Fix IMEI information can't display without pSIM inserted

When no SIM, we can't get active subscription info.
So current code will not create TelephonyManager and cause IMEI not
retrieved.
Create TelephonyManager with default if no subscription info.

Bug: 132215720
Test: test with SIM and without SIM to check SIM status UI and atest ImeiInfoDialogControllerTest pass
Change-Id: Iaeb932ea66a6bee77136251941cca657984e456f
This commit is contained in:
andychou
2019-05-09 00:00:23 +08:00
parent 6e8c403360
commit 9ac6d81177
2 changed files with 29 additions and 4 deletions

View File

@@ -86,8 +86,8 @@ public class ImeiInfoDialogControllerTest {
mController = spy(new ImeiInfoDialogController(mDialog, SLOT_ID));
doReturn(PRL_VERSION).when(mController).getCdmaPrlVersion();
doReturn(MEID_NUMBER).when(mController).getMeid();
when(mTelephonyManager.getCdmaPrlVersion()).thenReturn(PRL_VERSION);
when(mTelephonyManager.getMeid(anyInt())).thenReturn(MEID_NUMBER);
when(mTelephonyManager.getCdmaMin(anyInt())).thenReturn(MIN_NUMBER);
when(mTelephonyManager.getDeviceSoftwareVersion(anyInt())).thenReturn(IMEI_SV_NUMBER);
when(mTelephonyManager.getImei(anyInt())).thenReturn(IMEI_NUMBER);
@@ -98,6 +98,7 @@ public class ImeiInfoDialogControllerTest {
mController = spy(new ImeiInfoDialogController(mDialog, SLOT_ID + 1));
mController.populateImeiInfo();
verify(mDialog, never()).setText(anyInt(), any());
}
@@ -129,16 +130,30 @@ public class ImeiInfoDialogControllerTest {
}
@Test
public void populateImeiInfo_cdmaSimDisabled_shouldRemoveImeiInfoAndSetMinToEmpty() {
public void populateImeiInfo_cdmaSimDisabled_shouldRemoveImeiInfoAndSetMinPrlToEmpty() {
ReflectionHelpers.setField(mController, "mSubscriptionInfo", null);
when(mTelephonyManager.getPhoneType()).thenReturn(TelephonyManager.PHONE_TYPE_CDMA);
mController.populateImeiInfo();
verify(mDialog).setText(ID_MEID_NUMBER_VALUE, MEID_NUMBER);
verify(mDialog).setText(ID_MIN_NUMBER_VALUE, "");
verify(mDialog).setText(ID_PRL_VERSION_VALUE, "");
verify(mDialog).removeViewFromScreen(ID_GSM_SETTINGS);
}
@Test
public void populateImeiInfo_gsmSimDisabled_shouldSetImeiAndRemoveCdmaSettings() {
ReflectionHelpers.setField(mController, "mSubscriptionInfo", null);
when(mTelephonyManager.getPhoneType()).thenReturn(TelephonyManager.PHONE_TYPE_GSM);
mController.populateImeiInfo();
verify(mDialog).setText(eq(ID_IMEI_VALUE), any());
verify(mDialog).setText(eq(ID_IMEI_SV_VALUE), any());
verify(mDialog).removeViewFromScreen(ID_CDMA_SETTINGS);
}
@Test
public void populateImeinfo_gsm_shouldSetImeiAndRemoveCdmaSettings() {
when(mTelephonyManager.getPhoneType()).thenReturn(TelephonyManager.PHONE_TYPE_GSM);