Search in sources :

Example 16 with NetworkPolicyEditor

use of com.android.settingslib.NetworkPolicyEditor in project platform_packages_apps_Settings by BlissRoms.

the class DataUsageSummaryTest method testUpdateNetworkRestrictionSummary_shouldSetSummary.

@Test
public void testUpdateNetworkRestrictionSummary_shouldSetSummary() {
    final DataUsageSummary dataUsageSummary = spy(new DataUsageSummary());
    final NetworkRestrictionsPreference preference = mock(NetworkRestrictionsPreference.class);
    final NetworkPolicyEditor policyEditor = mock(NetworkPolicyEditor.class);
    final WifiManager wifiManager = mock(WifiManager.class);
    ReflectionHelpers.setField(dataUsageSummary, "mPolicyEditor", policyEditor);
    ReflectionHelpers.setField(dataUsageSummary, "mWifiManager", wifiManager);
    when(wifiManager.getConfiguredNetworks()).thenReturn(new ArrayList<WifiConfiguration>());
    doReturn(mContext.getResources()).when(dataUsageSummary).getResources();
    dataUsageSummary.updateNetworkRestrictionSummary(preference);
    verify(preference).setSummary(mContext.getResources().getQuantityString(R.plurals.network_restrictions_summary, 0, 0));
}
Also used : WifiManager(android.net.wifi.WifiManager) WifiConfiguration(android.net.wifi.WifiConfiguration) NetworkPolicyEditor(com.android.settingslib.NetworkPolicyEditor) Test(org.junit.Test)

Example 17 with NetworkPolicyEditor

use of com.android.settingslib.NetworkPolicyEditor in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class BillingCyclePreferenceController method displayPreference.

@Override
public void displayPreference(PreferenceScreen screen) {
    super.displayPreference(screen);
    BillingCyclePreference preference = screen.findPreference(getPreferenceKey());
    TemplatePreference.NetworkServices services = new TemplatePreference.NetworkServices();
    services.mNetworkService = INetworkManagementService.Stub.asInterface(ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE));
    services.mStatsService = INetworkStatsService.Stub.asInterface(ServiceManager.getService(Context.NETWORK_STATS_SERVICE));
    services.mPolicyManager = mContext.getSystemService(NetworkPolicyManager.class);
    services.mPolicyEditor = new NetworkPolicyEditor(services.mPolicyManager);
    services.mTelephonyManager = mContext.getSystemService(TelephonyManager.class);
    services.mSubscriptionManager = mContext.getSystemService(SubscriptionManager.class);
    services.mUserManager = mContext.getSystemService(UserManager.class);
    NetworkTemplate template = DataUsageUtils.getMobileTemplate(mContext, mSubscriptionId);
    preference.setTemplate(template, mSubscriptionId, services);
}
Also used : NetworkTemplate(android.net.NetworkTemplate) TelephonyManager(android.telephony.TelephonyManager) NetworkPolicyEditor(com.android.settingslib.NetworkPolicyEditor) UserManager(android.os.UserManager) NetworkPolicyManager(android.net.NetworkPolicyManager) SubscriptionManager(android.telephony.SubscriptionManager)

Example 18 with NetworkPolicyEditor

use of com.android.settingslib.NetworkPolicyEditor in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class DataUsageBase method onCreate.

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    final Context context = getActivity();
    services.mNetworkService = INetworkManagementService.Stub.asInterface(ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE));
    services.mStatsService = INetworkStatsService.Stub.asInterface(ServiceManager.getService(Context.NETWORK_STATS_SERVICE));
    services.mPolicyManager = NetworkPolicyManager.from(context);
    services.mPolicyEditor = new NetworkPolicyEditor(services.mPolicyManager);
    services.mTelephonyManager = TelephonyManager.from(context);
    services.mSubscriptionManager = SubscriptionManager.from(context);
    services.mUserManager = UserManager.get(context);
}
Also used : Context(android.content.Context) NetworkPolicyEditor(com.android.settingslib.NetworkPolicyEditor)

Example 19 with NetworkPolicyEditor

use of com.android.settingslib.NetworkPolicyEditor in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class DataUsageMeteredSettings method onCreate.

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    final Context context = getActivity();
    mPolicyManager = NetworkPolicyManager.from(context);
    mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    mPolicyEditor = new NetworkPolicyEditor(mPolicyManager);
    mPolicyEditor.read();
    addPreferencesFromResource(R.xml.data_usage_metered_prefs);
    mMobileCategory = (PreferenceCategory) findPreference("mobile");
    mWifiCategory = (PreferenceCategory) findPreference("wifi");
    mWifiDisabled = findPreference("wifi_disabled");
    updateNetworks(context);
}
Also used : Context(android.content.Context) NetworkPolicyEditor(com.android.settingslib.NetworkPolicyEditor)

Example 20 with NetworkPolicyEditor

use of com.android.settingslib.NetworkPolicyEditor in project android_packages_apps_Settings by LineageOS.

the class DataUsageBase method onCreate.

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    final Context context = getActivity();
    services.mNetworkService = INetworkManagementService.Stub.asInterface(ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE));
    services.mStatsService = INetworkStatsService.Stub.asInterface(ServiceManager.getService(Context.NETWORK_STATS_SERVICE));
    services.mPolicyManager = NetworkPolicyManager.from(context);
    services.mPolicyEditor = new NetworkPolicyEditor(services.mPolicyManager);
    services.mTelephonyManager = TelephonyManager.from(context);
    services.mSubscriptionManager = SubscriptionManager.from(context);
    services.mUserManager = UserManager.get(context);
}
Also used : Context(android.content.Context) NetworkPolicyEditor(com.android.settingslib.NetworkPolicyEditor)

Aggregations

NetworkPolicyEditor (com.android.settingslib.NetworkPolicyEditor)34 Context (android.content.Context)27 NetworkPolicyManager (android.net.NetworkPolicyManager)13 DataUsageController (com.android.settingslib.net.DataUsageController)12 WifiConfiguration (android.net.wifi.WifiConfiguration)6 WifiManager (android.net.wifi.WifiManager)6 SubscriptionInfo (android.telephony.SubscriptionInfo)6 Test (org.junit.Test)6 NetworkTemplate (android.net.NetworkTemplate)1 UserManager (android.os.UserManager)1 SubscriptionManager (android.telephony.SubscriptionManager)1 TelephonyManager (android.telephony.TelephonyManager)1