[Settings] Support getSystemService(Class<T>)

Add getSystemService(Class<T>) to align the capability with framework
part.

This is a back port from aosp/1639943, aosp/1645152 and aosp/1648047

Bug: 179640862
Test: local
Change-Id: I035db55a71f94000ca35f8d71f03c19208423c73
This commit is contained in:
Bonian Chen
2021-03-24 00:59:46 +08:00
parent d8c9a53931
commit d5ccde31a8
63 changed files with 103 additions and 103 deletions

View File

@@ -255,7 +255,7 @@ public class TetherService extends Service {
}
private void disableTethering(final int tetheringType) {
final TetheringManager tm = (TetheringManager) getSystemService(Context.TETHERING_SERVICE);
final TetheringManager tm = getSystemService(TetheringManager.class);
tm.stopTethering(tetheringType);
}

View File

@@ -45,8 +45,8 @@ public abstract class WifiTetherBasePreferenceController extends AbstractPrefere
OnTetherConfigUpdateListener listener) {
super(context);
mListener = listener;
mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
mTm = (TetheringManager) context.getSystemService(Context.TETHERING_SERVICE);
mWifiManager = context.getSystemService(WifiManager.class);
mTm = context.getSystemService(TetheringManager.class);
mWifiRegexs = mTm.getTetherableWifiRegexs();
}

View File

@@ -63,7 +63,7 @@ public class WifiTetherPreferenceController extends AbstractPreferenceController
boolean initSoftApManager) {
super(context);
mTetheringManager = context.getSystemService(TetheringManager.class);
mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
mWifiManager = context.getSystemService(WifiManager.class);
mWifiRegexs = mTetheringManager.getTetherableWifiRegexs();
mLifecycle = lifecycle;
if (lifecycle != null) {

View File

@@ -110,7 +110,7 @@ public class WifiTetherSettings extends RestrictedDashboardFragment
@Override
public void onAttach(Context context) {
super.onAttach(context);
mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
mWifiManager = context.getSystemService(WifiManager.class);
mTetherChangeReceiver = new TetherChangeReceiver();
mSSIDPreferenceController = use(WifiTetherSSIDPreferenceController.class);

View File

@@ -73,8 +73,8 @@ public class WifiTetherSwitchBarController implements
mSwitch = mSwitchBar.getSwitch();
mDataSaverBackend = new DataSaverBackend(context);
mConnectivityManager =
(ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
context.getSystemService(ConnectivityManager.class);
mWifiManager = context.getSystemService(WifiManager.class);
mSwitchBar.setChecked(mWifiManager.getWifiApState() == WifiManager.WIFI_AP_STATE_ENABLED);
updateWifiSwitch();
}