Revert "[Settings] Support getSystemService(Class<T>)"
This reverts commit d5ccde31a8
.
Reason for revert: failure on test cases
Change-Id: I0a179a6ebb5ef1dec566ce6e8facd5f3b82d7c8a
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
@@ -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);
|
||||
|
@@ -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);
|
||||
|
@@ -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();
|
||||
|
@@ -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));
|
||||
|
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
@@ -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);
|
||||
|
@@ -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);
|
||||
|
@@ -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());
|
||||
|
@@ -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);
|
||||
|
||||
|
@@ -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
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
@@ -209,7 +209,7 @@ public class WifiSettingsTest {
|
||||
final Resources.Theme theme = mContext.getTheme();
|
||||
when(activity.getTheme()).thenReturn(theme);
|
||||
UserManager userManager = mock(UserManager.class);
|
||||
when(activity.getSystemService(UserManager.class))
|
||||
when(activity.getSystemService(Context.USER_SERVICE))
|
||||
.thenReturn(userManager);
|
||||
|
||||
when(mWifiSettings.findPreference(WifiSettings.PREF_KEY_DATA_USAGE))
|
||||
|
@@ -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);
|
||||
|
@@ -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());
|
||||
|
@@ -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());
|
||||
}
|
||||
|
@@ -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);
|
||||
|
@@ -80,10 +80,10 @@ 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(UserManager.class);
|
||||
doReturn(mUserManager).when(mContext).getSystemService(Context.USER_SERVICE);
|
||||
|
||||
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(UserManager.class)).thenReturn(mUserManager);
|
||||
when(activity.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
|
||||
doNothing().when(settings)
|
||||
.onCreatePreferences(any(Bundle.class), nullable(String.class));
|
||||
final FakeFeatureFactory fakeFeatureFactory = FakeFeatureFactory.setupForTest();
|
||||
|
Reference in New Issue
Block a user