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));
}
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);
}
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);
}
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);
}
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);
}
Aggregations