From e63dfcbd90f9a5d7220c1fe97a6e8a599a48f746 Mon Sep 17 00:00:00 2001 From: SongFerngWang Date: Mon, 13 Jun 2022 17:59:17 +0800 Subject: [PATCH] [MEP] Modify the comments Bug: 235792308 Test: build pass Change-Id: Idf0ce19814ce8b23bc1eea864b36815203069f87 --- .../SwitchToEuiccSubscriptionSidecar.java | 30 ++++++++----------- .../settings/network/UiccSlotUtil.java | 2 +- .../settings/network/UiccSlotUtilTest.java | 14 ++++++--- 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/src/com/android/settings/network/SwitchToEuiccSubscriptionSidecar.java b/src/com/android/settings/network/SwitchToEuiccSubscriptionSidecar.java index 4eee6053da8..0c3d61a2573 100644 --- a/src/com/android/settings/network/SwitchToEuiccSubscriptionSidecar.java +++ b/src/com/android/settings/network/SwitchToEuiccSubscriptionSidecar.java @@ -92,9 +92,6 @@ public class SwitchToEuiccSubscriptionSidecar extends EuiccOperationSidecar { 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 @@ public class SwitchToEuiccSubscriptionSidecar extends EuiccOperationSidecar { 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 @@ public class SwitchToEuiccSubscriptionSidecar extends EuiccOperationSidecar { } 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 @@ public class SwitchToEuiccSubscriptionSidecar extends EuiccOperationSidecar { private boolean isMultipleEnabledProfilesSupported(int physicalEsimSlotIndex) { List 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 7ba2e0f8ed0..e5323d11b99 100644 --- a/src/com/android/settings/network/UiccSlotUtil.java +++ b/src/com/android/settings/network/UiccSlotUtil.java @@ -201,7 +201,7 @@ public class UiccSlotUtil { && 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 526fc0c8d18..4282b3e64c5 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 @@ import java.util.List; @RunWith(AndroidJUnit4.class) public class UiccSlotUtilTest { - private Context mContext; @Mock private TelephonyManager mTelephonyManager; @Mock @@ -61,8 +60,10 @@ public class UiccSlotUtilTest { private static final int ESIM_PHYSICAL_SLOT = 0; private static final int PSIM_PHYSICAL_SLOT = 1; + private Context mContext; private List mSubscriptionInfoList = new ArrayList<>(); private List mUiccCardInfo = new ArrayList<>(); + @Before public void setUp() { MockitoAnnotations.initMocks(this); @@ -98,7 +99,8 @@ public class UiccSlotUtilTest { 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 @@ public class UiccSlotUtilTest { 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 @@ public class UiccSlotUtilTest { 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 class UiccSlotUtilTest { 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 class UiccSlotUtilTest { 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); }