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

Commit bdf60112 authored by Malcolm Chen's avatar Malcolm Chen
Browse files

If uicc apps are disabled, mark its NOT_READY state final.

Bug: 141018421
Test: unittest
Change-Id: If7a615f4d0117b7f12829fd87c48882360a34c52
parent 09c5ddcd
Loading
Loading
Loading
Loading
+21 −3
Original line number Diff line number Diff line
@@ -418,11 +418,15 @@ public class SubscriptionInfoUpdater extends Handler {

    private void handleSimNotReady(int phoneId) {
        logd("handleSimNotReady: phoneId: " + phoneId);
        boolean isFinalState = false;

        IccCard iccCard = PhoneFactory.getPhone(phoneId).getIccCard();
        if (iccCard.isEmptyProfile()) {
            // ICC_NOT_READY is a terminal state for an eSIM on the boot profile. At this
            // phase, the subscription list is accessible. Treating NOT_READY
        if (iccCard.isEmptyProfile() || areUiccAppsDisabledOnCard(phoneId)) {
            isFinalState = true;
            // ICC_NOT_READY is a terminal state for
            // 1) It's an empty profile as there's no uicc applications. Or
            // 2) Its uicc applications are set to be disabled.
            // At this phase, the subscription list is accessible. Treating NOT_READY
            // as equivalent to ABSENT, once the rest of the system can handle it.
            sIccId[phoneId] = ICCID_STRING_FOR_NO_SIM;
            updateSubscriptionInfoByIccId(phoneId, false /* updateEmbeddedSubs */);
@@ -432,6 +436,20 @@ public class SubscriptionInfoUpdater extends Handler {
                null);
        broadcastSimCardStateChanged(phoneId, TelephonyManager.SIM_STATE_PRESENT);
        broadcastSimApplicationStateChanged(phoneId, TelephonyManager.SIM_STATE_NOT_READY);
        if (isFinalState) {
            updateCarrierServices(phoneId, IccCardConstants.INTENT_VALUE_ICC_NOT_READY);
        }
    }

    private boolean areUiccAppsDisabledOnCard(int phoneId) {
        // When uicc apps are disabled(supported in IRadio 1.5), we will still get IccId from
        // cardStatus (since IRadio 1.2). Amd upon cardStatus change we'll receive another
        // handleSimNotReady so this will be evaluated again.
        UiccSlot slot = UiccController.getInstance().getUiccSlotForPhone(phoneId);
        if (slot == null || slot.getIccId() == null) return false;
        SubscriptionInfo info = SubscriptionController.getInstance()
                .getSubInfoForIccId(slot.getIccId());
        return info != null && !info.areUiccApplicationsEnabled();
    }

    private void handleSimLoaded(int phoneId) {
+6 −0
Original line number Diff line number Diff line
@@ -590,6 +590,12 @@ public class UiccProfile extends IccCard {
                }
                setExternalState(IccCardConstants.State.NOT_READY);
                break;
            case APPSTATE_DETECTED:
                if (VDBG) {
                    log("updateExternalState: app state is detected; setting state to NOT_READY");
                }
                setExternalState(IccCardConstants.State.NOT_READY);
                break;
            case APPSTATE_READY:
                checkAndUpdateIfAnyAppToBeIgnored();
                if (areAllApplicationsReady()) {
+40 −0
Original line number Diff line number Diff line
@@ -233,6 +233,46 @@ public class SubscriptionInfoUpdaterTest extends TelephonyTest {
        verify(mSubscriptionController, times(0)).notifySubscriptionInfoChanged();
    }

    @Test
    @SmallTest
    public void testSimNotReady() throws Exception {
        mUpdater.updateInternalIccState(
                IccCardConstants.INTENT_VALUE_ICC_NOT_READY, null, FAKE_SUB_ID_1, false);

        processAllMessages();
        assertFalse(mUpdater.isSubInfoInitialized());
        verify(mSubscriptionContent, never()).put(anyString(), any());
        CarrierConfigManager mConfigManager = (CarrierConfigManager)
                mContext.getSystemService(Context.CARRIER_CONFIG_SERVICE);
        verify(mConfigManager, never()).updateConfigForPhoneId(eq(FAKE_SUB_ID_1),
                eq(IccCardConstants.INTENT_VALUE_ICC_NOT_READY));
        verify(mSubscriptionController, never()).clearSubInfo();
        verify(mSubscriptionController, never()).notifySubscriptionInfoChanged();
    }

    @Test
    @SmallTest
    public void testSimNotReadyEmptyProfile() throws Exception {
        doReturn(mIccCard).when(mPhone).getIccCard();
        doReturn(true).when(mIccCard).isEmptyProfile();

        mUpdater.updateInternalIccState(
                IccCardConstants.INTENT_VALUE_ICC_NOT_READY, null, FAKE_SUB_ID_1, false);

        processAllMessages();
        assertTrue(mUpdater.isSubInfoInitialized());
        // Sub info should be cleared and change should be notified.
        verify(mSubscriptionController).clearSubInfoRecord(eq(FAKE_SUB_ID_1));
        verify(mSubscriptionController).notifySubscriptionInfoChanged();
        // No new sub should be added.
        verify(mSubscriptionManager, never()).addSubscriptionInfoRecord(any(), anyInt());
        verify(mSubscriptionContent, never()).put(anyString(), any());
        CarrierConfigManager mConfigManager = (CarrierConfigManager)
                mContext.getSystemService(Context.CARRIER_CONFIG_SERVICE);
        verify(mConfigManager).updateConfigForPhoneId(eq(FAKE_SUB_ID_1),
                eq(IccCardConstants.INTENT_VALUE_ICC_NOT_READY));
    }

    @Test
    @SmallTest
    public void testSimError() throws Exception {
+2 −0
Original line number Diff line number Diff line
@@ -265,6 +265,8 @@ public abstract class TelephonyTest {
    protected UiccCard mUiccCard;
    @Mock
    protected MultiSimSettingController mMultiSimSettingController;
    @Mock
    protected IccCard mIccCard;

    protected ImsCallProfile mImsCallProfile;
    protected TelephonyManager mTelephonyManager;