Merge "Fix IMEI information can't display without pSIM inserted" into qt-dev
This commit is contained in:
@@ -78,9 +78,12 @@ public class ImeiInfoDialogController {
|
|||||||
final Context context = dialog.getContext();
|
final Context context = dialog.getContext();
|
||||||
mSubscriptionInfo = context.getSystemService(SubscriptionManager.class)
|
mSubscriptionInfo = context.getSystemService(SubscriptionManager.class)
|
||||||
.getActiveSubscriptionInfoForSimSlotIndex(slotId);
|
.getActiveSubscriptionInfoForSimSlotIndex(slotId);
|
||||||
|
TelephonyManager tm = context.getSystemService(TelephonyManager.class);
|
||||||
if (mSubscriptionInfo != null) {
|
if (mSubscriptionInfo != null) {
|
||||||
mTelephonyManager = context.getSystemService(TelephonyManager.class)
|
mTelephonyManager = context.getSystemService(TelephonyManager.class)
|
||||||
.createForSubscriptionId(mSubscriptionInfo.getSubscriptionId());
|
.createForSubscriptionId(mSubscriptionInfo.getSubscriptionId());
|
||||||
|
} else if(isValidSlotIndex(slotId, tm)) {
|
||||||
|
mTelephonyManager = tm;
|
||||||
} else {
|
} else {
|
||||||
mTelephonyManager = null;
|
mTelephonyManager = null;
|
||||||
}
|
}
|
||||||
@@ -104,6 +107,7 @@ public class ImeiInfoDialogController {
|
|||||||
private void updateDialogForCdmaPhone() {
|
private void updateDialogForCdmaPhone() {
|
||||||
final Resources res = mDialog.getContext().getResources();
|
final Resources res = mDialog.getContext().getResources();
|
||||||
mDialog.setText(ID_MEID_NUMBER_VALUE, getMeid());
|
mDialog.setText(ID_MEID_NUMBER_VALUE, getMeid());
|
||||||
|
// MIN needs to read from SIM. So if no SIM, we should not show MIN on UI
|
||||||
mDialog.setText(ID_MIN_NUMBER_VALUE, mSubscriptionInfo != null
|
mDialog.setText(ID_MIN_NUMBER_VALUE, mSubscriptionInfo != null
|
||||||
? mTelephonyManager.getCdmaMin(mSubscriptionInfo.getSubscriptionId())
|
? mTelephonyManager.getCdmaMin(mSubscriptionInfo.getSubscriptionId())
|
||||||
: "");
|
: "");
|
||||||
@@ -137,7 +141,8 @@ public class ImeiInfoDialogController {
|
|||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
String getCdmaPrlVersion() {
|
String getCdmaPrlVersion() {
|
||||||
return mTelephonyManager.getCdmaPrlVersion();
|
// PRL needs to read from SIM. So if no SIM, return empty
|
||||||
|
return mSubscriptionInfo != null ? mTelephonyManager.getCdmaPrlVersion() : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
@@ -150,4 +155,9 @@ public class ImeiInfoDialogController {
|
|||||||
String getMeid() {
|
String getMeid() {
|
||||||
return mTelephonyManager.getMeid(mSlotId);
|
return mTelephonyManager.getMeid(mSlotId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
private boolean isValidSlotIndex(int slotIndex, TelephonyManager telephonyManager) {
|
||||||
|
return slotIndex >= 0 && slotIndex < telephonyManager.getPhoneCount();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -86,8 +86,8 @@ public class ImeiInfoDialogControllerTest {
|
|||||||
|
|
||||||
mController = spy(new ImeiInfoDialogController(mDialog, SLOT_ID));
|
mController = spy(new ImeiInfoDialogController(mDialog, SLOT_ID));
|
||||||
|
|
||||||
doReturn(PRL_VERSION).when(mController).getCdmaPrlVersion();
|
when(mTelephonyManager.getCdmaPrlVersion()).thenReturn(PRL_VERSION);
|
||||||
doReturn(MEID_NUMBER).when(mController).getMeid();
|
when(mTelephonyManager.getMeid(anyInt())).thenReturn(MEID_NUMBER);
|
||||||
when(mTelephonyManager.getCdmaMin(anyInt())).thenReturn(MIN_NUMBER);
|
when(mTelephonyManager.getCdmaMin(anyInt())).thenReturn(MIN_NUMBER);
|
||||||
when(mTelephonyManager.getDeviceSoftwareVersion(anyInt())).thenReturn(IMEI_SV_NUMBER);
|
when(mTelephonyManager.getDeviceSoftwareVersion(anyInt())).thenReturn(IMEI_SV_NUMBER);
|
||||||
when(mTelephonyManager.getImei(anyInt())).thenReturn(IMEI_NUMBER);
|
when(mTelephonyManager.getImei(anyInt())).thenReturn(IMEI_NUMBER);
|
||||||
@@ -98,6 +98,7 @@ public class ImeiInfoDialogControllerTest {
|
|||||||
mController = spy(new ImeiInfoDialogController(mDialog, SLOT_ID + 1));
|
mController = spy(new ImeiInfoDialogController(mDialog, SLOT_ID + 1));
|
||||||
|
|
||||||
mController.populateImeiInfo();
|
mController.populateImeiInfo();
|
||||||
|
|
||||||
verify(mDialog, never()).setText(anyInt(), any());
|
verify(mDialog, never()).setText(anyInt(), any());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,16 +130,30 @@ public class ImeiInfoDialogControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void populateImeiInfo_cdmaSimDisabled_shouldRemoveImeiInfoAndSetMinToEmpty() {
|
public void populateImeiInfo_cdmaSimDisabled_shouldRemoveImeiInfoAndSetMinPrlToEmpty() {
|
||||||
ReflectionHelpers.setField(mController, "mSubscriptionInfo", null);
|
ReflectionHelpers.setField(mController, "mSubscriptionInfo", null);
|
||||||
when(mTelephonyManager.getPhoneType()).thenReturn(TelephonyManager.PHONE_TYPE_CDMA);
|
when(mTelephonyManager.getPhoneType()).thenReturn(TelephonyManager.PHONE_TYPE_CDMA);
|
||||||
|
|
||||||
mController.populateImeiInfo();
|
mController.populateImeiInfo();
|
||||||
|
|
||||||
|
verify(mDialog).setText(ID_MEID_NUMBER_VALUE, MEID_NUMBER);
|
||||||
verify(mDialog).setText(ID_MIN_NUMBER_VALUE, "");
|
verify(mDialog).setText(ID_MIN_NUMBER_VALUE, "");
|
||||||
|
verify(mDialog).setText(ID_PRL_VERSION_VALUE, "");
|
||||||
verify(mDialog).removeViewFromScreen(ID_GSM_SETTINGS);
|
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
|
@Test
|
||||||
public void populateImeinfo_gsm_shouldSetImeiAndRemoveCdmaSettings() {
|
public void populateImeinfo_gsm_shouldSetImeiAndRemoveCdmaSettings() {
|
||||||
when(mTelephonyManager.getPhoneType()).thenReturn(TelephonyManager.PHONE_TYPE_GSM);
|
when(mTelephonyManager.getPhoneType()).thenReturn(TelephonyManager.PHONE_TYPE_GSM);
|
||||||
|
Reference in New Issue
Block a user