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

Commit 9dfe2d55 authored by Muralidhar Reddy's avatar Muralidhar Reddy Committed by Automerger Merge Worker
Browse files

Fixed port index is not updated when iccid is active but slot is inactive am: 12259326

parents 22c962d2 12259326
Loading
Loading
Loading
Loading
+17 −3
Original line number Diff line number Diff line
@@ -909,8 +909,10 @@ public class SubscriptionManagerService extends ISub.Stub {
                .forEach(subInfo -> {
                    mSubscriptionDatabaseManager.setSimSlotIndex(subInfo.getSubscriptionId(),
                            SubscriptionManager.INVALID_SIM_SLOT_INDEX);
                    // Sometime even though slot-port is inactive, proper iccid will be present,
                    // hence retry the port index from UiccSlot. (Pre-U behavior)
                    mSubscriptionDatabaseManager.setPortIndex(subInfo.getSubscriptionId(),
                            TelephonyManager.INVALID_PORT_INDEX);
                            getPortIndex(subInfo.getIccId()));
                });
        updateGroupDisabled();
        logl("markSubscriptionsInactive: current mapping " + slotMappingToString());
@@ -3802,11 +3804,12 @@ public class SubscriptionManagerService extends ISub.Stub {
    }

    /**
     * Called when eSIM becomes inactive.
     * Called when SIM becomes inactive.
     *
     * @param slotIndex The logical SIM slot index.
     * @param iccId iccId of the SIM in inactivate slot
     */
    public void updateSimStateForInactivePort(int slotIndex) {
    public void updateSimStateForInactivePort(int slotIndex, String iccId) {
        mHandler.post(() -> {
            logl("updateSimStateForInactivePort: slotIndex=" + slotIndex);
            if (mSlotIndexToSubId.containsKey(slotIndex)) {
@@ -3816,6 +3819,17 @@ public class SubscriptionManagerService extends ISub.Stub {
                        mSlotIndexToSubId.get(slotIndex), true);
                updateSubscription(slotIndex);
            }
            if (!TextUtils.isEmpty(iccId)) {
                // When port is inactive, sometimes valid iccid is present in the slot status,
                // hence update the portIndex. (Pre-U behavior)
                SubscriptionInfoInternal subInfo = mSubscriptionDatabaseManager
                        .getSubscriptionInfoInternalByIccId(IccUtils.stripTrailingFs(iccId));
                if (subInfo != null) {
                    mSubscriptionDatabaseManager.setPortIndex(subInfo.getSubscriptionId(),
                            getPortIndex(iccId));
                }
            }

        });
    }

+1 −1
Original line number Diff line number Diff line
@@ -787,7 +787,7 @@ public class UiccController extends Handler {
                        IccCardConstants.State.ABSENT.toString());
            }

            SubscriptionManagerService.getInstance().updateSimStateForInactivePort(phoneId);
            SubscriptionManagerService.getInstance().updateSimStateForInactivePort(phoneId, iccId);
        });
    }

+4 −2
Original line number Diff line number Diff line
@@ -1965,6 +1965,8 @@ public class SubscriptionManagerServiceTest extends TelephonyTest {
                EuiccService.RESULT_OK, new EuiccProfileInfo[0], false);
        doReturn(result).when(mEuiccController).blockingGetEuiccProfileInfoList(eq(1));
        doReturn("").when(mUiccPort).getIccId();
        doReturn(TelephonyManager.INVALID_PORT_INDEX)
                .when(mUiccSlot).getPortIndexFromIccId(anyString());

        mSubscriptionManagerServiceUT.updateEmbeddedSubscriptions(List.of(1), null);
        mSubscriptionManagerServiceUT.updateSimState(
@@ -2026,7 +2028,7 @@ public class SubscriptionManagerServiceTest extends TelephonyTest {
                .getSubscriptionInfoInternal(1);
        assertThat(subInfo.getSimSlotIndex()).isEqualTo(
                SubscriptionManager.INVALID_SUBSCRIPTION_ID);
        assertThat(subInfo.getPortIndex()).isEqualTo(TelephonyManager.INVALID_PORT_INDEX);
        assertThat(subInfo.getPortIndex()).isEqualTo(TelephonyManager.DEFAULT_PORT_INDEX);
    }

    @Test
@@ -2175,7 +2177,7 @@ public class SubscriptionManagerServiceTest extends TelephonyTest {
        testSetUiccApplicationsEnabled();

        mContextFixture.addCallingOrSelfPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE);
        mSubscriptionManagerServiceUT.updateSimStateForInactivePort(0);
        mSubscriptionManagerServiceUT.updateSimStateForInactivePort(0, null);
        processAllMessages();

        SubscriptionInfoInternal subInfo = mSubscriptionManagerServiceUT