[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:
@@ -73,8 +73,8 @@ public class WifiTetherApBandPreferenceControllerTest {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mContext = spy(RuntimeEnvironment.application);
|
||||
mPreference = new ListPreference(RuntimeEnvironment.application);
|
||||
when(mContext.getSystemService(Context.WIFI_SERVICE)).thenReturn(mWifiManager);
|
||||
when(mContext.getSystemService(Context.TETHERING_SERVICE)).thenReturn(mTetheringManager);
|
||||
when(mContext.getSystemService(WifiManager.class)).thenReturn(mWifiManager);
|
||||
when(mContext.getSystemService(TetheringManager.class)).thenReturn(mTetheringManager);
|
||||
when(mTetheringManager.getTetherableWifiRegexs()).thenReturn(new String[]{"1", "2"});
|
||||
when(mContext.getResources()).thenReturn(RuntimeEnvironment.application.getResources());
|
||||
when(mScreen.findPreference(anyString())).thenReturn(mPreference);
|
||||
|
||||
@@ -80,10 +80,10 @@ public class WifiTetherSettingsTest {
|
||||
|
||||
MockitoAnnotations.initMocks(this);
|
||||
doReturn(mConnectivityManager)
|
||||
.when(mContext).getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
doReturn(mTetheringManager).when(mContext).getSystemService(Context.TETHERING_SERVICE);
|
||||
.when(mContext).getSystemService(ConnectivityManager.class);
|
||||
doReturn(mTetheringManager).when(mContext).getSystemService(TetheringManager.class);
|
||||
doReturn(WIFI_REGEXS).when(mTetheringManager).getTetherableWifiRegexs();
|
||||
doReturn(mUserManager).when(mContext).getSystemService(Context.USER_SERVICE);
|
||||
doReturn(mUserManager).when(mContext).getSystemService(UserManager.class);
|
||||
|
||||
mWifiTetherSettings = new WifiTetherSettings();
|
||||
}
|
||||
@@ -133,7 +133,7 @@ public class WifiTetherSettingsTest {
|
||||
when(settings.getContext()).thenReturn(mContext);
|
||||
final Resources.Theme theme = mContext.getTheme();
|
||||
when(activity.getTheme()).thenReturn(theme);
|
||||
when(activity.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
|
||||
when(activity.getSystemService(UserManager.class)).thenReturn(mUserManager);
|
||||
doNothing().when(settings)
|
||||
.onCreatePreferences(any(Bundle.class), nullable(String.class));
|
||||
final FakeFeatureFactory fakeFeatureFactory = FakeFeatureFactory.setupForTest();
|
||||
|
||||
Reference in New Issue
Block a user