[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:
Bonian Chen
2021-03-20 04:46:39 +08:00
parent 3e737c11db
commit db6c47756d
64 changed files with 103 additions and 103 deletions

View File

@@ -1285,8 +1285,8 @@ public class ApnEditor extends SettingsPreferenceFragment
mReadOnlyApnTypes = null;
mReadOnlyApnFields = null;
final CarrierConfigManager configManager = (CarrierConfigManager)
getSystemService(Context.CARRIER_CONFIG_SERVICE);
final CarrierConfigManager configManager =
getSystemService(CarrierConfigManager.class);
if (configManager != null) {
final PersistableBundle b = configManager.getConfigForSubId(mSubId);
if (b != null) {

View File

@@ -206,8 +206,8 @@ public class ApnSettings extends RestrictedSettingsFragment
mSubscriptionInfo = getSubscriptionInfo(mSubId);
mTelephonyManager = activity.getSystemService(TelephonyManager.class);
final CarrierConfigManager configManager = (CarrierConfigManager)
getSystemService(Context.CARRIER_CONFIG_SERVICE);
final CarrierConfigManager configManager =
getSystemService(CarrierConfigManager.class);
final PersistableBundle b = configManager.getConfigForSubId(mSubId);
mHideImsApn = b.getBoolean(CarrierConfigManager.KEY_HIDE_IMS_APN_BOOL);
mAllowAddingApns = b.getBoolean(CarrierConfigManager.KEY_ALLOW_ADDING_APNS_BOOL);

View File

@@ -43,7 +43,7 @@ public final class EthernetTetherPreferenceController extends TetherBasePreferen
super(context, preferenceKey);
mEthernetRegex = context.getString(
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)

View File

@@ -73,9 +73,9 @@ public class MobilePlanPreferenceController extends AbstractPreferenceController
MobilePlanPreferenceHost host) {
super(context);
mHost = host;
mCm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
mTm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
mCm = context.getSystemService(ConnectivityManager.class);
mTm = context.getSystemService(TelephonyManager.class);
mUserManager = context.getSystemService(UserManager.class);
mIsSecondaryUser = !mUserManager.isAdminUser();
}

View File

@@ -31,7 +31,7 @@ public class NetworkResetRestrictionChecker {
public NetworkResetRestrictionChecker(Context context) {
mContext = context;
mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
mUserManager = context.getSystemService(UserManager.class);
}
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)

View File

@@ -140,6 +140,6 @@ public class NetworkScorerPicker extends InstrumentedPreferenceFragment implemen
@VisibleForTesting
NetworkScoreManager createNetworkScorerManager(Context context) {
return (NetworkScoreManager) context.getSystemService(Context.NETWORK_SCORE_SERVICE);
return context.getSystemService(NetworkScoreManager.class);
}
}

View File

@@ -37,7 +37,7 @@ public class NetworkScorerPickerPreferenceController extends BasePreferenceContr
public NetworkScorerPickerPreferenceController(Context context, String key) {
super(context, key);
mNetworkScoreManager =
(NetworkScoreManager) mContext.getSystemService(Context.NETWORK_SCORE_SERVICE);
mContext.getSystemService(NetworkScoreManager.class);
}
@Override

View File

@@ -128,10 +128,10 @@ public class TetherEnabler implements SwitchWidgetController.OnSwitchChangeListe
mSwitchWidgetController = switchWidgetController;
mDataSaverBackend = new DataSaverBackend(context);
mConnectivityManager =
(ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
mTetheringManager = (TetheringManager) context.getSystemService(Context.TETHERING_SERVICE);
mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
context.getSystemService(ConnectivityManager.class);
mTetheringManager = context.getSystemService(TetheringManager.class);
mWifiManager = context.getSystemService(WifiManager.class);
mUserManager = context.getSystemService(UserManager.class);
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
mBluetoothPan = bluetoothPan;
mEthernetRegex =

View File

@@ -194,7 +194,7 @@ public class MobileNetworkSettings extends AbstractMobileNetworkSettings {
super.onCreate(icicle);
final Context context = getContext();
mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
mUserManager = context.getSystemService(UserManager.class);
mTelephonyManager = context.getSystemService(TelephonyManager.class)
.createForSubscriptionId(mSubId);

View File

@@ -106,8 +106,8 @@ public class NetworkSelectSettings extends DashboardFragment {
.createForSubscriptionId(mSubId);
mNetworkScanHelper = new NetworkScanHelper(
mTelephonyManager, mCallback, mNetworkScanExecutor);
PersistableBundle bundle = ((CarrierConfigManager) getContext().getSystemService(
Context.CARRIER_CONFIG_SERVICE)).getConfigForSubId(mSubId);
PersistableBundle bundle = (getContext().getSystemService(
CarrierConfigManager.class)).getConfigForSubId(mSubId);
if (bundle != null) {
mShow4GForLTE = bundle.getBoolean(
CarrierConfigManager.KEY_SHOW_4G_FOR_LTE_DATA_ICON_BOOL);

View File

@@ -190,8 +190,8 @@ public class RenameMobileNetworkDialogFragment extends InstrumentedDialogFragmen
@Override
public View getView(int position, View convertView, ViewGroup parent) {
final LayoutInflater inflater = (LayoutInflater)
mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
final LayoutInflater inflater =
mContext.getSystemService(LayoutInflater.class);
if (convertView == null) {
convertView = inflater.inflate(mItemResId, null);