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

Unverified Commit 5c9dc29a authored by Wileen Chiu's avatar Wileen Chiu Committed by Michael Bestas
Browse files

Update external card state based on current app

- Before setting and broadcasting READY
state, Telephony checks all supported
UiccCardApplications instead of only the current app state
- Telephony expects all apps reported through
GET_SIM_STATUS should move to READY, however,
this expectation is not correct.
- For example, in the case where a CDMAless MBN is flashed,
and CDMA is not supported, the SIM card reports
a CSIM app. It will remain in DETECTED state and thus,
Telephony never broadcasts the relevant state.
- Use legacy implementation, and broadcast READY state
based on the current app. Broadcast LOADED state once
all apps that have moved to READY have finished loading.

Change-Id: I12ffcc0dc0518f78b6753b8741ccae421e0466bd
CRs-Fixed: 2203384
parent 34cccdc8
Loading
Loading
Loading
Loading
+11 −33
Original line number Diff line number Diff line
@@ -724,25 +724,17 @@ public class UiccProfile extends IccCard {
                break;
            case APPSTATE_READY:
                checkAndUpdateIfAnyAppToBeIgnored();
                if (areAllApplicationsReady()) {
                    if (areAllRecordsLoaded() && areCarrierPrivilegeRulesLoaded()) {
                if (areReadyAppsRecordsLoaded() && areCarrierPrivilegeRulesLoaded()) {
                    if (VDBG) log("updateExternalState: setting state to LOADED");
                    setExternalState(IccCardConstants.State.LOADED);
                } else {
                    if (VDBG) {
                        log("updateExternalState: setting state to READY; records loaded "
                                    + areAllRecordsLoaded() + ", carrier privilige rules loaded "
                                + areReadyAppsRecordsLoaded() + ", carrier privilige rules loaded "
                                + areCarrierPrivilegeRulesLoaded());
                    }
                    setExternalState(IccCardConstants.State.READY);
                }
                } else {
                    if (VDBG) {
                        log("updateExternalState: app state is READY but not for all apps; "
                                + "setting state to NOT_READY");
                    }
                    setExternalState(IccCardConstants.State.NOT_READY);
                }
                break;
        }
    }
@@ -1248,33 +1240,19 @@ public class UiccProfile extends IccCard {
        }
    }

    private boolean areAllApplicationsReady() {
    private boolean areReadyAppsRecordsLoaded() {
        for (UiccCardApplication app : mUiccApplications) {
            if (app != null && isSupportedApplication(app) && !app.isReady()
            if (app != null && isSupportedApplication(app) && app.isReady()
                    && !app.isAppIgnored()) {
                if (VDBG) log("areAllApplicationsReady: return false");
                return false;
            }
        }

        if (VDBG) {
            log("areAllApplicationsReady: outside loop, return " + (mUiccApplication != null));
        }
        return mUiccApplication != null;
    }

    private boolean areAllRecordsLoaded() {
        for (UiccCardApplication app : mUiccApplications) {
            if (app != null && isSupportedApplication(app) && !app.isAppIgnored()) {
                IccRecords ir = app.getIccRecords();
                if (ir == null || !ir.isLoaded()) {
                    if (VDBG) log("areAllRecordsLoaded: return false");
                    if (VDBG) log("areReadyAppsRecordsLoaded: return false");
                    return false;
                }
            }
        }
        if (VDBG) {
            log("areAllRecordsLoaded: outside loop, return " + (mUiccApplication != null));
            log("areReadyAppsRecordsLoaded: outside loop, return " + (mUiccApplication != null));
        }
        return mUiccApplication != null;
    }