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

Commit 6444ca66 authored by Muralidhar Reddy Mule's avatar Muralidhar Reddy Mule Committed by Android (Google) Code Review
Browse files

Merge "Fixed port index is not updated when iccid is active but slot is inactive" into udc-dev

parents b7b74a20 e20f8b94
Loading
Loading
Loading
Loading
+17 −3
Original line number Diff line number Diff line
@@ -933,8 +933,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());
@@ -3813,11 +3815,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)) {
@@ -3827,6 +3830,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
@@ -790,7 +790,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
@@ -1956,6 +1956,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(
@@ -2017,7 +2019,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
@@ -2166,7 +2168,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