[MEP] Modify the comments
Bug: 235792308
Test: build pass
Change-Id: Idf0ce19814ce8b23bc1eea864b36815203069f87
diff --git a/src/com/android/settings/network/SwitchToEuiccSubscriptionSidecar.java b/src/com/android/settings/network/SwitchToEuiccSubscriptionSidecar.java
index 4eee605..0c3d61a 100644
--- a/src/com/android/settings/network/SwitchToEuiccSubscriptionSidecar.java
+++ b/src/com/android/settings/network/SwitchToEuiccSubscriptionSidecar.java
@@ -92,9 +92,6 @@
setState(State.RUNNING, Substate.UNUSED);
mCallbackIntent = createCallbackIntent();
mSubId = subscriptionId;
- SubscriptionManager subscriptionManager = getContext().getSystemService(
- SubscriptionManager.class);
- mActiveSubInfos = SubscriptionUtil.getActiveSubscriptions(subscriptionManager);
int targetSlot = getTargetSlot();
if (targetSlot < 0) {
@@ -103,12 +100,16 @@
return;
}
+ SubscriptionManager subscriptionManager = getContext().getSystemService(
+ SubscriptionManager.class);
+ mActiveSubInfos = SubscriptionUtil.getActiveSubscriptions(subscriptionManager);
+
// To check whether the esim slot's port is active. If yes, skip setSlotMapping. If no,
// set this slot+port into setSimSlotMapping.
mPort = (port < 0) ? getTargetPortId(targetSlot, removedSubInfo) : port;
mRemovedSubInfo = removedSubInfo;
Log.d(TAG,
- String.format("set esim into the SubId%d Physical Slot%d:Port%d",
+ String.format("Set esim into the SubId%d Physical Slot%d:Port%d",
mSubId, targetSlot, mPort));
if (mSubId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
// If the subId is INVALID_SUBSCRIPTION_ID, disable the esim (the default esim slot
@@ -117,20 +118,19 @@
} else if ((mTelephonyManager.isMultiSimEnabled() && removedSubInfo != null
&& removedSubInfo.isEmbedded())
|| isEsimEnabledAtTargetSlotPort(targetSlot, mPort)) {
- // Case1: In DSDS mode+MEP, if the replaced esim is active, then the replaced esim
+ // Case 1: In DSDS mode+MEP, if the replaced esim is active, then the replaced esim
// should be disabled before changing SimSlotMapping process.
//
- // Case2: If the user enables the esimA on the target slot:port and the target
- // slot:port is active and there is an active esimB on target slot:port, then the
- // settings disables the esimB before the settings enables the esimA on the
- // target slot:port.
+ // Case 2: If the user enables the esim A on the target slot:port which is active
+ // and there is an active esim B on target slot:port, then the settings disables the
+ // esim B before the settings enables the esim A on the target slot:port.
//
// Step:
- // 1. disables the replaced esim.
- // 2. switches the SimSlotMapping if the target slot port is not active.
- // 3. enables the target esim.
+ // 1) Disables the replaced esim.
+ // 2) Switches the SimSlotMapping if the target slot:port is not active.
+ // 3) Enables the target esim.
// Note: Use INVALID_SUBSCRIPTION_ID to disable the esim profile.
- Log.d(TAG, "disable the enabled esim before the settings enables the target esim");
+ Log.d(TAG, "Disable the enabled esim before the settings enables the target esim");
mIsDuringSimSlotMapping = true;
mEuiccManager.switchToSubscription(SubscriptionManager.INVALID_SUBSCRIPTION_ID, mPort,
mCallbackIntent);
@@ -235,10 +235,6 @@
private boolean isMultipleEnabledProfilesSupported(int physicalEsimSlotIndex) {
List<UiccCardInfo> cardInfos = mTelephonyManager.getUiccCardsInfo();
- if (cardInfos == null) {
- Log.w(TAG, "UICC cards info list is empty.");
- return false;
- }
return cardInfos.stream()
.anyMatch(cardInfo -> cardInfo.getPhysicalSlotIndex() == physicalEsimSlotIndex
&& cardInfo.isMultipleEnabledProfilesSupported());
diff --git a/src/com/android/settings/network/UiccSlotUtil.java b/src/com/android/settings/network/UiccSlotUtil.java
index 7ba2e0f..e5323d1 100644
--- a/src/com/android/settings/network/UiccSlotUtil.java
+++ b/src/com/android/settings/network/UiccSlotUtil.java
@@ -201,7 +201,7 @@
&& uiccCardInfo.getCardId() > TelephonyManager.UNSUPPORTED_CARD_ID
&& uiccCardInfo.isEuicc()
&& uiccCardInfo.isRemovable()) {
- Log.d(TAG, "getEsimSlotId: This subInfo is removable esim.");
+ Log.d(TAG, "getEsimSlotId: This subInfo is a removable esim.");
return uiccCardInfo.getPhysicalSlotIndex();
}
}
diff --git a/tests/unit/src/com/android/settings/network/UiccSlotUtilTest.java b/tests/unit/src/com/android/settings/network/UiccSlotUtilTest.java
index 526fc0c..4282b3e6 100644
--- a/tests/unit/src/com/android/settings/network/UiccSlotUtilTest.java
+++ b/tests/unit/src/com/android/settings/network/UiccSlotUtilTest.java
@@ -52,7 +52,6 @@
@RunWith(AndroidJUnit4.class)
public class UiccSlotUtilTest {
- private Context mContext;
@Mock
private TelephonyManager mTelephonyManager;
@Mock
@@ -61,8 +60,10 @@
private static final int ESIM_PHYSICAL_SLOT = 0;
private static final int PSIM_PHYSICAL_SLOT = 1;
+ private Context mContext;
private List<SubscriptionInfo> mSubscriptionInfoList = new ArrayList<>();
private List<UiccCardInfo> mUiccCardInfo = new ArrayList<>();
+
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
@@ -98,7 +99,8 @@
public void getEsimSlotId_twoSimSlotsDeviceAndEsimIsSlot0_returnTheCorrectEsimSlot() {
when(mTelephonyManager.getUiccSlotsInfo()).thenReturn(
twoSimSlotsDeviceActiveEsimActivePsim());
- int testSlot = UiccSlotUtil.getEsimSlotId(mContext,0);
+
+ int testSlot = UiccSlotUtil.getEsimSlotId(mContext, 0);
assertThat(testSlot).isEqualTo(0);
}
@@ -112,6 +114,7 @@
mUiccCardInfo.add(createUiccCardInfo(true, cardId, 1, true, -1, -1));
when(mTelephonyManager.getUiccSlotsInfo()).thenReturn(
twoSimSlotsDeviceActiveEsimActiveRemovableEsim());
+
int testSlot = UiccSlotUtil.getEsimSlotId(mContext, subId);
assertThat(testSlot).isEqualTo(1);
@@ -126,6 +129,7 @@
mUiccCardInfo.add(createUiccCardInfo(true, cardId, 1, true, -1, -1));
when(mTelephonyManager.getUiccSlotsInfo()).thenReturn(
twoSimSlotsDeviceActivePsimActiveRemovableEsim());
+
int testSlot = UiccSlotUtil.getEsimSlotId(mContext, subId);
assertThat(testSlot).isEqualTo(1);
@@ -135,7 +139,8 @@
public void getEsimSlotId_twoSimSlotsDeviceAndEsimIsSlot1_returnTheCorrectEsimSlot() {
when(mTelephonyManager.getUiccSlotsInfo()).thenReturn(
twoSimSlotsDeviceActivePsimActiveEsim());
- int testSlot = UiccSlotUtil.getEsimSlotId(mContext,0);
+
+ int testSlot = UiccSlotUtil.getEsimSlotId(mContext, 0);
assertThat(testSlot).isEqualTo(1);
}
@@ -144,7 +149,8 @@
public void getEsimSlotId_noEimSlotDevice_returnTheCorrectEsimSlot() {
when(mTelephonyManager.getUiccSlotsInfo()).thenReturn(
oneSimSlotDeviceActivePsim());
- int testSlot = UiccSlotUtil.getEsimSlotId(mContext,0);
+
+ int testSlot = UiccSlotUtil.getEsimSlotId(mContext, 0);
assertThat(testSlot).isEqualTo(-1);
}