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

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

Handle default boot profile on eSIM where it's never READY.

Default boot eSIM profile will have 0 UiccApplications. Which will
have Uicc stuck in NOT_READY state. Here we are treating it as SIM
being ABSENT in SubscriptionInfoUpdater.
This is necessary to unblock DSDS power profiling.

Bug: 120149456
Test: manual
Change-Id: I4051b3dd0d119de0fa9e5a988fae7d0195a6f28a
Merged-In: I4051b3dd0d119de0fa9e5a988fae7d0195a6f28a
parent 27d9744e
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -275,6 +275,14 @@ public class IccCard {
        return false;
    }

    /**
     * @return whether the card is an empty profile, meaning there's no UiccCardApplication,
     * and that we don't need to wait for LOADED state.
     */
    public boolean isEmptyProfile() {
        return false;
    }

    private void sendMessageWithCardAbsentException(Message onComplete) {
        AsyncResult ret = AsyncResult.forMessage(onComplete);
        ret.exception = new RuntimeException("No valid IccCard");
+21 −9
Original line number Diff line number Diff line
@@ -276,16 +276,8 @@ public class SubscriptionInfoUpdater extends Handler {
                break;

            case EVENT_SIM_NOT_READY:
                broadcastSimStateChanged(msg.arg1, IccCardConstants.INTENT_VALUE_ICC_NOT_READY,
                        null);
                broadcastSimCardStateChanged(msg.arg1, TelephonyManager.SIM_STATE_PRESENT);
                broadcastSimApplicationStateChanged(msg.arg1, TelephonyManager.SIM_STATE_NOT_READY);
                handleSimNotReady(msg.arg1);
                // intentional fall through
                // ICC_NOT_READY is a terminal state for an eSIM on the boot profile. At this
                // phase, the subscription list is accessible.
                // TODO(b/64216093): Clean up this special case, likely by treating NOT_READY
                // as equivalent to ABSENT, once the rest of the system can handle it. Currently
                // this breaks SystemUI which shows a "No SIM" icon.

            case EVENT_REFRESH_EMBEDDED_SUBSCRIPTIONS:
                if (updateEmbeddedSubscriptions()) {
@@ -359,6 +351,26 @@ public class SubscriptionInfoUpdater extends Handler {
        }
    }

    private void handleSimNotReady(int slotId) {
        logd("handleSimNotReady: slotId: " + slotId);

        IccCard iccCard = mPhone[slotId].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
            // as equivalent to ABSENT, once the rest of the system can handle it.
            mIccId[slotId] = ICCID_STRING_FOR_NO_SIM;
            if (isAllIccIdQueryDone()) {
                updateSubscriptionInfoByIccId();
            }
        }

        broadcastSimStateChanged(slotId, IccCardConstants.INTENT_VALUE_ICC_NOT_READY,
                null);
        broadcastSimCardStateChanged(slotId, TelephonyManager.SIM_STATE_PRESENT);
        broadcastSimApplicationStateChanged(slotId, TelephonyManager.SIM_STATE_NOT_READY);
    }

    private void handleSimLoaded(int slotId) {
        logd("handleSimLoaded: slotId: " + slotId);

+10 −0
Original line number Diff line number Diff line
@@ -787,6 +787,16 @@ public class UiccProfile extends IccCard {
        return mUiccApplication != null && mUiccApplication.getIccPuk2Blocked();
    }

    @Override
    public boolean isEmptyProfile() {
        // If there's no UiccCardApplication, it's an empty profile.
        // Empty profile is a valid case of eSIM (default boot profile).
        for (UiccCardApplication app : mUiccApplications) {
            if (app != null) return false;
        }
        return true;
    }

    @Override
    public void setIccLockEnabled(boolean enabled, String password, Message onComplete) {
        synchronized (mLock) {