</LinearLayout>
+ <!-- These items are for GSM and LTE enabled CDMA phones -->
<LinearLayout
android:id="@+id/gsm_settings"
android:orientation="vertical"
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
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>
@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;
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,
} 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);
}
}
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) {
package com.android.settings.deviceinfo.simstatus;
+import static android.content.Context.CARRIER_CONFIG_SERVICE;
import static android.content.Context.TELEPHONY_SERVICE;
import android.Manifest;
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;
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";
private final SimStatusDialogFragment mDialog;
private final SubscriptionInfo mSubscriptionInfo;
private final TelephonyManager mTelephonyManager;
+ private final CarrierConfigManager mCarrierConfigManager;
private final Resources mRes;
private final Context mContext;
mSubscriptionInfo = getPhoneSubscriptionInfo(slotId);
mTelephonyManager = (TelephonyManager) mContext.getSystemService(
TELEPHONY_SERVICE);
+ mCarrierConfigManager = (CarrierConfigManager) mContext.getSystemService(
+ CARRIER_CONFIG_SERVICE);
+
mRes = mContext.getResources();
if (lifecycle != null) {
updateSignalStrength(getSignalStrength());
updateNetworkType();
updateRoamingStatus(serviceState);
+ updateIccidNumber();
}
@Override
}
}
+ 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();
SignalStrength getSignalStrength() {
return mTelephonyManager.getSignalStrength();
}
+
+ @VisibleForTesting
+ String getSimSerialNumber(int subscriptionId) {
+ return mTelephonyManager.getSimSerialNumber(subscriptionId);
+ }
}
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;
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
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);
}
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());
}
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
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);
}
}
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;
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;
private PhoneStateListener mPhoneStateListener;
@Mock
private SignalStrength mSignalStrength;
+ @Mock
+ private CarrierConfigManager mCarrierConfigManager;
+ @Mock
+ private PersistableBundle mPersistableBundle;
private SimStatusDialogController mController;
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
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);
+ }
}