Merge "Revert "[Settings] Support getSystemService(Class<T>)"" into sc-dev

This commit is contained in:
Bonian Chen
2021-03-30 05:31:52 +00:00
committed by Android (Google) Code Review
62 changed files with 100 additions and 100 deletions

View File

@@ -57,7 +57,7 @@ public class BluetoothTetherPreferenceControllerTest {
mContext = spy(ApplicationProvider.getApplicationContext());
mSwitchPreference = spy(SwitchPreference.class);
when(mContext.getSystemService(TetheringManager.class)).thenReturn(mTetheringManager);
when(mContext.getSystemService(Context.TETHERING_SERVICE)).thenReturn(mTetheringManager);
when(mTetheringManager.getTetherableBluetoothRegexs()).thenReturn(new String[] {""});
mController = new BluetoothTetherPreferenceController(mContext, "BLUETOOTH");
mController.setTetherEnabler(mTetherEnabler);

View File

@@ -62,9 +62,9 @@ public class EthernetTetherPreferenceControllerTest {
public void setUp() {
mContext = spy(ApplicationProvider.getApplicationContext());
mPreference = spy(SwitchPreference.class);
when(mContext.getSystemService(TetheringManager.class)).thenReturn(mTetheringManager);
when(mContext.getSystemService(Context.TETHERING_SERVICE)).thenReturn(mTetheringManager);
when(mTetheringManager.getTetherableIfaces()).thenReturn(new String[]{ETHERNET_REGEX});
when(mContext.getSystemService(EthernetManager.class)).thenReturn(mEthernetManager);
when(mContext.getSystemService(Context.ETHERNET_SERVICE)).thenReturn(mEthernetManager);
mController = new EthernetTetherPreferenceController(mContext, "ethernet");
mController.setTetherEnabler(mTetherEnabler);
ReflectionHelpers.setField(mController, "mEthernetRegex", ETHERNET_REGEX);

View File

@@ -45,14 +45,14 @@ public class NetworkResetRestrictionCheckerTest {
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
when(mContext.getSystemService(UserManager.class)).thenReturn(mUserManager);
when(mContext.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
mRestrictionChecker = spy(new NetworkResetRestrictionChecker(mContext));
}
@Test
public void testHasRestriction_notAdmin_shouldReturnTrue() {
final Context context = mock(Context.class);
when(context.getSystemService(UserManager.class)).thenReturn(mUserManager);
when(context.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
when(mUserManager.isAdminUser()).thenReturn(false);
assertThat(mRestrictionChecker.hasRestriction()).isTrue();

View File

@@ -125,7 +125,7 @@ public class PrivateDnsPreferenceControllerTest {
mContext = spy(RuntimeEnvironment.application);
mContentResolver = mContext.getContentResolver();
mShadowContentResolver = Shadow.extract(mContentResolver);
when(mContext.getSystemService(ConnectivityManager.class))
when(mContext.getSystemService(Context.CONNECTIVITY_SERVICE))
.thenReturn(mConnectivityManager);
doNothing().when(mConnectivityManager).registerDefaultNetworkCallback(
mCallbackCaptor.capture(), nullable(Handler.class));

View File

@@ -95,10 +95,10 @@ public class TetherEnablerTest {
AtomicReference<BluetoothPan> panReference = spy(AtomicReference.class);
mSwitchBar = spy(new SwitchBar(context));
mSwitchWidgetController = spy(new SwitchBarController(mSwitchBar));
when(context.getSystemService(WifiManager.class)).thenReturn(mWifiManager);
when(context.getSystemService(ConnectivityManager.class)).thenReturn(
when(context.getSystemService(Context.WIFI_SERVICE)).thenReturn(mWifiManager);
when(context.getSystemService(Context.CONNECTIVITY_SERVICE)).thenReturn(
mConnectivityManager);
when(context.getSystemService(TetheringManager.class)).thenReturn(mTetheringManager);
when(context.getSystemService(Context.TETHERING_SERVICE)).thenReturn(mTetheringManager);
when(context.getSystemService(Context.NETWORK_POLICY_SERVICE)).thenReturn(
mNetworkPolicyManager);
when(mTetheringManager.getTetherableIfaces()).thenReturn(new String[0]);
@@ -311,4 +311,4 @@ public class TetherEnablerTest {
assertThat(TetherEnabler.isTethering(TETHERING_ETHERNET_ON, TETHERING_ETHERNET)).isTrue();
assertThat(TetherEnabler.isTethering(~TETHERING_ETHERNET_ON, TETHERING_ETHERNET)).isFalse();
}
}
}

View File

@@ -55,7 +55,7 @@ public class UsbTetherPreferenceControllerTest {
MockitoAnnotations.initMocks(this);
mContext = spy(ApplicationProvider.getApplicationContext());
when(mContext.getSystemService(TetheringManager.class)).thenReturn(mTetheringManager);
when(mContext.getSystemService(Context.TETHERING_SERVICE)).thenReturn(mTetheringManager);
when(mTetheringManager.getTetherableUsbRegexs()).thenReturn(new String[]{""});
mController = new UsbTetherPreferenceController(mContext, "USB");
mController.setTetherEnabler(mTetherEnabler);

View File

@@ -100,7 +100,7 @@ public class WifiTetherDisablePreferenceControllerTest {
mContext = spy(ApplicationProvider.getApplicationContext());
mPreference = spy(SwitchPreference.class);
when(mContext.getSystemService(TetheringManager.class)).thenReturn(mTetheringManager);
when(mContext.getSystemService(Context.TETHERING_SERVICE)).thenReturn(mTetheringManager);
when(mTetheringManager.getTetherableWifiRegexs()).thenReturn(new String[]{""});
mController = new WifiTetherDisablePreferenceController(mContext, WIFI_TETHER_DISABLE_KEY);
mController.setTetherEnabler(mTetherEnabler);

View File

@@ -74,7 +74,7 @@ public class MobileDataSliceTest {
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
doReturn(mTelephonyManager).when(mContext).getSystemService(TelephonyManager.class);
doReturn(mTelephonyManager).when(mContext).getSystemService(Context.TELEPHONY_SERVICE);
doReturn(mSubscriptionManager).when(mContext).getSystemService(SubscriptionManager.class);
doReturn(mTelephonyManager).when(mTelephonyManager).createForSubscriptionId(SUB_ID);
doReturn(mSubscriptionInfo).when(mSubscriptionManager).getActiveSubscriptionInfo(anyInt());

View File

@@ -77,7 +77,7 @@ public class NetworkSelectSettingsTest {
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
when(mContext.getSystemService(TelephonyManager.class)).thenReturn(mTelephonyManager);
when(mContext.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mTelephonyManager);
when(mContext.getSystemService(SubscriptionManager.class)).thenReturn(mSubscriptionManager);
when(mTelephonyManager.createForSubscriptionId(SUB_ID)).thenReturn(mTelephonyManager);