Merge "Display IMEI info when sim is removed"
diff --git a/src/com/android/settings/deviceinfo/imei/ImeiInfoDialogController.java b/src/com/android/settings/deviceinfo/imei/ImeiInfoDialogController.java
index 33bb1d4..f9555e2 100644
--- a/src/com/android/settings/deviceinfo/imei/ImeiInfoDialogController.java
+++ b/src/com/android/settings/deviceinfo/imei/ImeiInfoDialogController.java
@@ -80,9 +80,6 @@
* Sets IMEI/MEID information based on whether the device is CDMA or GSM.
*/
public void populateImeiInfo() {
- if (mSubscriptionInfo == null) {
- return;
- }
if (mTelephonyManager.getPhoneType() == TelephonyManager.PHONE_TYPE_CDMA) {
updateDialogForCdmaPhone();
} else {
@@ -94,7 +91,8 @@
final Resources res = mDialog.getContext().getResources();
mDialog.setText(ID_MEID_NUMBER_VALUE, getMeid());
mDialog.setText(ID_MIN_NUMBER_VALUE,
- mTelephonyManager.getCdmaMin(mSubscriptionInfo.getSubscriptionId()));
+ mSubscriptionInfo != null ? mTelephonyManager.getCdmaMin(
+ mSubscriptionInfo.getSubscriptionId()) : "");
if (res.getBoolean(R.bool.config_msid_enable)) {
mDialog.setText(ID_MIN_NUMBER_LABEL,
@@ -103,7 +101,7 @@
mDialog.setText(ID_PRL_VERSION_VALUE, getCdmaPrlVersion());
- if (isCdmaLteEnabled()) {
+ if (mSubscriptionInfo != null && isCdmaLteEnabled()) {
// Show IMEI for LTE device
mDialog.setText(ID_IMEI_VALUE,
getTextAsDigits(mTelephonyManager.getImei(mSlotId)));
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/imei/ImeiInfoDialogControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/imei/ImeiInfoDialogControllerTest.java
index 921c41f..fd7089e 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/imei/ImeiInfoDialogControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/imei/ImeiInfoDialogControllerTest.java
@@ -112,6 +112,17 @@
}
@Test
+ public void populateImeiInfo_cdmaSimDisabled_shouldRemoveImeiInfoAndSetMinToEmpty() {
+ ReflectionHelpers.setField(mController, "mSubscriptionInfo", null);
+ when(mTelephonyManager.getPhoneType()).thenReturn(TelephonyManager.PHONE_TYPE_CDMA);
+
+ mController.populateImeiInfo();
+
+ verify(mDialog).setText(ID_MIN_NUMBER_VALUE, "");
+ verify(mDialog).removeViewFromScreen(ID_GSM_SETTINGS);
+ }
+
+ @Test
public void populateImeinfo_gsm_shouldSetImeiAndRemoveCdmaSettings() {
when(mTelephonyManager.getPhoneType()).thenReturn(TelephonyManager.PHONE_TYPE_GSM);