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

Commit f44be149 authored by Danny Baumann's avatar Danny Baumann Committed by Gerrit Code Review
Browse files

Also activate default UICC apps once after SIM presence.

Some devices apparently need this, and it shouldn't hurt on other
devices either.

Change-Id: I7feb27cceeffc30081e682a6f6b0e2bdb6ad5087
parent fa7ee16d
Loading
Loading
Loading
Loading
+38 −29
Original line number Diff line number Diff line
@@ -83,7 +83,7 @@ public class UiccCard {
    private CatService mCatService;
    private RadioState mLastRadioState =  RadioState.RADIO_UNAVAILABLE;
    private UiccCarrierPrivilegeRules mCarrierPrivilegeRules;
    private boolean m3GPPAppActivated, m3GPP2AppActivated;
    private boolean mDefaultAppsActivated;
    private UICCConfig mUICCConfig = null;

    private RegistrantList mAbsentRegistrants = new RegistrantList();
@@ -195,36 +195,17 @@ public class UiccCard {
                    mHandler.sendMessage(mHandler.obtainMessage(EVENT_CARD_ADDED, null));
                }
            }
            if (mGsmUmtsSubscriptionAppIndex < 0
                    && mCdmaSubscriptionAppIndex < 0
                    && mCardState == CardState.CARDSTATE_PRESENT
                    && mCi.needsOldRilFeature("simactivation")) {
                // Activate/Deactivate first 3GPP and 3GPP2 app in the SIM, if available
                for (int i = 0; i < mUiccApplications.length; i++) {
                    if (mUiccApplications[i] == null) {
                        continue;
                    }

                    AppType appType = mUiccApplications[i].getType();
                    if (!m3GPPAppActivated &&
                            (appType == AppType.APPTYPE_USIM || appType == AppType.APPTYPE_SIM)) {
                        mCi.setUiccSubscription(i, true, null);
                        m3GPPAppActivated = true;
                    } else if (!m3GPP2AppActivated &&
                            (appType == AppType.APPTYPE_CSIM || appType == AppType.APPTYPE_RUIM)) {
                        mCi.setUiccSubscription(i, true, null);
                        m3GPP2AppActivated = true;
                    }

                    if (m3GPPAppActivated && m3GPP2AppActivated) {
                        break;
                    }
            if (mCi.needsOldRilFeature("simactivation")) {
                if (mCardState == CardState.CARDSTATE_PRESENT) {
                    if (!mDefaultAppsActivated) {
                        activateDefaultApps();
                        mDefaultAppsActivated = true;
                    }
                } else {
                // SIM removed, reset activation flags to make sure
                    // SIM removed, reset activation flag to make sure
                    // to re-run the activation at the next insertion
                m3GPPAppActivated = false;
                m3GPP2AppActivated = false;
                    mDefaultAppsActivated = false;
                }
            }

            mLastRadioState = radioState;
@@ -292,6 +273,34 @@ public class UiccCard {
        return index;
    }

    private void activateDefaultApps() {
        int gsmIndex = mGsmUmtsSubscriptionAppIndex;
        int cdmaIndex = mCdmaSubscriptionAppIndex;

        if (gsmIndex < 0 || cdmaIndex < 0) {
            for (int i = 0; i < mUiccApplications.length; i++) {
                if (mUiccApplications[i] == null) {
                    continue;
                }

                AppType appType = mUiccApplications[i].getType();
                if (gsmIndex < 0
                        && (appType == AppType.APPTYPE_USIM || appType == AppType.APPTYPE_SIM)) {
                    gsmIndex = i;
                } else if (cdmaIndex < 0 &&
                        (appType == AppType.APPTYPE_CSIM || appType == AppType.APPTYPE_RUIM)) {
                    cdmaIndex = i;
                }
            }
        }
        if (gsmIndex >= 0) {
            mCi.setUiccSubscription(gsmIndex, true, null);
        }
        if (cdmaIndex >= 0) {
            mCi.setUiccSubscription(cdmaIndex, true, null);
        }
    }

    /**
     * Notifies handler of any transition into State.ABSENT
     */