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

@@ -181,8 +181,8 @@ public class ImeiInfoPreferenceControllerTest {
mController.copy();
final ClipboardManager clipboard = mContext.getSystemService(
ClipboardManager.class);
final ClipboardManager clipboard = (ClipboardManager) mContext.getSystemService(
CLIPBOARD_SERVICE);
final CharSequence data = clipboard.getPrimaryClip().getItemAt(0).getText();
assertThat(data.toString()).isEqualTo(meid);
}

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);

View File

@@ -78,7 +78,7 @@ public class NetworkRequestDialogActivityTest {
mActivity = spy(activity);
mWifiManager = mock(WifiManager.class);
when(mActivity.getSystemService(WifiManager.class)).thenReturn(mWifiManager);
when(mActivity.getSystemService(Context.WIFI_SERVICE)).thenReturn(mWifiManager);
}
@Test

View File

@@ -53,7 +53,7 @@ public class WifiEnablerTest {
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
when(mContext.getSystemService(WifiManager.class)).thenReturn(mWifiManager);
when(mContext.getSystemService(Context.WIFI_SERVICE)).thenReturn(mWifiManager);
mEnabler = new WifiEnabler(mContext, mock(SwitchWidgetController.class),
mock(MetricsFeatureProvider.class), mConnectivityManager);
}

View File

@@ -78,7 +78,7 @@ public class WifiPrimarySwitchPreferenceControllerTest {
when(mContext.getSystemService(NetworkScoreManager.class)).thenReturn(mNetworkScoreManager);
mController = new WifiPrimarySwitchPreferenceController(mContext, mMetricsFeatureProvider);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
when(mContext.getSystemService(WifiManager.class)).thenReturn(mWifiManager);
when(mContext.getSystemService(Context.WIFI_SERVICE)).thenReturn(mWifiManager);
when(mWifiManager.getWifiState()).thenReturn(WifiManager.WIFI_STATE_DISABLED);
}

View File

@@ -77,7 +77,7 @@ public class DisclaimerItemListAdapterTest {
when(mLayoutInflater.inflate(anyInt(), anyObject(), anyBoolean())).thenReturn(mView);
when(mViewGroup.getContext()).thenReturn(mContext);
when(mViewGroup.getContext().getSystemService(LayoutInflater.class)).thenReturn(
when(mViewGroup.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE)).thenReturn(
mLayoutInflater);
when(mView.findViewById(ID_DISCLAIMER_ITEM_TITLE)).thenReturn(mTestView);
when(mView.findViewById(ID_DISCLAIMER_ITEM_DESCRIPTION)).thenReturn(mDescView);

View File

@@ -54,7 +54,7 @@ public class EmergencyCallLimitationDisclaimerTest {
mContext = spy(RuntimeEnvironment.application);
doReturn(mCarrierConfigManager).when(mContext).getSystemService(
CarrierConfigManager.class);
Context.CARRIER_CONFIG_SERVICE);
when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(mBundle);
doReturn(getSharedPreferences()).when(mContext).getSharedPreferences(anyString(), anyInt());

View File

@@ -54,7 +54,7 @@ public class LocationPolicyDisclaimerTest {
mContext = spy(RuntimeEnvironment.application);
doReturn(mCarrierConfigManager).when(mContext).getSystemService(
CarrierConfigManager.class);
Context.CARRIER_CONFIG_SERVICE);
when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(mBundle);
doReturn(getSharedPreferences()).when(mContext).getSharedPreferences(anyString(), anyInt());
}

View File

@@ -73,8 +73,8 @@ public class WifiTetherApBandPreferenceControllerTest {
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
mPreference = new ListPreference(RuntimeEnvironment.application);
when(mContext.getSystemService(WifiManager.class)).thenReturn(mWifiManager);
when(mContext.getSystemService(TetheringManager.class)).thenReturn(mTetheringManager);
when(mContext.getSystemService(Context.WIFI_SERVICE)).thenReturn(mWifiManager);
when(mContext.getSystemService(Context.TETHERING_SERVICE)).thenReturn(mTetheringManager);
when(mTetheringManager.getTetherableWifiRegexs()).thenReturn(new String[]{"1", "2"});
when(mContext.getResources()).thenReturn(RuntimeEnvironment.application.getResources());
when(mScreen.findPreference(anyString())).thenReturn(mPreference);

View File

@@ -80,8 +80,8 @@ public class WifiTetherSettingsTest {
MockitoAnnotations.initMocks(this);
doReturn(mConnectivityManager)
.when(mContext).getSystemService(ConnectivityManager.class);
doReturn(mTetheringManager).when(mContext).getSystemService(TetheringManager.class);
.when(mContext).getSystemService(Context.CONNECTIVITY_SERVICE);
doReturn(mTetheringManager).when(mContext).getSystemService(Context.TETHERING_SERVICE);
doReturn(WIFI_REGEXS).when(mTetheringManager).getTetherableWifiRegexs();
doReturn(mUserManager).when(mContext).getSystemService(Context.USER_SERVICE);