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

Commit 301f40d1 authored by Malcolm Chen's avatar Malcolm Chen
Browse files

Check SIM valid before forcing network auto select

When handling EVENT_POLL_STATE_NETWORK_SELECTION_MODE, we make
sure it's valid subId before we try to force automatic network
selection mode to the modem.

Bug: 63969102
Test: manual
Change-Id: Ic831056ab658146a845b3271b494a505c2e72053
parent 02558a9f
Loading
Loading
Loading
Loading
+16 −7
Original line number Diff line number Diff line
@@ -2718,26 +2718,35 @@ public class GsmCdmaPhone extends Phone {
        return (r != null) ? r.isCspPlmnEnabled() : false;
    }

    public boolean isManualNetSelAllowed() {
    /**
     * Whether manual select is now allowed and we should set
     * to auto network select mode.
     */
    public boolean shouldForceAutoNetworkSelect() {

        int nwMode = Phone.PREFERRED_NT_MODE;
        int subId = getSubId();

        // If it's invalid subId, we shouldn't force to auto network select mode.
        if (!SubscriptionManager.isValidSubscriptionId(subId)) {
            return false;
        }

        nwMode = android.provider.Settings.Global.getInt(mContext.getContentResolver(),
                    android.provider.Settings.Global.PREFERRED_NETWORK_MODE + subId, nwMode);

        logd("isManualNetSelAllowed in mode = " + nwMode);
        logd("shouldForceAutoNetworkSelect in mode = " + nwMode);
        /*
         *  For multimode targets in global mode manual network
         *  selection is disallowed
         *  selection is disallowed. So we should force auto select mode.
         */
        if (isManualSelProhibitedInGlobalMode()
                && ((nwMode == Phone.NT_MODE_LTE_CDMA_EVDO_GSM_WCDMA)
                        || (nwMode == Phone.NT_MODE_GLOBAL)) ){
            logd("Manual selection not supported in mode = " + nwMode);
            return false;
            logd("Should force auto network select mode = " + nwMode);
            return true;
        } else {
            logd("Manual selection is supported in mode = " + nwMode);
            logd("Should not force auto network select mode = " + nwMode);
        }

        /*
@@ -2747,7 +2756,7 @@ public class GsmCdmaPhone extends Phone {
         *  Note: the actual enabling/disabling manual selection for these
         *  cases will be controlled by csp
         */
        return true;
        return false;
    }

    private boolean isManualSelProhibitedInGlobalMode() {
+1 −1
Original line number Diff line number Diff line
@@ -1975,7 +1975,7 @@ public class ServiceStateTracker extends Handler {
            case EVENT_POLL_STATE_NETWORK_SELECTION_MODE: {
                ints = (int[])ar.result;
                mNewSS.setIsManualSelection(ints[0] == 1);
                if ((ints[0] == 1) && (!mPhone.isManualNetSelAllowed())) {
                if ((ints[0] == 1) && (mPhone.shouldForceAutoNetworkSelect())) {
                        /*
                         * modem is currently in manual selection but manual
                         * selection is not allowed in the current mode so