Move iccid number to sim status dialog
- Remove iccid number logic from imei dialog
- Add iccid number log to sim status dialog
Bug: 36458278
Test: make RunSettingsRoboTests -j40
Change-Id: I087688645169b387b9d65264e2c8b70ca565a44e
diff --git a/res/layout/dialog_imei_info.xml b/res/layout/dialog_imei_info.xml
index b19d336..d989f42 100644
--- a/res/layout/dialog_imei_info.xml
+++ b/res/layout/dialog_imei_info.xml
@@ -69,6 +69,7 @@
</LinearLayout>
+ <!-- These items are for GSM and LTE enabled CDMA phones -->
<LinearLayout
android:id="@+id/gsm_settings"
android:orientation="vertical"
@@ -99,16 +100,5 @@
android:layout_height="wrap_content"/>
</LinearLayout>
- <TextView
- style="@style/device_info_dialog_label"
- android:id="@+id/icc_id_label"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="@string/status_icc_id"/>
- <TextView
- style="@style/device_info_dialog_value"
- android:id="@+id/icc_id_value"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"/>
</LinearLayout>
</ScrollView>
\ No newline at end of file
diff --git a/res/layout/dialog_sim_status.xml b/res/layout/dialog_sim_status.xml
index 068a889..9377664 100644
--- a/res/layout/dialog_sim_status.xml
+++ b/res/layout/dialog_sim_status.xml
@@ -128,5 +128,17 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/device_info_not_available"/>
+
+ <TextView
+ style="@style/device_info_dialog_label"
+ android:id="@+id/icc_id_label"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/status_icc_id"/>
+ <TextView
+ style="@style/device_info_dialog_value"
+ android:id="@+id/icc_id_value"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"/>
</LinearLayout>
</ScrollView>
diff --git a/src/com/android/settings/deviceinfo/imei/ImeiInfoDialogController.java b/src/com/android/settings/deviceinfo/imei/ImeiInfoDialogController.java
index 542b630..33bb1d4 100644
--- a/src/com/android/settings/deviceinfo/imei/ImeiInfoDialogController.java
+++ b/src/com/android/settings/deviceinfo/imei/ImeiInfoDialogController.java
@@ -44,10 +44,6 @@
@VisibleForTesting
static final int ID_MEID_NUMBER_VALUE = R.id.meid_number_value;
@VisibleForTesting
- static final int ID_ICC_ID_LABEL = R.id.icc_id_label;
- @VisibleForTesting
- static final int ID_ICC_ID_VALUE = R.id.icc_id_value;
- @VisibleForTesting
static final int ID_IMEI_VALUE = R.id.imei_value;
@VisibleForTesting
static final int ID_IMEI_SV_VALUE = R.id.imei_sv_value;
@@ -108,8 +104,7 @@
mDialog.setText(ID_PRL_VERSION_VALUE, getCdmaPrlVersion());
if (isCdmaLteEnabled()) {
- // Show ICC ID and IMEI for LTE device
- mDialog.setText(ID_ICC_ID_VALUE, mSubscriptionInfo.getIccId());
+ // Show IMEI for LTE device
mDialog.setText(ID_IMEI_VALUE,
getTextAsDigits(mTelephonyManager.getImei(mSlotId)));
mDialog.setText(ID_IMEI_SV_VALUE,
@@ -117,8 +112,6 @@
} else {
// device is not GSM/UMTS, do not display GSM/UMTS features
mDialog.removeViewFromScreen(ID_GSM_SETTINGS);
- mDialog.removeViewFromScreen(ID_ICC_ID_LABEL);
- mDialog.removeViewFromScreen(ID_ICC_ID_VALUE);
}
}
@@ -128,8 +121,6 @@
getTextAsDigits(mTelephonyManager.getDeviceSoftwareVersion(mSlotId)));
// device is not CDMA, do not display CDMA features
mDialog.removeViewFromScreen(ID_CDMA_SETTINGS);
- mDialog.removeViewFromScreen(ID_ICC_ID_LABEL);
- mDialog.removeViewFromScreen(ID_ICC_ID_VALUE);
}
private SubscriptionInfo getSubscriptionInfo(Context context, int slotId) {
diff --git a/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogController.java b/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogController.java
index a6cc28f..15ca87b 100644
--- a/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogController.java
+++ b/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogController.java
@@ -16,6 +16,7 @@
package com.android.settings.deviceinfo.simstatus;
+import static android.content.Context.CARRIER_CONFIG_SERVICE;
import static android.content.Context.TELEPHONY_SERVICE;
import android.Manifest;
@@ -26,9 +27,11 @@
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.os.Bundle;
+import android.os.PersistableBundle;
import android.os.UserHandle;
import android.support.annotation.NonNull;
import android.support.annotation.VisibleForTesting;
+import android.telephony.CarrierConfigManager;
import android.telephony.CellBroadcastMessage;
import android.telephony.PhoneStateListener;
import android.telephony.ServiceState;
@@ -70,6 +73,10 @@
final static int CELLULAR_NETWORK_TYPE_VALUE_ID = R.id.network_type_value;
@VisibleForTesting
final static int ROAMING_INFO_VALUE_ID = R.id.roaming_state_value;
+ @VisibleForTesting
+ final static int ICCID_INFO_LABEL_ID = R.id.icc_id_label;
+ @VisibleForTesting
+ final static int ICCID_INFO_VALUE_ID = R.id.icc_id_value;
private final static String CB_AREA_INFO_RECEIVED_ACTION =
"com.android.cellbroadcastreceiver.CB_AREA_INFO_RECEIVED";
@@ -80,6 +87,7 @@
private final SimStatusDialogFragment mDialog;
private final SubscriptionInfo mSubscriptionInfo;
private final TelephonyManager mTelephonyManager;
+ private final CarrierConfigManager mCarrierConfigManager;
private final Resources mRes;
private final Context mContext;
@@ -114,6 +122,9 @@
mSubscriptionInfo = getPhoneSubscriptionInfo(slotId);
mTelephonyManager = (TelephonyManager) mContext.getSystemService(
TELEPHONY_SERVICE);
+ mCarrierConfigManager = (CarrierConfigManager) mContext.getSystemService(
+ CARRIER_CONFIG_SERVICE);
+
mRes = mContext.getResources();
if (lifecycle != null) {
@@ -136,6 +147,7 @@
updateSignalStrength(getSignalStrength());
updateNetworkType();
updateRoamingStatus(serviceState);
+ updateIccidNumber();
}
@Override
@@ -313,6 +325,19 @@
}
}
+ private void updateIccidNumber() {
+ final int subscriptionId = mSubscriptionInfo.getSubscriptionId();
+ final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(subscriptionId);
+ final boolean showIccId = carrierConfig.getBoolean(
+ CarrierConfigManager.KEY_SHOW_ICCID_IN_SIM_STATUS_BOOL);
+ if (!showIccId) {
+ mDialog.removeSettingFromScreen(ICCID_INFO_LABEL_ID);
+ mDialog.removeSettingFromScreen(ICCID_INFO_VALUE_ID);
+ } else {
+ mDialog.setText(ICCID_INFO_VALUE_ID, getSimSerialNumber(subscriptionId));
+ }
+ }
+
private SubscriptionInfo getPhoneSubscriptionInfo(int slotId) {
final List<SubscriptionInfo> subscriptionInfoList = SubscriptionManager.from(
mContext).getActiveSubscriptionInfoList();
@@ -372,4 +397,9 @@
SignalStrength getSignalStrength() {
return mTelephonyManager.getSignalStrength();
}
+
+ @VisibleForTesting
+ String getSimSerialNumber(int subscriptionId) {
+ return mTelephonyManager.getSimSerialNumber(subscriptionId);
+ }
}
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 bb4933b..c95c4db 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/imei/ImeiInfoDialogControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/imei/ImeiInfoDialogControllerTest.java
@@ -18,8 +18,6 @@
import static com.android.settings.deviceinfo.imei.ImeiInfoDialogController.ID_CDMA_SETTINGS;
import static com.android.settings.deviceinfo.imei.ImeiInfoDialogController.ID_GSM_SETTINGS;
-import static com.android.settings.deviceinfo.imei.ImeiInfoDialogController.ID_ICC_ID_LABEL;
-import static com.android.settings.deviceinfo.imei.ImeiInfoDialogController.ID_ICC_ID_VALUE;
import static com.android.settings.deviceinfo.imei.ImeiInfoDialogController.ID_IMEI_SV_VALUE;
import static com.android.settings.deviceinfo.imei.ImeiInfoDialogController.ID_IMEI_VALUE;
import static com.android.settings.deviceinfo.imei.ImeiInfoDialogController.ID_MEID_NUMBER_VALUE;
@@ -58,7 +56,6 @@
private static final String MEID_NUMBER = "12871234124";
private static final String IMEI_NUMBER = "2341982751254";
private static final String MIN_NUMBER = "123417851315";
- private static final String ICCID_NUMBER = "3845672472";
private static final String IMEI_SV_NUMBER = "12";
@Mock
@@ -83,7 +80,6 @@
doReturn(PRL_VERSION).when(mController).getCdmaPrlVersion();
doReturn(MEID_NUMBER).when(mController).getMeid();
when(mTelephonyManager.getCdmaMin(anyInt())).thenReturn(MIN_NUMBER);
- when(mSubscriptionInfo.getIccId()).thenReturn(ICCID_NUMBER);
when(mTelephonyManager.getDeviceSoftwareVersion(anyInt())).thenReturn(IMEI_SV_NUMBER);
when(mTelephonyManager.getImei(anyInt())).thenReturn(IMEI_NUMBER);
}
@@ -98,7 +94,6 @@
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(ID_ICC_ID_VALUE, ICCID_NUMBER);
verify(mDialog).setText(eq(ID_IMEI_VALUE), any());
verify(mDialog).setText(eq(ID_IMEI_SV_VALUE), any());
}
@@ -114,8 +109,6 @@
verify(mDialog).setText(ID_MIN_NUMBER_VALUE, MIN_NUMBER);
verify(mDialog).setText(ID_PRL_VERSION_VALUE, PRL_VERSION);
verify(mDialog).removeViewFromScreen(ID_GSM_SETTINGS);
- verify(mDialog).removeViewFromScreen(ID_ICC_ID_VALUE);
- verify(mDialog).removeViewFromScreen(ID_ICC_ID_LABEL);
}
@Test
@@ -127,7 +120,5 @@
verify(mDialog).setText(eq(ID_IMEI_VALUE), any());
verify(mDialog).setText(eq(ID_IMEI_SV_VALUE), any());
verify(mDialog).removeViewFromScreen(ID_CDMA_SETTINGS);
- verify(mDialog).removeViewFromScreen(ID_ICC_ID_VALUE);
- verify(mDialog).removeViewFromScreen(ID_ICC_ID_LABEL);
}
}
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogControllerTest.java
index 73db81d..d2ee543 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogControllerTest.java
@@ -19,6 +19,10 @@
import static com.android.settings.deviceinfo.simstatus.SimStatusDialogController
.CELLULAR_NETWORK_TYPE_VALUE_ID;
import static com.android.settings.deviceinfo.simstatus.SimStatusDialogController
+ .ICCID_INFO_LABEL_ID;
+import static com.android.settings.deviceinfo.simstatus.SimStatusDialogController
+ .ICCID_INFO_VALUE_ID;
+import static com.android.settings.deviceinfo.simstatus.SimStatusDialogController
.NETWORK_PROVIDER_VALUE_ID;
import static com.android.settings.deviceinfo.simstatus.SimStatusDialogController
.OPERATOR_INFO_LABEL_ID;
@@ -41,6 +45,8 @@
import static org.mockito.Mockito.when;
import android.content.Context;
+import android.os.PersistableBundle;
+import android.telephony.CarrierConfigManager;
import android.telephony.PhoneStateListener;
import android.telephony.ServiceState;
import android.telephony.SignalStrength;
@@ -77,6 +83,10 @@
private PhoneStateListener mPhoneStateListener;
@Mock
private SignalStrength mSignalStrength;
+ @Mock
+ private CarrierConfigManager mCarrierConfigManager;
+ @Mock
+ private PersistableBundle mPersistableBundle;
private SimStatusDialogController mController;
@@ -96,7 +106,9 @@
doReturn("").when(mController).getPhoneNumber();
doReturn(mSignalStrength).when(mController).getSignalStrength();
ReflectionHelpers.setField(mController, "mTelephonyManager", mTelephonyManager);
+ ReflectionHelpers.setField(mController, "mCarrierConfigManager", mCarrierConfigManager);
ReflectionHelpers.setField(mController, "mSubscriptionInfo", mSubscriptionInfo);
+ when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(mPersistableBundle);
}
@Test
@@ -199,4 +211,28 @@
verify(mDialog).setText(ROAMING_INFO_VALUE_ID, roamingOffString);
}
+ @Test
+ public void initialize_doNotShowIccid_shouldRemoveIccidSetting() {
+ when(mPersistableBundle.getBoolean(
+ CarrierConfigManager.KEY_SHOW_ICCID_IN_SIM_STATUS_BOOL)).thenReturn(
+ false);
+
+ mController.initialize();
+
+ verify(mDialog).removeSettingFromScreen(ICCID_INFO_LABEL_ID);
+ verify(mDialog).removeSettingFromScreen(ICCID_INFO_VALUE_ID);
+ }
+
+ @Test
+ public void initialize_showIccid_shouldSetIccidToSetting() {
+ final String iccid = "12351351231241";
+ when(mPersistableBundle.getBoolean(
+ CarrierConfigManager.KEY_SHOW_ICCID_IN_SIM_STATUS_BOOL)).thenReturn(
+ true);
+ doReturn(iccid).when(mController).getSimSerialNumber(anyInt());
+
+ mController.initialize();
+
+ verify(mDialog).setText(ICCID_INFO_VALUE_ID, iccid);
+ }
}