Merge "Don't crash if IMEI is empty"
diff --git a/src/com/android/settings/deviceinfo/imei/ImeiInfoDialogController.java b/src/com/android/settings/deviceinfo/imei/ImeiInfoDialogController.java
index 71da4a3..4157886 100644
--- a/src/com/android/settings/deviceinfo/imei/ImeiInfoDialogController.java
+++ b/src/com/android/settings/deviceinfo/imei/ImeiInfoDialogController.java
@@ -53,6 +53,9 @@
static final int ID_GSM_SETTINGS = R.id.gsm_settings;
private static CharSequence getTextAsDigits(CharSequence text) {
+ if (TextUtils.isEmpty(text)) {
+ return "";
+ }
if (TextUtils.isDigitsOnly(text)) {
final Spannable spannable = new SpannableStringBuilder(text);
final TtsSpan span = new TtsSpan.DigitsBuilder(text.toString()).build();
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 658a60a..349eddc 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/imei/ImeiInfoDialogControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/imei/ImeiInfoDialogControllerTest.java
@@ -128,4 +128,19 @@
verify(mDialog).setText(eq(ID_IMEI_SV_VALUE), any());
verify(mDialog).removeViewFromScreen(ID_CDMA_SETTINGS);
}
+
+ @Test
+ public void populateImeiInfo_emptyImei_shouldSetMeid_imeiSetToEmptyString() {
+ doReturn(true).when(mController).isCdmaLteEnabled();
+ when(mTelephonyManager.getPhoneType()).thenReturn(TelephonyManager.PHONE_TYPE_CDMA);
+ when(mTelephonyManager.getImei(anyInt())).thenReturn(null);
+
+ mController.populateImeiInfo();
+
+ verify(mDialog).setText(ID_MEID_NUMBER_VALUE, MEID_NUMBER);
+ verify(mDialog).setText(ID_MIN_NUMBER_VALUE, MIN_NUMBER);
+ verify(mDialog).setText(ID_PRL_VERSION_VALUE, PRL_VERSION);
+ verify(mDialog).setText(eq(ID_IMEI_VALUE), eq(""));
+ verify(mDialog).setText(eq(ID_IMEI_SV_VALUE), any());
+ }
}