Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 95f15364 authored by SongFerng Wang's avatar SongFerng Wang Committed by Automerger Merge Worker
Browse files

Merge changes Idf0ce198,Ibd324b78,I6daa38f5,I242402e4 am: 8be3ebd1 am: a5a729f5

parents a5ddd890 a5a729f5
Loading
Loading
Loading
Loading
+13 −17
Original line number Diff line number Diff line
@@ -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
@@ -120,17 +121,16 @@ public class SwitchToEuiccSubscriptionSidecar extends EuiccOperationSidecar {
            // 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<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());
+1 −1
Original line number Diff line number Diff line
@@ -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();
                }
            }
+10 −4
Original line number Diff line number Diff line
@@ -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<SubscriptionInfo> mSubscriptionInfoList = new ArrayList<>();
    private List<UiccCardInfo> mUiccCardInfo = new ArrayList<>();

    @Before
    public void setUp() {
        MockitoAnnotations.initMocks(this);
@@ -98,6 +99,7 @@ public class UiccSlotUtilTest {
    public void getEsimSlotId_twoSimSlotsDeviceAndEsimIsSlot0_returnTheCorrectEsimSlot() {
        when(mTelephonyManager.getUiccSlotsInfo()).thenReturn(
                twoSimSlotsDeviceActiveEsimActivePsim());

        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,6 +139,7 @@ public class UiccSlotUtilTest {
    public void getEsimSlotId_twoSimSlotsDeviceAndEsimIsSlot1_returnTheCorrectEsimSlot() {
        when(mTelephonyManager.getUiccSlotsInfo()).thenReturn(
                twoSimSlotsDeviceActivePsimActiveEsim());

        int testSlot = UiccSlotUtil.getEsimSlotId(mContext, 0);

        assertThat(testSlot).isEqualTo(1);
@@ -144,6 +149,7 @@ public class UiccSlotUtilTest {
    public void getEsimSlotId_noEimSlotDevice_returnTheCorrectEsimSlot() {
        when(mTelephonyManager.getUiccSlotsInfo()).thenReturn(
                oneSimSlotDeviceActivePsim());

        int testSlot = UiccSlotUtil.getEsimSlotId(mContext, 0);

        assertThat(testSlot).isEqualTo(-1);