[Settings] Convert to getSystemService(Class<T>)
Change to getSystemService(Class<T>) to align the capability with framework part. Bug: 179640862 Test: local Change-Id: I1b4812044fc4876bec6645570049a60f9470dbbd
This commit is contained in:
@@ -55,7 +55,7 @@ public class DeviceNamePreferenceController extends BasePreferenceController
|
|||||||
public DeviceNamePreferenceController(Context context, String key) {
|
public DeviceNamePreferenceController(Context context, String key) {
|
||||||
super(context, key);
|
super(context, key);
|
||||||
|
|
||||||
mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
|
mWifiManager = context.getSystemService(WifiManager.class);
|
||||||
mWifiDeviceNameTextValidator = new WifiDeviceNameTextValidator();
|
mWifiDeviceNameTextValidator = new WifiDeviceNameTextValidator();
|
||||||
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
||||||
|
|
||||||
|
@@ -115,7 +115,7 @@ public class StorageWizardMigrateConfirm extends StorageWizardBase {
|
|||||||
try {
|
try {
|
||||||
moveId = getPackageManager().movePrimaryStorage(mVolume);
|
moveId = getPackageManager().movePrimaryStorage(mVolume);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
StorageManager sm = (StorageManager) getSystemService(STORAGE_SERVICE);
|
StorageManager sm = getSystemService(StorageManager.class);
|
||||||
|
|
||||||
if (Objects.equals(mVolume.getFsUuid(), sm.getPrimaryStorageVolume().getUuid())) {
|
if (Objects.equals(mVolume.getFsUuid(), sm.getPrimaryStorageVolume().getUuid())) {
|
||||||
final Intent intent = new Intent(this, StorageWizardReady.class);
|
final Intent intent = new Intent(this, StorageWizardReady.class);
|
||||||
|
@@ -146,8 +146,8 @@ public class MyDeviceInfoFragment extends DashboardFragment
|
|||||||
// TODO: There may be an avatar setting action we can use here.
|
// TODO: There may be an avatar setting action we can use here.
|
||||||
final int iconId = bundle.getInt("icon_id", 0);
|
final int iconId = bundle.getInt("icon_id", 0);
|
||||||
if (iconId == 0) {
|
if (iconId == 0) {
|
||||||
final UserManager userManager = (UserManager) getActivity().getSystemService(
|
final UserManager userManager = getActivity().getSystemService(
|
||||||
Context.USER_SERVICE);
|
UserManager.class);
|
||||||
final UserInfo info = Utils.getExistingUser(userManager,
|
final UserInfo info = Utils.getExistingUser(userManager,
|
||||||
android.os.Process.myUserHandle());
|
android.os.Process.myUserHandle());
|
||||||
controller.setLabel(info.name);
|
controller.setLabel(info.name);
|
||||||
|
@@ -49,7 +49,7 @@ public class FirmwareVersionDetailPreferenceController extends BasePreferenceCon
|
|||||||
|
|
||||||
public FirmwareVersionDetailPreferenceController(Context context, String key) {
|
public FirmwareVersionDetailPreferenceController(Context context, String key) {
|
||||||
super(context, key);
|
super(context, key);
|
||||||
mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
|
mUserManager = mContext.getSystemService(UserManager.class);
|
||||||
initializeAdminPermissions();
|
initializeAdminPermissions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -49,7 +49,7 @@ public class ImeiInfoPreferenceController extends BasePreferenceController {
|
|||||||
|
|
||||||
public ImeiInfoPreferenceController(Context context, String key) {
|
public ImeiInfoPreferenceController(Context context, String key) {
|
||||||
super(context, key);
|
super(context, key);
|
||||||
mTelephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
mTelephonyManager = context.getSystemService(TelephonyManager.class);
|
||||||
mIsMultiSim = mTelephonyManager.getPhoneCount() > 1;
|
mIsMultiSim = mTelephonyManager.getPhoneCount() > 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -46,9 +46,9 @@ public class SimStatusPreferenceController extends
|
|||||||
public SimStatusPreferenceController(Context context, Fragment fragment) {
|
public SimStatusPreferenceController(Context context, Fragment fragment) {
|
||||||
super(context);
|
super(context);
|
||||||
|
|
||||||
mTelephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
mTelephonyManager = context.getSystemService(TelephonyManager.class);
|
||||||
mSubscriptionManager = (SubscriptionManager) context.getSystemService(
|
mSubscriptionManager = context.getSystemService(
|
||||||
Context.TELEPHONY_SUBSCRIPTION_SERVICE);
|
SubscriptionManager.class);
|
||||||
mFragment = fragment;
|
mFragment = fragment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1285,8 +1285,8 @@ public class ApnEditor extends SettingsPreferenceFragment
|
|||||||
mReadOnlyApnTypes = null;
|
mReadOnlyApnTypes = null;
|
||||||
mReadOnlyApnFields = null;
|
mReadOnlyApnFields = null;
|
||||||
|
|
||||||
final CarrierConfigManager configManager = (CarrierConfigManager)
|
final CarrierConfigManager configManager =
|
||||||
getSystemService(Context.CARRIER_CONFIG_SERVICE);
|
getSystemService(CarrierConfigManager.class);
|
||||||
if (configManager != null) {
|
if (configManager != null) {
|
||||||
final PersistableBundle b = configManager.getConfigForSubId(mSubId);
|
final PersistableBundle b = configManager.getConfigForSubId(mSubId);
|
||||||
if (b != null) {
|
if (b != null) {
|
||||||
|
@@ -206,8 +206,8 @@ public class ApnSettings extends RestrictedSettingsFragment
|
|||||||
mSubscriptionInfo = getSubscriptionInfo(mSubId);
|
mSubscriptionInfo = getSubscriptionInfo(mSubId);
|
||||||
mTelephonyManager = activity.getSystemService(TelephonyManager.class);
|
mTelephonyManager = activity.getSystemService(TelephonyManager.class);
|
||||||
|
|
||||||
final CarrierConfigManager configManager = (CarrierConfigManager)
|
final CarrierConfigManager configManager =
|
||||||
getSystemService(Context.CARRIER_CONFIG_SERVICE);
|
getSystemService(CarrierConfigManager.class);
|
||||||
final PersistableBundle b = configManager.getConfigForSubId(mSubId);
|
final PersistableBundle b = configManager.getConfigForSubId(mSubId);
|
||||||
mHideImsApn = b.getBoolean(CarrierConfigManager.KEY_HIDE_IMS_APN_BOOL);
|
mHideImsApn = b.getBoolean(CarrierConfigManager.KEY_HIDE_IMS_APN_BOOL);
|
||||||
mAllowAddingApns = b.getBoolean(CarrierConfigManager.KEY_ALLOW_ADDING_APNS_BOOL);
|
mAllowAddingApns = b.getBoolean(CarrierConfigManager.KEY_ALLOW_ADDING_APNS_BOOL);
|
||||||
|
@@ -43,7 +43,7 @@ public final class EthernetTetherPreferenceController extends TetherBasePreferen
|
|||||||
super(context, preferenceKey);
|
super(context, preferenceKey);
|
||||||
mEthernetRegex = context.getString(
|
mEthernetRegex = context.getString(
|
||||||
com.android.internal.R.string.config_ethernet_iface_regex);
|
com.android.internal.R.string.config_ethernet_iface_regex);
|
||||||
mEthernetManager = (EthernetManager) context.getSystemService(Context.ETHERNET_SERVICE);
|
mEthernetManager = context.getSystemService(EthernetManager.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnLifecycleEvent(Lifecycle.Event.ON_START)
|
@OnLifecycleEvent(Lifecycle.Event.ON_START)
|
||||||
|
@@ -73,9 +73,9 @@ public class MobilePlanPreferenceController extends AbstractPreferenceController
|
|||||||
MobilePlanPreferenceHost host) {
|
MobilePlanPreferenceHost host) {
|
||||||
super(context);
|
super(context);
|
||||||
mHost = host;
|
mHost = host;
|
||||||
mCm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
mCm = context.getSystemService(ConnectivityManager.class);
|
||||||
mTm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
mTm = context.getSystemService(TelephonyManager.class);
|
||||||
mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
|
mUserManager = context.getSystemService(UserManager.class);
|
||||||
mIsSecondaryUser = !mUserManager.isAdminUser();
|
mIsSecondaryUser = !mUserManager.isAdminUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -31,7 +31,7 @@ public class NetworkResetRestrictionChecker {
|
|||||||
|
|
||||||
public NetworkResetRestrictionChecker(Context context) {
|
public NetworkResetRestrictionChecker(Context context) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
|
mUserManager = context.getSystemService(UserManager.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
|
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
|
||||||
|
@@ -140,6 +140,6 @@ public class NetworkScorerPicker extends InstrumentedPreferenceFragment implemen
|
|||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
NetworkScoreManager createNetworkScorerManager(Context context) {
|
NetworkScoreManager createNetworkScorerManager(Context context) {
|
||||||
return (NetworkScoreManager) context.getSystemService(Context.NETWORK_SCORE_SERVICE);
|
return context.getSystemService(NetworkScoreManager.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -37,7 +37,7 @@ public class NetworkScorerPickerPreferenceController extends BasePreferenceContr
|
|||||||
public NetworkScorerPickerPreferenceController(Context context, String key) {
|
public NetworkScorerPickerPreferenceController(Context context, String key) {
|
||||||
super(context, key);
|
super(context, key);
|
||||||
mNetworkScoreManager =
|
mNetworkScoreManager =
|
||||||
(NetworkScoreManager) mContext.getSystemService(Context.NETWORK_SCORE_SERVICE);
|
mContext.getSystemService(NetworkScoreManager.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -128,10 +128,10 @@ public class TetherEnabler implements SwitchWidgetController.OnSwitchChangeListe
|
|||||||
mSwitchWidgetController = switchWidgetController;
|
mSwitchWidgetController = switchWidgetController;
|
||||||
mDataSaverBackend = new DataSaverBackend(context);
|
mDataSaverBackend = new DataSaverBackend(context);
|
||||||
mConnectivityManager =
|
mConnectivityManager =
|
||||||
(ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
context.getSystemService(ConnectivityManager.class);
|
||||||
mTetheringManager = (TetheringManager) context.getSystemService(Context.TETHERING_SERVICE);
|
mTetheringManager = context.getSystemService(TetheringManager.class);
|
||||||
mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
|
mWifiManager = context.getSystemService(WifiManager.class);
|
||||||
mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
|
mUserManager = context.getSystemService(UserManager.class);
|
||||||
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
||||||
mBluetoothPan = bluetoothPan;
|
mBluetoothPan = bluetoothPan;
|
||||||
mEthernetRegex =
|
mEthernetRegex =
|
||||||
|
@@ -194,7 +194,7 @@ public class MobileNetworkSettings extends AbstractMobileNetworkSettings {
|
|||||||
|
|
||||||
super.onCreate(icicle);
|
super.onCreate(icicle);
|
||||||
final Context context = getContext();
|
final Context context = getContext();
|
||||||
mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
|
mUserManager = context.getSystemService(UserManager.class);
|
||||||
mTelephonyManager = context.getSystemService(TelephonyManager.class)
|
mTelephonyManager = context.getSystemService(TelephonyManager.class)
|
||||||
.createForSubscriptionId(mSubId);
|
.createForSubscriptionId(mSubId);
|
||||||
|
|
||||||
|
@@ -106,8 +106,8 @@ public class NetworkSelectSettings extends DashboardFragment {
|
|||||||
.createForSubscriptionId(mSubId);
|
.createForSubscriptionId(mSubId);
|
||||||
mNetworkScanHelper = new NetworkScanHelper(
|
mNetworkScanHelper = new NetworkScanHelper(
|
||||||
mTelephonyManager, mCallback, mNetworkScanExecutor);
|
mTelephonyManager, mCallback, mNetworkScanExecutor);
|
||||||
PersistableBundle bundle = ((CarrierConfigManager) getContext().getSystemService(
|
PersistableBundle bundle = (getContext().getSystemService(
|
||||||
Context.CARRIER_CONFIG_SERVICE)).getConfigForSubId(mSubId);
|
CarrierConfigManager.class)).getConfigForSubId(mSubId);
|
||||||
if (bundle != null) {
|
if (bundle != null) {
|
||||||
mShow4GForLTE = bundle.getBoolean(
|
mShow4GForLTE = bundle.getBoolean(
|
||||||
CarrierConfigManager.KEY_SHOW_4G_FOR_LTE_DATA_ICON_BOOL);
|
CarrierConfigManager.KEY_SHOW_4G_FOR_LTE_DATA_ICON_BOOL);
|
||||||
|
@@ -190,8 +190,8 @@ public class RenameMobileNetworkDialogFragment extends InstrumentedDialogFragmen
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View getView(int position, View convertView, ViewGroup parent) {
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
final LayoutInflater inflater = (LayoutInflater)
|
final LayoutInflater inflater =
|
||||||
mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
mContext.getSystemService(LayoutInflater.class);
|
||||||
|
|
||||||
if (convertView == null) {
|
if (convertView == null) {
|
||||||
convertView = inflater.inflate(mItemResId, null);
|
convertView = inflater.inflate(mItemResId, null);
|
||||||
|
@@ -104,8 +104,8 @@ public class SimSelectNotification extends BroadcastReceiver {
|
|||||||
subId = SubscriptionManager.getDefaultSmsSubscriptionId();
|
subId = SubscriptionManager.getDefaultSmsSubscriptionId();
|
||||||
}
|
}
|
||||||
|
|
||||||
SubscriptionManager subscriptionManager = ((SubscriptionManager) context.getSystemService(
|
SubscriptionManager subscriptionManager = (context.getSystemService(
|
||||||
Context.TELEPHONY_SUBSCRIPTION_SERVICE));
|
SubscriptionManager.class));
|
||||||
if (!subscriptionManager.isActiveSubscriptionId(subId)) {
|
if (!subscriptionManager.isActiveSubscriptionId(subId)) {
|
||||||
Log.w(TAG, "onEnableMmsDataRequest invalid sub ID " + subId);
|
Log.w(TAG, "onEnableMmsDataRequest invalid sub ID " + subId);
|
||||||
return;
|
return;
|
||||||
@@ -130,8 +130,8 @@ public class SimSelectNotification extends BroadcastReceiver {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TelephonyManager tm = ((TelephonyManager) context.getSystemService(
|
TelephonyManager tm = (context.getSystemService(
|
||||||
Context.TELEPHONY_SERVICE)).createForSubscriptionId(subId);
|
TelephonyManager.class)).createForSubscriptionId(subId);
|
||||||
|
|
||||||
if (tm.isDataEnabledForApn(TYPE_MMS)) {
|
if (tm.isDataEnabledForApn(TYPE_MMS)) {
|
||||||
Log.w(TAG, "onEnableMmsDataRequest MMS data already enabled on sub ID " + subId);
|
Log.w(TAG, "onEnableMmsDataRequest MMS data already enabled on sub ID " + subId);
|
||||||
@@ -229,14 +229,14 @@ public class SimSelectNotification extends BroadcastReceiver {
|
|||||||
PendingIntent.FLAG_CANCEL_CURRENT);
|
PendingIntent.FLAG_CANCEL_CURRENT);
|
||||||
builder.setContentIntent(resultPendingIntent);
|
builder.setContentIntent(resultPendingIntent);
|
||||||
NotificationManager notificationManager =
|
NotificationManager notificationManager =
|
||||||
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
context.getSystemService(NotificationManager.class);
|
||||||
notificationManager.createNotificationChannel(notificationChannel);
|
notificationManager.createNotificationChannel(notificationChannel);
|
||||||
notificationManager.notify(SIM_SELECT_NOTIFICATION_ID, builder.build());
|
notificationManager.notify(SIM_SELECT_NOTIFICATION_ID, builder.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void cancelSimSelectNotification(Context context) {
|
public static void cancelSimSelectNotification(Context context) {
|
||||||
NotificationManager notificationManager =
|
NotificationManager notificationManager =
|
||||||
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
context.getSystemService(NotificationManager.class);
|
||||||
notificationManager.cancel(SIM_SELECT_NOTIFICATION_ID);
|
notificationManager.cancel(SIM_SELECT_NOTIFICATION_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -269,14 +269,14 @@ public class SimSelectNotification extends BroadcastReceiver {
|
|||||||
|
|
||||||
// Notify the notification.
|
// Notify the notification.
|
||||||
NotificationManager notificationManager =
|
NotificationManager notificationManager =
|
||||||
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
context.getSystemService(NotificationManager.class);
|
||||||
notificationManager.createNotificationChannel(notificationChannel);
|
notificationManager.createNotificationChannel(notificationChannel);
|
||||||
notificationManager.notify(ENABLE_MMS_NOTIFICATION_ID, builder.build());
|
notificationManager.notify(ENABLE_MMS_NOTIFICATION_ID, builder.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cancelEnableMmsNotification(Context context) {
|
private void cancelEnableMmsNotification(Context context) {
|
||||||
NotificationManager notificationManager =
|
NotificationManager notificationManager =
|
||||||
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
context.getSystemService(NotificationManager.class);
|
||||||
notificationManager.cancel(ENABLE_MMS_NOTIFICATION_ID);
|
notificationManager.cancel(ENABLE_MMS_NOTIFICATION_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -319,7 +319,7 @@ public class AppManagementFragment extends SettingsPreferenceFragment
|
|||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
static boolean appHasVpnPermission(Context context, @NonNull ApplicationInfo application) {
|
static boolean appHasVpnPermission(Context context, @NonNull ApplicationInfo application) {
|
||||||
final AppOpsManager service =
|
final AppOpsManager service =
|
||||||
(AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
|
context.getSystemService(AppOpsManager.class);
|
||||||
final List<AppOpsManager.PackageOps> ops = service.getOpsForPackage(application.uid,
|
final List<AppOpsManager.PackageOps> ops = service.getOpsForPackage(application.uid,
|
||||||
application.packageName, new int[]{OP_ACTIVATE_VPN, OP_ACTIVATE_PLATFORM_VPN});
|
application.packageName, new int[]{OP_ACTIVATE_VPN, OP_ACTIVATE_PLATFORM_VPN});
|
||||||
return !ArrayUtils.isEmpty(ops);
|
return !ArrayUtils.isEmpty(ops);
|
||||||
|
@@ -116,9 +116,9 @@ public class VpnSettings extends RestrictedSettingsFragment implements
|
|||||||
public void onActivityCreated(Bundle savedInstanceState) {
|
public void onActivityCreated(Bundle savedInstanceState) {
|
||||||
super.onActivityCreated(savedInstanceState);
|
super.onActivityCreated(savedInstanceState);
|
||||||
|
|
||||||
mUserManager = (UserManager) getSystemService(Context.USER_SERVICE);
|
mUserManager = getSystemService(UserManager.class);
|
||||||
mConnectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
mConnectivityManager = getSystemService(ConnectivityManager.class);
|
||||||
mVpnManager = (VpnManager) getSystemService(Context.VPN_MANAGEMENT_SERVICE);
|
mVpnManager = getSystemService(VpnManager.class);
|
||||||
|
|
||||||
mUnavailable = isUiRestricted();
|
mUnavailable = isUiRestricted();
|
||||||
setHasOptionsMenu(!mUnavailable);
|
setHasOptionsMenu(!mUnavailable);
|
||||||
@@ -509,7 +509,7 @@ public class VpnSettings extends RestrictedSettingsFragment implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fetch VPN-enabled apps from AppOps.
|
// Fetch VPN-enabled apps from AppOps.
|
||||||
AppOpsManager aom = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
|
AppOpsManager aom = context.getSystemService(AppOpsManager.class);
|
||||||
List<AppOpsManager.PackageOps> apps =
|
List<AppOpsManager.PackageOps> apps =
|
||||||
aom.getPackagesForOps(new int[] {OP_ACTIVATE_VPN, OP_ACTIVATE_PLATFORM_VPN});
|
aom.getPackagesForOps(new int[] {OP_ACTIVATE_VPN, OP_ACTIVATE_PLATFORM_VPN});
|
||||||
if (apps != null) {
|
if (apps != null) {
|
||||||
|
@@ -49,7 +49,7 @@ public class ChangeWifiStateDetails extends AppInfoWithHeader
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
final Context context = getActivity();
|
final Context context = getActivity();
|
||||||
mAppBridge = new AppStateChangeWifiStateBridge(context, mState, null);
|
mAppBridge = new AppStateChangeWifiStateBridge(context, mState, null);
|
||||||
mAppOpsManager = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
|
mAppOpsManager = context.getSystemService(AppOpsManager.class);
|
||||||
|
|
||||||
// find preferences
|
// find preferences
|
||||||
addPreferencesFromResource(R.xml.change_wifi_state_details);
|
addPreferencesFromResource(R.xml.change_wifi_state_details);
|
||||||
|
@@ -68,7 +68,7 @@ public class ConfigureWifiSettings extends DashboardFragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
|
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
|
||||||
final WifiManager wifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
|
final WifiManager wifiManager = getSystemService(WifiManager.class);
|
||||||
final List<AbstractPreferenceController> controllers = new ArrayList<>();
|
final List<AbstractPreferenceController> controllers = new ArrayList<>();
|
||||||
controllers.add(new WifiP2pPreferenceController(context, getSettingsLifecycle(),
|
controllers.add(new WifiP2pPreferenceController(context, getSettingsLifecycle(),
|
||||||
wifiManager));
|
wifiManager));
|
||||||
|
@@ -51,7 +51,7 @@ public class UseOpenWifiPreferenceController extends TogglePreferenceController
|
|||||||
super(context, KEY_USE_OPEN_WIFI_AUTOMATICALLY);
|
super(context, KEY_USE_OPEN_WIFI_AUTOMATICALLY);
|
||||||
mContentResolver = context.getContentResolver();
|
mContentResolver = context.getContentResolver();
|
||||||
mNetworkScoreManager =
|
mNetworkScoreManager =
|
||||||
(NetworkScoreManager) context.getSystemService(Context.NETWORK_SCORE_SERVICE);
|
context.getSystemService(NetworkScoreManager.class);
|
||||||
mSettingObserver = new SettingObserver();
|
mSettingObserver = new SettingObserver();
|
||||||
updateEnableUseWifiComponentName();
|
updateEnableUseWifiComponentName();
|
||||||
checkForFeatureSupportedScorers();
|
checkForFeatureSupportedScorers();
|
||||||
|
@@ -64,7 +64,7 @@ public class WifiAPITest extends SettingsPreferenceFragment implements
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
mWifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
|
mWifiManager = getSystemService(WifiManager.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -38,7 +38,7 @@ public class WifiConfigInfo extends Activity {
|
|||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
mWifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
|
mWifiManager = getSystemService(WifiManager.class);
|
||||||
setContentView(R.layout.wifi_config_info);
|
setContentView(R.layout.wifi_config_info);
|
||||||
mConfigList = (TextView) findViewById(R.id.config_list);
|
mConfigList = (TextView) findViewById(R.id.config_list);
|
||||||
}
|
}
|
||||||
|
@@ -75,7 +75,7 @@ public class WifiEnabler implements SwitchWidgetController.OnSwitchChangeListene
|
|||||||
public WifiEnabler(Context context, SwitchWidgetController switchWidget,
|
public WifiEnabler(Context context, SwitchWidgetController switchWidget,
|
||||||
MetricsFeatureProvider metricsFeatureProvider) {
|
MetricsFeatureProvider metricsFeatureProvider) {
|
||||||
this(context, switchWidget, metricsFeatureProvider,
|
this(context, switchWidget, metricsFeatureProvider,
|
||||||
(ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE));
|
context.getSystemService(ConnectivityManager.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
@@ -86,7 +86,7 @@ public class WifiEnabler implements SwitchWidgetController.OnSwitchChangeListene
|
|||||||
mSwitchWidget = switchWidget;
|
mSwitchWidget = switchWidget;
|
||||||
mSwitchWidget.setListener(this);
|
mSwitchWidget.setListener(this);
|
||||||
mMetricsFeatureProvider = metricsFeatureProvider;
|
mMetricsFeatureProvider = metricsFeatureProvider;
|
||||||
mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
|
mWifiManager = context.getSystemService(WifiManager.class);
|
||||||
mConnectivityManager = connectivityManager;
|
mConnectivityManager = connectivityManager;
|
||||||
|
|
||||||
mIntentFilter = new IntentFilter(WifiManager.WIFI_STATE_CHANGED_ACTION);
|
mIntentFilter = new IntentFilter(WifiManager.WIFI_STATE_CHANGED_ACTION);
|
||||||
|
@@ -102,7 +102,7 @@ public final class WifiNoInternetDialog extends AlertActivity implements
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
mCM = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
mCM = getSystemService(ConnectivityManager.class);
|
||||||
mCM.registerNetworkCallback(request, mNetworkCallback);
|
mCM.registerNetworkCallback(request, mNetworkCallback);
|
||||||
|
|
||||||
final NetworkInfo ni = mCM.getNetworkInfo(mNetwork);
|
final NetworkInfo ni = mCM.getNetworkInfo(mNetwork);
|
||||||
|
@@ -116,7 +116,7 @@ public class WifiStatusTest extends Activity {
|
|||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
mWifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
|
mWifiManager = getSystemService(WifiManager.class);
|
||||||
|
|
||||||
mWifiStateFilter = new IntentFilter(WifiManager.WIFI_STATE_CHANGED_ACTION);
|
mWifiStateFilter = new IntentFilter(WifiManager.WIFI_STATE_CHANGED_ACTION);
|
||||||
mWifiStateFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
|
mWifiStateFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
|
||||||
|
@@ -83,7 +83,7 @@ public class WifiUtils {
|
|||||||
final DevicePolicyManager dpm =
|
final DevicePolicyManager dpm =
|
||||||
(DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE);
|
(DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE);
|
||||||
final PackageManager pm = context.getPackageManager();
|
final PackageManager pm = context.getPackageManager();
|
||||||
final UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE);
|
final UserManager um = context.getSystemService(UserManager.class);
|
||||||
|
|
||||||
// Check if device has DPM capability. If it has and dpm is still null, then we
|
// Check if device has DPM capability. If it has and dpm is still null, then we
|
||||||
// treat this case with suspicion and bail out.
|
// treat this case with suspicion and bail out.
|
||||||
|
@@ -73,7 +73,7 @@ public class WifiWakeupPreferenceController extends TogglePreferenceController i
|
|||||||
|
|
||||||
public WifiWakeupPreferenceController(Context context) {
|
public WifiWakeupPreferenceController(Context context) {
|
||||||
super(context, KEY_ENABLE_WIFI_WAKEUP);
|
super(context, KEY_ENABLE_WIFI_WAKEUP);
|
||||||
mLocationManager = (LocationManager) context.getSystemService(Service.LOCATION_SERVICE);
|
mLocationManager = context.getSystemService(LocationManager.class);
|
||||||
mWifiManager = context.getSystemService(WifiManager.class);
|
mWifiManager = context.getSystemService(WifiManager.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -124,8 +124,8 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment
|
|||||||
|
|
||||||
boolean isWfcModeEditable = true;
|
boolean isWfcModeEditable = true;
|
||||||
boolean isWfcRoamingModeEditable = false;
|
boolean isWfcRoamingModeEditable = false;
|
||||||
final CarrierConfigManager configManager = (CarrierConfigManager)
|
final CarrierConfigManager configManager =
|
||||||
activity.getSystemService(Context.CARRIER_CONFIG_SERVICE);
|
activity.getSystemService(CarrierConfigManager.class);
|
||||||
if (configManager != null) {
|
if (configManager != null) {
|
||||||
PersistableBundle b =
|
PersistableBundle b =
|
||||||
configManager.getConfigForSubId(WifiCallingSettingsForSub.this.mSubId);
|
configManager.getConfigForSubId(WifiCallingSettingsForSub.this.mSubId);
|
||||||
@@ -340,8 +340,8 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final CarrierConfigManager configManager = (CarrierConfigManager)
|
final CarrierConfigManager configManager =
|
||||||
getSystemService(Context.CARRIER_CONFIG_SERVICE);
|
getSystemService(CarrierConfigManager.class);
|
||||||
boolean isWifiOnlySupported = true;
|
boolean isWifiOnlySupported = true;
|
||||||
|
|
||||||
if (configManager != null) {
|
if (configManager != null) {
|
||||||
|
@@ -42,7 +42,7 @@ public class AddDevicePreferenceController2 extends BasePreferenceController {
|
|||||||
public AddDevicePreferenceController2(Context context) {
|
public AddDevicePreferenceController2(Context context) {
|
||||||
super(context, KEY_ADD_DEVICE);
|
super(context, KEY_ADD_DEVICE);
|
||||||
|
|
||||||
mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
|
mWifiManager = context.getSystemService(WifiManager.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWifiEntry(WifiEntry wifiEntry) {
|
public void setWifiEntry(WifiEntry wifiEntry) {
|
||||||
|
@@ -140,8 +140,8 @@ public class WifiNetworkDetailsFragment2 extends DashboardFragment implements
|
|||||||
if (admin == null) {
|
if (admin == null) {
|
||||||
final DevicePolicyManager dpm = (DevicePolicyManager)
|
final DevicePolicyManager dpm = (DevicePolicyManager)
|
||||||
getContext().getSystemService(Context.DEVICE_POLICY_SERVICE);
|
getContext().getSystemService(Context.DEVICE_POLICY_SERVICE);
|
||||||
final UserManager um = (UserManager)
|
final UserManager um =
|
||||||
getContext().getSystemService(Context.USER_SERVICE);
|
getContext().getSystemService(UserManager.class);
|
||||||
final int profileOwnerUserId = Utils.getManagedProfileId(
|
final int profileOwnerUserId = Utils.getManagedProfileId(
|
||||||
um, UserHandle.myUserId());
|
um, UserHandle.myUserId());
|
||||||
if (profileOwnerUserId != UserHandle.USER_NULL) {
|
if (profileOwnerUserId != UserHandle.USER_NULL) {
|
||||||
|
@@ -45,7 +45,7 @@ public class WifiPrivacyPreferenceController2 extends BasePreferenceController i
|
|||||||
public WifiPrivacyPreferenceController2(Context context) {
|
public WifiPrivacyPreferenceController2(Context context) {
|
||||||
super(context, KEY_WIFI_PRIVACY);
|
super(context, KEY_WIFI_PRIVACY);
|
||||||
|
|
||||||
mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
|
mWifiManager = context.getSystemService(WifiManager.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWifiEntry(WifiEntry wifiEntry) {
|
public void setWifiEntry(WifiEntry wifiEntry) {
|
||||||
|
@@ -403,8 +403,8 @@ public class WifiDppUtils {
|
|||||||
* device security or if lock screen is unlocked
|
* device security or if lock screen is unlocked
|
||||||
*/
|
*/
|
||||||
public static void showLockScreen(Context context, Runnable successRunnable) {
|
public static void showLockScreen(Context context, Runnable successRunnable) {
|
||||||
final KeyguardManager keyguardManager = (KeyguardManager) context.getSystemService(
|
final KeyguardManager keyguardManager = context.getSystemService(
|
||||||
Context.KEYGUARD_SERVICE);
|
KeyguardManager.class);
|
||||||
|
|
||||||
if (keyguardManager.isKeyguardSecure()) {
|
if (keyguardManager.isKeyguardSecure()) {
|
||||||
final BiometricPrompt.AuthenticationCallback authenticationCallback =
|
final BiometricPrompt.AuthenticationCallback authenticationCallback =
|
||||||
|
@@ -71,7 +71,7 @@ public class WifiP2pPreferenceController extends AbstractPreferenceController
|
|||||||
super(context);
|
super(context);
|
||||||
mWifiManager = wifiManager;
|
mWifiManager = wifiManager;
|
||||||
lifecycle.addObserver(this);
|
lifecycle.addObserver(this);
|
||||||
mLocationManager = (LocationManager) context.getSystemService(Service.LOCATION_SERVICE);
|
mLocationManager = context.getSystemService(LocationManager.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -200,7 +200,7 @@ public class WifiP2pSettings extends DashboardFragment
|
|||||||
public void onActivityCreated(Bundle savedInstanceState) {
|
public void onActivityCreated(Bundle savedInstanceState) {
|
||||||
final Activity activity = getActivity();
|
final Activity activity = getActivity();
|
||||||
if (mWifiP2pManager == null) {
|
if (mWifiP2pManager == null) {
|
||||||
mWifiP2pManager = (WifiP2pManager) getSystemService(Context.WIFI_P2P_SERVICE);
|
mWifiP2pManager = getSystemService(WifiP2pManager.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mWifiP2pManager != null) {
|
if (mWifiP2pManager != null) {
|
||||||
|
@@ -202,7 +202,7 @@ public class QrCamera extends Handler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final WindowManager winManager =
|
final WindowManager winManager =
|
||||||
(WindowManager) mContext.get().getSystemService(Context.WINDOW_SERVICE);
|
mContext.get().getSystemService(WindowManager.class);
|
||||||
final int rotation = winManager.getDefaultDisplay().getRotation();
|
final int rotation = winManager.getDefaultDisplay().getRotation();
|
||||||
int degrees = 0;
|
int degrees = 0;
|
||||||
switch (rotation) {
|
switch (rotation) {
|
||||||
|
@@ -255,7 +255,7 @@ public class TetherService extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void disableTethering(final int tetheringType) {
|
private void disableTethering(final int tetheringType) {
|
||||||
final TetheringManager tm = (TetheringManager) getSystemService(Context.TETHERING_SERVICE);
|
final TetheringManager tm = getSystemService(TetheringManager.class);
|
||||||
tm.stopTethering(tetheringType);
|
tm.stopTethering(tetheringType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -45,8 +45,8 @@ public abstract class WifiTetherBasePreferenceController extends AbstractPrefere
|
|||||||
OnTetherConfigUpdateListener listener) {
|
OnTetherConfigUpdateListener listener) {
|
||||||
super(context);
|
super(context);
|
||||||
mListener = listener;
|
mListener = listener;
|
||||||
mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
|
mWifiManager = context.getSystemService(WifiManager.class);
|
||||||
mTm = (TetheringManager) context.getSystemService(Context.TETHERING_SERVICE);
|
mTm = context.getSystemService(TetheringManager.class);
|
||||||
mWifiRegexs = mTm.getTetherableWifiRegexs();
|
mWifiRegexs = mTm.getTetherableWifiRegexs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -63,7 +63,7 @@ public class WifiTetherPreferenceController extends AbstractPreferenceController
|
|||||||
boolean initSoftApManager) {
|
boolean initSoftApManager) {
|
||||||
super(context);
|
super(context);
|
||||||
mTetheringManager = context.getSystemService(TetheringManager.class);
|
mTetheringManager = context.getSystemService(TetheringManager.class);
|
||||||
mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
|
mWifiManager = context.getSystemService(WifiManager.class);
|
||||||
mWifiRegexs = mTetheringManager.getTetherableWifiRegexs();
|
mWifiRegexs = mTetheringManager.getTetherableWifiRegexs();
|
||||||
mLifecycle = lifecycle;
|
mLifecycle = lifecycle;
|
||||||
if (lifecycle != null) {
|
if (lifecycle != null) {
|
||||||
|
@@ -110,7 +110,7 @@ public class WifiTetherSettings extends RestrictedDashboardFragment
|
|||||||
@Override
|
@Override
|
||||||
public void onAttach(Context context) {
|
public void onAttach(Context context) {
|
||||||
super.onAttach(context);
|
super.onAttach(context);
|
||||||
mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
|
mWifiManager = context.getSystemService(WifiManager.class);
|
||||||
mTetherChangeReceiver = new TetherChangeReceiver();
|
mTetherChangeReceiver = new TetherChangeReceiver();
|
||||||
|
|
||||||
mSSIDPreferenceController = use(WifiTetherSSIDPreferenceController.class);
|
mSSIDPreferenceController = use(WifiTetherSSIDPreferenceController.class);
|
||||||
|
@@ -73,8 +73,8 @@ public class WifiTetherSwitchBarController implements
|
|||||||
mSwitch = mSwitchBar.getSwitch();
|
mSwitch = mSwitchBar.getSwitch();
|
||||||
mDataSaverBackend = new DataSaverBackend(context);
|
mDataSaverBackend = new DataSaverBackend(context);
|
||||||
mConnectivityManager =
|
mConnectivityManager =
|
||||||
(ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
context.getSystemService(ConnectivityManager.class);
|
||||||
mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
|
mWifiManager = context.getSystemService(WifiManager.class);
|
||||||
mSwitchBar.setChecked(mWifiManager.getWifiApState() == WifiManager.WIFI_AP_STATE_ENABLED);
|
mSwitchBar.setChecked(mWifiManager.getWifiApState() == WifiManager.WIFI_AP_STATE_ENABLED);
|
||||||
updateWifiSwitch();
|
updateWifiSwitch();
|
||||||
}
|
}
|
||||||
|
@@ -181,8 +181,8 @@ public class ImeiInfoPreferenceControllerTest {
|
|||||||
|
|
||||||
mController.copy();
|
mController.copy();
|
||||||
|
|
||||||
final ClipboardManager clipboard = (ClipboardManager) mContext.getSystemService(
|
final ClipboardManager clipboard = mContext.getSystemService(
|
||||||
CLIPBOARD_SERVICE);
|
ClipboardManager.class);
|
||||||
final CharSequence data = clipboard.getPrimaryClip().getItemAt(0).getText();
|
final CharSequence data = clipboard.getPrimaryClip().getItemAt(0).getText();
|
||||||
assertThat(data.toString()).isEqualTo(meid);
|
assertThat(data.toString()).isEqualTo(meid);
|
||||||
}
|
}
|
||||||
|
@@ -57,7 +57,7 @@ public class BluetoothTetherPreferenceControllerTest {
|
|||||||
|
|
||||||
mContext = spy(ApplicationProvider.getApplicationContext());
|
mContext = spy(ApplicationProvider.getApplicationContext());
|
||||||
mSwitchPreference = spy(SwitchPreference.class);
|
mSwitchPreference = spy(SwitchPreference.class);
|
||||||
when(mContext.getSystemService(Context.TETHERING_SERVICE)).thenReturn(mTetheringManager);
|
when(mContext.getSystemService(TetheringManager.class)).thenReturn(mTetheringManager);
|
||||||
when(mTetheringManager.getTetherableBluetoothRegexs()).thenReturn(new String[] {""});
|
when(mTetheringManager.getTetherableBluetoothRegexs()).thenReturn(new String[] {""});
|
||||||
mController = new BluetoothTetherPreferenceController(mContext, "BLUETOOTH");
|
mController = new BluetoothTetherPreferenceController(mContext, "BLUETOOTH");
|
||||||
mController.setTetherEnabler(mTetherEnabler);
|
mController.setTetherEnabler(mTetherEnabler);
|
||||||
|
@@ -62,9 +62,9 @@ public class EthernetTetherPreferenceControllerTest {
|
|||||||
public void setUp() {
|
public void setUp() {
|
||||||
mContext = spy(ApplicationProvider.getApplicationContext());
|
mContext = spy(ApplicationProvider.getApplicationContext());
|
||||||
mPreference = spy(SwitchPreference.class);
|
mPreference = spy(SwitchPreference.class);
|
||||||
when(mContext.getSystemService(Context.TETHERING_SERVICE)).thenReturn(mTetheringManager);
|
when(mContext.getSystemService(TetheringManager.class)).thenReturn(mTetheringManager);
|
||||||
when(mTetheringManager.getTetherableIfaces()).thenReturn(new String[]{ETHERNET_REGEX});
|
when(mTetheringManager.getTetherableIfaces()).thenReturn(new String[]{ETHERNET_REGEX});
|
||||||
when(mContext.getSystemService(Context.ETHERNET_SERVICE)).thenReturn(mEthernetManager);
|
when(mContext.getSystemService(EthernetManager.class)).thenReturn(mEthernetManager);
|
||||||
mController = new EthernetTetherPreferenceController(mContext, "ethernet");
|
mController = new EthernetTetherPreferenceController(mContext, "ethernet");
|
||||||
mController.setTetherEnabler(mTetherEnabler);
|
mController.setTetherEnabler(mTetherEnabler);
|
||||||
ReflectionHelpers.setField(mController, "mEthernetRegex", ETHERNET_REGEX);
|
ReflectionHelpers.setField(mController, "mEthernetRegex", ETHERNET_REGEX);
|
||||||
|
@@ -45,14 +45,14 @@ public class NetworkResetRestrictionCheckerTest {
|
|||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
when(mContext.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
|
when(mContext.getSystemService(UserManager.class)).thenReturn(mUserManager);
|
||||||
mRestrictionChecker = spy(new NetworkResetRestrictionChecker(mContext));
|
mRestrictionChecker = spy(new NetworkResetRestrictionChecker(mContext));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHasRestriction_notAdmin_shouldReturnTrue() {
|
public void testHasRestriction_notAdmin_shouldReturnTrue() {
|
||||||
final Context context = mock(Context.class);
|
final Context context = mock(Context.class);
|
||||||
when(context.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
|
when(context.getSystemService(UserManager.class)).thenReturn(mUserManager);
|
||||||
when(mUserManager.isAdminUser()).thenReturn(false);
|
when(mUserManager.isAdminUser()).thenReturn(false);
|
||||||
|
|
||||||
assertThat(mRestrictionChecker.hasRestriction()).isTrue();
|
assertThat(mRestrictionChecker.hasRestriction()).isTrue();
|
||||||
|
@@ -125,7 +125,7 @@ public class PrivateDnsPreferenceControllerTest {
|
|||||||
mContext = spy(RuntimeEnvironment.application);
|
mContext = spy(RuntimeEnvironment.application);
|
||||||
mContentResolver = mContext.getContentResolver();
|
mContentResolver = mContext.getContentResolver();
|
||||||
mShadowContentResolver = Shadow.extract(mContentResolver);
|
mShadowContentResolver = Shadow.extract(mContentResolver);
|
||||||
when(mContext.getSystemService(Context.CONNECTIVITY_SERVICE))
|
when(mContext.getSystemService(ConnectivityManager.class))
|
||||||
.thenReturn(mConnectivityManager);
|
.thenReturn(mConnectivityManager);
|
||||||
doNothing().when(mConnectivityManager).registerDefaultNetworkCallback(
|
doNothing().when(mConnectivityManager).registerDefaultNetworkCallback(
|
||||||
mCallbackCaptor.capture(), nullable(Handler.class));
|
mCallbackCaptor.capture(), nullable(Handler.class));
|
||||||
|
@@ -95,10 +95,10 @@ public class TetherEnablerTest {
|
|||||||
AtomicReference<BluetoothPan> panReference = spy(AtomicReference.class);
|
AtomicReference<BluetoothPan> panReference = spy(AtomicReference.class);
|
||||||
mSwitchBar = spy(new SwitchBar(context));
|
mSwitchBar = spy(new SwitchBar(context));
|
||||||
mSwitchWidgetController = spy(new SwitchBarController(mSwitchBar));
|
mSwitchWidgetController = spy(new SwitchBarController(mSwitchBar));
|
||||||
when(context.getSystemService(Context.WIFI_SERVICE)).thenReturn(mWifiManager);
|
when(context.getSystemService(WifiManager.class)).thenReturn(mWifiManager);
|
||||||
when(context.getSystemService(Context.CONNECTIVITY_SERVICE)).thenReturn(
|
when(context.getSystemService(ConnectivityManager.class)).thenReturn(
|
||||||
mConnectivityManager);
|
mConnectivityManager);
|
||||||
when(context.getSystemService(Context.TETHERING_SERVICE)).thenReturn(mTetheringManager);
|
when(context.getSystemService(TetheringManager.class)).thenReturn(mTetheringManager);
|
||||||
when(context.getSystemService(Context.NETWORK_POLICY_SERVICE)).thenReturn(
|
when(context.getSystemService(Context.NETWORK_POLICY_SERVICE)).thenReturn(
|
||||||
mNetworkPolicyManager);
|
mNetworkPolicyManager);
|
||||||
when(mTetheringManager.getTetherableIfaces()).thenReturn(new String[0]);
|
when(mTetheringManager.getTetherableIfaces()).thenReturn(new String[0]);
|
||||||
|
@@ -55,7 +55,7 @@ public class UsbTetherPreferenceControllerTest {
|
|||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
|
|
||||||
mContext = spy(ApplicationProvider.getApplicationContext());
|
mContext = spy(ApplicationProvider.getApplicationContext());
|
||||||
when(mContext.getSystemService(Context.TETHERING_SERVICE)).thenReturn(mTetheringManager);
|
when(mContext.getSystemService(TetheringManager.class)).thenReturn(mTetheringManager);
|
||||||
when(mTetheringManager.getTetherableUsbRegexs()).thenReturn(new String[]{""});
|
when(mTetheringManager.getTetherableUsbRegexs()).thenReturn(new String[]{""});
|
||||||
mController = new UsbTetherPreferenceController(mContext, "USB");
|
mController = new UsbTetherPreferenceController(mContext, "USB");
|
||||||
mController.setTetherEnabler(mTetherEnabler);
|
mController.setTetherEnabler(mTetherEnabler);
|
||||||
|
@@ -100,7 +100,7 @@ public class WifiTetherDisablePreferenceControllerTest {
|
|||||||
|
|
||||||
mContext = spy(ApplicationProvider.getApplicationContext());
|
mContext = spy(ApplicationProvider.getApplicationContext());
|
||||||
mPreference = spy(SwitchPreference.class);
|
mPreference = spy(SwitchPreference.class);
|
||||||
when(mContext.getSystemService(Context.TETHERING_SERVICE)).thenReturn(mTetheringManager);
|
when(mContext.getSystemService(TetheringManager.class)).thenReturn(mTetheringManager);
|
||||||
when(mTetheringManager.getTetherableWifiRegexs()).thenReturn(new String[]{""});
|
when(mTetheringManager.getTetherableWifiRegexs()).thenReturn(new String[]{""});
|
||||||
mController = new WifiTetherDisablePreferenceController(mContext, WIFI_TETHER_DISABLE_KEY);
|
mController = new WifiTetherDisablePreferenceController(mContext, WIFI_TETHER_DISABLE_KEY);
|
||||||
mController.setTetherEnabler(mTetherEnabler);
|
mController.setTetherEnabler(mTetherEnabler);
|
||||||
|
@@ -74,7 +74,7 @@ public class MobileDataSliceTest {
|
|||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
mContext = spy(RuntimeEnvironment.application);
|
mContext = spy(RuntimeEnvironment.application);
|
||||||
|
|
||||||
doReturn(mTelephonyManager).when(mContext).getSystemService(Context.TELEPHONY_SERVICE);
|
doReturn(mTelephonyManager).when(mContext).getSystemService(TelephonyManager.class);
|
||||||
doReturn(mSubscriptionManager).when(mContext).getSystemService(SubscriptionManager.class);
|
doReturn(mSubscriptionManager).when(mContext).getSystemService(SubscriptionManager.class);
|
||||||
doReturn(mTelephonyManager).when(mTelephonyManager).createForSubscriptionId(SUB_ID);
|
doReturn(mTelephonyManager).when(mTelephonyManager).createForSubscriptionId(SUB_ID);
|
||||||
doReturn(mSubscriptionInfo).when(mSubscriptionManager).getActiveSubscriptionInfo(anyInt());
|
doReturn(mSubscriptionInfo).when(mSubscriptionManager).getActiveSubscriptionInfo(anyInt());
|
||||||
|
@@ -77,7 +77,7 @@ public class NetworkSelectSettingsTest {
|
|||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
|
|
||||||
mContext = spy(RuntimeEnvironment.application);
|
mContext = spy(RuntimeEnvironment.application);
|
||||||
when(mContext.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mTelephonyManager);
|
when(mContext.getSystemService(TelephonyManager.class)).thenReturn(mTelephonyManager);
|
||||||
when(mContext.getSystemService(SubscriptionManager.class)).thenReturn(mSubscriptionManager);
|
when(mContext.getSystemService(SubscriptionManager.class)).thenReturn(mSubscriptionManager);
|
||||||
when(mTelephonyManager.createForSubscriptionId(SUB_ID)).thenReturn(mTelephonyManager);
|
when(mTelephonyManager.createForSubscriptionId(SUB_ID)).thenReturn(mTelephonyManager);
|
||||||
|
|
||||||
|
@@ -66,7 +66,7 @@ public class NetworkRequestDialogActivityTest {
|
|||||||
mActivity = spy(activity);
|
mActivity = spy(activity);
|
||||||
|
|
||||||
mWifiManager = mock(WifiManager.class);
|
mWifiManager = mock(WifiManager.class);
|
||||||
when(mActivity.getSystemService(Context.WIFI_SERVICE)).thenReturn(mWifiManager);
|
when(mActivity.getSystemService(WifiManager.class)).thenReturn(mWifiManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@@ -53,7 +53,7 @@ public class WifiEnablerTest {
|
|||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
when(mContext.getSystemService(Context.WIFI_SERVICE)).thenReturn(mWifiManager);
|
when(mContext.getSystemService(WifiManager.class)).thenReturn(mWifiManager);
|
||||||
mEnabler = new WifiEnabler(mContext, mock(SwitchWidgetController.class),
|
mEnabler = new WifiEnabler(mContext, mock(SwitchWidgetController.class),
|
||||||
mock(MetricsFeatureProvider.class), mConnectivityManager);
|
mock(MetricsFeatureProvider.class), mConnectivityManager);
|
||||||
}
|
}
|
||||||
|
@@ -78,7 +78,7 @@ public class WifiMasterSwitchPreferenceControllerTest {
|
|||||||
when(mContext.getSystemService(NetworkScoreManager.class)).thenReturn(mNetworkScoreManager);
|
when(mContext.getSystemService(NetworkScoreManager.class)).thenReturn(mNetworkScoreManager);
|
||||||
mController = new WifiMasterSwitchPreferenceController(mContext, mMetricsFeatureProvider);
|
mController = new WifiMasterSwitchPreferenceController(mContext, mMetricsFeatureProvider);
|
||||||
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
||||||
when(mContext.getSystemService(Context.WIFI_SERVICE)).thenReturn(mWifiManager);
|
when(mContext.getSystemService(WifiManager.class)).thenReturn(mWifiManager);
|
||||||
when(mWifiManager.getWifiState()).thenReturn(WifiManager.WIFI_STATE_DISABLED);
|
when(mWifiManager.getWifiState()).thenReturn(WifiManager.WIFI_STATE_DISABLED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -209,7 +209,7 @@ public class WifiSettings2Test {
|
|||||||
final Resources.Theme theme = mContext.getTheme();
|
final Resources.Theme theme = mContext.getTheme();
|
||||||
when(activity.getTheme()).thenReturn(theme);
|
when(activity.getTheme()).thenReturn(theme);
|
||||||
UserManager userManager = mock(UserManager.class);
|
UserManager userManager = mock(UserManager.class);
|
||||||
when(activity.getSystemService(Context.USER_SERVICE))
|
when(activity.getSystemService(UserManager.class))
|
||||||
.thenReturn(userManager);
|
.thenReturn(userManager);
|
||||||
|
|
||||||
when(mWifiSettings2.findPreference(WifiSettings2.PREF_KEY_DATA_USAGE))
|
when(mWifiSettings2.findPreference(WifiSettings2.PREF_KEY_DATA_USAGE))
|
||||||
|
@@ -77,7 +77,7 @@ public class DisclaimerItemListAdapterTest {
|
|||||||
|
|
||||||
when(mLayoutInflater.inflate(anyInt(), anyObject(), anyBoolean())).thenReturn(mView);
|
when(mLayoutInflater.inflate(anyInt(), anyObject(), anyBoolean())).thenReturn(mView);
|
||||||
when(mViewGroup.getContext()).thenReturn(mContext);
|
when(mViewGroup.getContext()).thenReturn(mContext);
|
||||||
when(mViewGroup.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE)).thenReturn(
|
when(mViewGroup.getContext().getSystemService(LayoutInflater.class)).thenReturn(
|
||||||
mLayoutInflater);
|
mLayoutInflater);
|
||||||
when(mView.findViewById(ID_DISCLAIMER_ITEM_TITLE)).thenReturn(mTestView);
|
when(mView.findViewById(ID_DISCLAIMER_ITEM_TITLE)).thenReturn(mTestView);
|
||||||
when(mView.findViewById(ID_DISCLAIMER_ITEM_DESCRIPTION)).thenReturn(mDescView);
|
when(mView.findViewById(ID_DISCLAIMER_ITEM_DESCRIPTION)).thenReturn(mDescView);
|
||||||
|
@@ -54,7 +54,7 @@ public class EmergencyCallLimitationDisclaimerTest {
|
|||||||
mContext = spy(RuntimeEnvironment.application);
|
mContext = spy(RuntimeEnvironment.application);
|
||||||
|
|
||||||
doReturn(mCarrierConfigManager).when(mContext).getSystemService(
|
doReturn(mCarrierConfigManager).when(mContext).getSystemService(
|
||||||
Context.CARRIER_CONFIG_SERVICE);
|
CarrierConfigManager.class);
|
||||||
when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(mBundle);
|
when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(mBundle);
|
||||||
|
|
||||||
doReturn(getSharedPreferences()).when(mContext).getSharedPreferences(anyString(), anyInt());
|
doReturn(getSharedPreferences()).when(mContext).getSharedPreferences(anyString(), anyInt());
|
||||||
|
@@ -54,7 +54,7 @@ public class LocationPolicyDisclaimerTest {
|
|||||||
mContext = spy(RuntimeEnvironment.application);
|
mContext = spy(RuntimeEnvironment.application);
|
||||||
|
|
||||||
doReturn(mCarrierConfigManager).when(mContext).getSystemService(
|
doReturn(mCarrierConfigManager).when(mContext).getSystemService(
|
||||||
Context.CARRIER_CONFIG_SERVICE);
|
CarrierConfigManager.class);
|
||||||
when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(mBundle);
|
when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(mBundle);
|
||||||
doReturn(getSharedPreferences()).when(mContext).getSharedPreferences(anyString(), anyInt());
|
doReturn(getSharedPreferences()).when(mContext).getSharedPreferences(anyString(), anyInt());
|
||||||
}
|
}
|
||||||
|
@@ -73,8 +73,8 @@ public class WifiTetherApBandPreferenceControllerTest {
|
|||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
mContext = spy(RuntimeEnvironment.application);
|
mContext = spy(RuntimeEnvironment.application);
|
||||||
mPreference = new ListPreference(RuntimeEnvironment.application);
|
mPreference = new ListPreference(RuntimeEnvironment.application);
|
||||||
when(mContext.getSystemService(Context.WIFI_SERVICE)).thenReturn(mWifiManager);
|
when(mContext.getSystemService(WifiManager.class)).thenReturn(mWifiManager);
|
||||||
when(mContext.getSystemService(Context.TETHERING_SERVICE)).thenReturn(mTetheringManager);
|
when(mContext.getSystemService(TetheringManager.class)).thenReturn(mTetheringManager);
|
||||||
when(mTetheringManager.getTetherableWifiRegexs()).thenReturn(new String[]{"1", "2"});
|
when(mTetheringManager.getTetherableWifiRegexs()).thenReturn(new String[]{"1", "2"});
|
||||||
when(mContext.getResources()).thenReturn(RuntimeEnvironment.application.getResources());
|
when(mContext.getResources()).thenReturn(RuntimeEnvironment.application.getResources());
|
||||||
when(mScreen.findPreference(anyString())).thenReturn(mPreference);
|
when(mScreen.findPreference(anyString())).thenReturn(mPreference);
|
||||||
|
@@ -79,10 +79,10 @@ public class WifiTetherSettingsTest {
|
|||||||
|
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
doReturn(mConnectivityManager)
|
doReturn(mConnectivityManager)
|
||||||
.when(mContext).getSystemService(Context.CONNECTIVITY_SERVICE);
|
.when(mContext).getSystemService(ConnectivityManager.class);
|
||||||
doReturn(mTetheringManager).when(mContext).getSystemService(Context.TETHERING_SERVICE);
|
doReturn(mTetheringManager).when(mContext).getSystemService(TetheringManager.class);
|
||||||
doReturn(WIFI_REGEXS).when(mTetheringManager).getTetherableWifiRegexs();
|
doReturn(WIFI_REGEXS).when(mTetheringManager).getTetherableWifiRegexs();
|
||||||
doReturn(mUserManager).when(mContext).getSystemService(Context.USER_SERVICE);
|
doReturn(mUserManager).when(mContext).getSystemService(UserManager.class);
|
||||||
|
|
||||||
mWifiTetherSettings = new WifiTetherSettings();
|
mWifiTetherSettings = new WifiTetherSettings();
|
||||||
}
|
}
|
||||||
@@ -131,7 +131,7 @@ public class WifiTetherSettingsTest {
|
|||||||
when(settings.getContext()).thenReturn(mContext);
|
when(settings.getContext()).thenReturn(mContext);
|
||||||
final Resources.Theme theme = mContext.getTheme();
|
final Resources.Theme theme = mContext.getTheme();
|
||||||
when(activity.getTheme()).thenReturn(theme);
|
when(activity.getTheme()).thenReturn(theme);
|
||||||
when(activity.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
|
when(activity.getSystemService(UserManager.class)).thenReturn(mUserManager);
|
||||||
doNothing().when(settings)
|
doNothing().when(settings)
|
||||||
.onCreatePreferences(any(Bundle.class), nullable(String.class));
|
.onCreatePreferences(any(Bundle.class), nullable(String.class));
|
||||||
final FakeFeatureFactory fakeFeatureFactory = FakeFeatureFactory.setupForTest();
|
final FakeFeatureFactory fakeFeatureFactory = FakeFeatureFactory.setupForTest();
|
||||||
|
@@ -94,7 +94,7 @@ public class EnabledNetworkModePreferenceControllerTest {
|
|||||||
|
|
||||||
when(mContext.getSystemService(CarrierConfigManager.class)).thenReturn(
|
when(mContext.getSystemService(CarrierConfigManager.class)).thenReturn(
|
||||||
mCarrierConfigManager);
|
mCarrierConfigManager);
|
||||||
when(mContext.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mTelephonyManager);
|
when(mContext.getSystemService(TelephonyManager.class)).thenReturn(mTelephonyManager);
|
||||||
when(mContext.getSystemService(TelephonyManager.class)).thenReturn(mTelephonyManager);
|
when(mContext.getSystemService(TelephonyManager.class)).thenReturn(mTelephonyManager);
|
||||||
doReturn(mTelephonyManager).when(mTelephonyManager).createForSubscriptionId(SUB_ID);
|
doReturn(mTelephonyManager).when(mTelephonyManager).createForSubscriptionId(SUB_ID);
|
||||||
doReturn(mInvalidTelephonyManager).when(mTelephonyManager).createForSubscriptionId(
|
doReturn(mInvalidTelephonyManager).when(mTelephonyManager).createForSubscriptionId(
|
||||||
|
@@ -73,7 +73,7 @@ public class MobileDataPreferenceControllerTest {
|
|||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
|
|
||||||
mContext = spy(ApplicationProvider.getApplicationContext());
|
mContext = spy(ApplicationProvider.getApplicationContext());
|
||||||
doReturn(mTelephonyManager).when(mContext).getSystemService(Context.TELEPHONY_SERVICE);
|
doReturn(mTelephonyManager).when(mContext).getSystemService(TelephonyManager.class);
|
||||||
|
|
||||||
when(mContext.getSystemService(SubscriptionManager.class)).thenReturn(mSubscriptionManager);
|
when(mContext.getSystemService(SubscriptionManager.class)).thenReturn(mSubscriptionManager);
|
||||||
doReturn(mTelephonyManager).when(mTelephonyManager).createForSubscriptionId(SUB_ID);
|
doReturn(mTelephonyManager).when(mTelephonyManager).createForSubscriptionId(SUB_ID);
|
||||||
|
Reference in New Issue
Block a user