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

Commit ea6f3d25 authored by Sandeep Gutta's avatar Sandeep Gutta
Browse files

MSIM: Fix Default DATA subId switch issue

- Fix to do not call DDS request when valid subscriptions
  are not available.
- Handle and update the SIM state info of a subscription when the
  SIM state change event belongs to that.

Change-Id: I3ffc4cbd40a91372c121d315e75e39da52dbd403
CRs-Fixed: 761866
parent 5bf3c52e
Loading
Loading
Loading
Loading
+49 −32
Original line number Diff line number Diff line
@@ -255,7 +255,14 @@ public class SubInfoRecordUpdater extends Handler {
                }
                break;
            case EVENT_ICC_CHANGED:
                updateIccAvailability();
                Integer cardIndex = new Integer(PhoneConstants.DEFAULT_CARD_INDEX);
                if (ar.result != null) {
                    cardIndex = (Integer) ar.result;
                } else {
                    Rlog.e(LOG_TAG, "Error: Invalid card index EVENT_ICC_CHANGED ");
                    return;
                }
                updateIccAvailability(cardIndex);
                break;
            case EVENT_STACK_READY:
                logd("EVENT_STACK_READY" );
@@ -268,17 +275,22 @@ public class SubInfoRecordUpdater extends Handler {
        }
    }

    private void updateIccAvailability() {
    private void updateIccAvailability(int slotId) {
        if (null == mUiccController) {
            return;
        }
        logd("updateIccAvailability: Enter");
        if (!SubscriptionHelper.getInstance().proceedToHandleIccEvent()) {
        SubscriptionHelper subHelper = SubscriptionHelper.getInstance();
        logd("updateIccAvailability: Enter, slotId " + slotId);
        if (PROJECT_SIM_NUM > 1 && !subHelper.proceedToHandleIccEvent(slotId)) {
            logd("updateIccAvailability: radio is OFF/unavailable, ignore ");
            if (!subHelper.isApmSIMNotPwdn()) {
                // set the iccid to null so that once SIM card detected
                //  ICCID will be read from the card again.
                sIccId[slotId] = null;
            }
            return;
        }

        for (int slotId = 0; slotId < PROJECT_SIM_NUM; slotId++) {
        CardState newState = CardState.CARDSTATE_ABSENT;
        UiccCard newCard = mUiccController.getUiccCard(slotId);
        if (newCard != null) {
@@ -307,7 +319,12 @@ public class SubInfoRecordUpdater extends Handler {
                sNeedUpdate = true;
            }
            queryIccId(slotId);
            }
        } else if (oldState.isCardPresent() && newState.isCardPresent() &&
                (!subHelper.isApmSIMNotPwdn()) && (sIccId[slotId] == null)) {
            logd("SIM" + (slotId + 1) + " powered up from APM ");
            sFh[slotId] = null;
            sNeedUpdate = true;
            queryIccId(slotId);
        }
    }

+15 −16
Original line number Diff line number Diff line
@@ -320,19 +320,19 @@ class SubscriptionHelper extends Handler {
        return mCi[phoneId].getRadioState().isAvailable();
    }

    public boolean proceedToHandleIccEvent() {
    public boolean isApmSIMNotPwdn() {
        return sApmSIMNotPwdn;
    }

    public boolean proceedToHandleIccEvent(int slotId) {
        int apmState = Settings.Global.getInt(mContext.getContentResolver(),
                Settings.Global.AIRPLANE_MODE_ON, 0);

        // If SIM powers down in APM, telephony needs to send SET_UICC
        // once radio turns ON
        if (!sApmSIMNotPwdn) {
            for (int phoneId = 0; phoneId < sNumPhones; phoneId++) {
                if (!isRadioOn(phoneId)) {
                     logi(" proceedToHandleIccEvent, radio off/unavailable, phoneId = " + phoneId);
                     mSubStatus[phoneId] = SUB_INIT_STATE;
                }
            }
        // once radio turns ON also do not handle process SIM change events
        if ((!sApmSIMNotPwdn) && (!isRadioOn(slotId) || (apmState == 1))) {
            logi(" proceedToHandleIccEvent, radio off/unavailable, slotId = " + slotId);
            mSubStatus[slotId] = SUB_INIT_STATE;
        }

        // Do not handle if SIM powers down in APM mode
@@ -341,13 +341,12 @@ class SubscriptionHelper extends Handler {
            return false;
        }

        for (int phoneId = 0; phoneId < sNumPhones; phoneId++) {

        // Seems SSR happenned or RILD crashed, do not handle SIM change events
            if (!isRadioAvailable(phoneId) || ((apmState == 0) && !isRadioOn(phoneId))) {
                logi(" proceedToHandleIccEvent, radio not available, phoneId = " + phoneId);
        if (!isRadioAvailable(slotId)) {
            logi(" proceedToHandleIccEvent, radio not available, slotId = " + slotId);
            return false;
        }
        }
        return true;
    }

+15 −4
Original line number Diff line number Diff line
@@ -154,6 +154,17 @@ public class DctController extends Handler {
        }
    };

    boolean isActiveSubId(long subId) {
        long[] activeSubs = mSubController.getActiveSubIdList();
        for (int i = 0; i < activeSubs.length; i++) {
            if (subId == activeSubs[i]) {
                return true;
            }
        }
        return false;
    }


    private class DataStateReceiver extends BroadcastReceiver {
        public void onReceive(Context context, Intent intent) {
            synchronized(this) {
@@ -162,12 +173,12 @@ public class DctController extends Handler {

                    long subId = intent.getLongExtra(PhoneConstants.SUBSCRIPTION_KEY, PhoneConstants.SUB1);
                    int phoneId = SubscriptionManager.getPhoneId(subId);
                    logd("DataStateReceiver: phoneId= " + phoneId);

                    // for the case of network out of service when bootup (ignore dummy values too)
                    if (!SubscriptionManager.isValidSubId(subId) || (subId < 0)) {
                    if (!SubscriptionManager.isValidSubId(subId) || (subId < 0) ||
                            !isActiveSubId(subId)) {
                        // FIXME: Maybe add SM.isRealSubId(subId)??
                        logd("DataStateReceiver: ignore invalid subId=" + subId);
                        logd("DataStateReceiver: ignore invalid subId=" + subId
                                + " phoneId = " + phoneId);
                        return;
                    }
                    if (!SubscriptionManager.isValidPhoneId(phoneId)) {
+0 −1
Original line number Diff line number Diff line
@@ -144,7 +144,6 @@ public class UiccController extends Handler {
            // TODO remove this once modem correctly notifies the unsols
            mCis[i].registerForAvailable(this, EVENT_ICC_STATUS_CHANGED, index);
            mCis[i].registerForNotAvailable(this, EVENT_RADIO_UNAVAILABLE, index);
            mCis[i].registerForOn(this, EVENT_ICC_STATUS_CHANGED, index);
            if (mOEMHookSimRefresh) {
                mCis[i].registerForSimRefreshEvent(this, EVENT_REFRESH_OEM, index);
            } else {