Merge "Mainline:SimStatusDialogController decouple TelephonyManager hidden APIs" am: 6bba42fb40 am: 27c52d5e76

Change-Id: I12080d93b39b990083f3ac795b7e4ae42ffcbe8d
This commit is contained in:
Automerger Merge Worker
2019-12-24 09:14:23 +00:00
2 changed files with 76 additions and 38 deletions

View File

@@ -134,7 +134,6 @@ public class SimStatusDialogControllerTest {
mLifecycle = new Lifecycle(mLifecycleOwner);
mController = spy(new SimStatusDialogController(mDialog, mLifecycle, 0 /* phone id */));
ShadowDeviceInfoUtils.setPhoneNumber("");
doReturn(mServiceState).when(mController).getCurrentServiceState();
//CellSignalStrength setup
doReturn(0).when(mCellSignalStrengthCdma).getDbm();
doReturn(0).when(mCellSignalStrengthCdma).getAsuLevel();
@@ -145,7 +144,6 @@ public class SimStatusDialogControllerTest {
doReturn(null).when(mSignalStrength).getCellSignalStrengths();
doReturn(mPhoneStateListener).when(mController).getPhoneStateListener();
doReturn(mSignalStrength).when(mController).getSignalStrength();
doReturn(mSubscriptionInfo).when(mSubscriptionManager).getActiveSubscriptionInfo(anyInt());
ReflectionHelpers.setField(mController, "mTelephonyManager", mTelephonyManager);
@@ -168,6 +166,9 @@ public class SimStatusDialogControllerTest {
when(mPersistableBundle.getBoolean(
CarrierConfigManager.KEY_SHOW_SIGNAL_STRENGTH_IN_SIM_STATUS_BOOL))
.thenReturn(true);
when(mTelephonyManager.createForSubscriptionId(anyInt())).thenReturn(mTelephonyManager);
doReturn(mServiceState).when(mTelephonyManager).getServiceState();
doReturn(mSignalStrength).when(mTelephonyManager).getSignalStrength();
final ShadowPackageManager shadowPackageManager =
Shadows.shadowOf(RuntimeEnvironment.application.getPackageManager());
@@ -330,25 +331,25 @@ public class SimStatusDialogControllerTest {
@Test
@Ignore
public void initialize_updateVoiceNetworkTypeWithEdge_shouldUpdateSettingToEdge() {
when(mTelephonyManager.getVoiceNetworkType(anyInt())).thenReturn(
when(mTelephonyManager.getVoiceNetworkType()).thenReturn(
TelephonyManager.NETWORK_TYPE_EDGE);
mController.initialize();
verify(mDialog).setText(CELL_VOICE_NETWORK_TYPE_VALUE_ID,
TelephonyManager.getNetworkTypeName(TelephonyManager.NETWORK_TYPE_EDGE));
SimStatusDialogController.getNetworkTypeName(TelephonyManager.NETWORK_TYPE_EDGE));
}
@Test
@Ignore
public void initialize_updateDataNetworkTypeWithEdge_shouldUpdateSettingToEdge() {
when(mTelephonyManager.getDataNetworkType(anyInt())).thenReturn(
when(mTelephonyManager.getDataNetworkType()).thenReturn(
TelephonyManager.NETWORK_TYPE_EDGE);
mController.initialize();
verify(mDialog).setText(CELL_DATA_NETWORK_TYPE_VALUE_ID,
TelephonyManager.getNetworkTypeName(TelephonyManager.NETWORK_TYPE_EDGE));
SimStatusDialogController.getNetworkTypeName(TelephonyManager.NETWORK_TYPE_EDGE));
}
@Test
@@ -417,7 +418,7 @@ public class SimStatusDialogControllerTest {
final String iccid = "12351351231241";
when(mPersistableBundle.getBoolean(
CarrierConfigManager.KEY_SHOW_ICCID_IN_SIM_STATUS_BOOL)).thenReturn(true);
doReturn(iccid).when(mController).getSimSerialNumber(anyInt());
doReturn(iccid).when(mTelephonyManager).getSimSerialNumber();
mController.initialize();
@@ -757,7 +758,7 @@ public class SimStatusDialogControllerTest {
@Test
@Ignore
public void initialize_nullSignalStrength_noCrash() {
doReturn(null).when(mController).getSignalStrength();
doReturn(null).when(mTelephonyManager).getSignalStrength();
// we should not crash when running the following line
mController.initialize();
}