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

Unverified Commit f3ae0e47 authored by Christopher R. Palmer's avatar Christopher R. Palmer Committed by Michael Bestas
Browse files

telephony: Improve compatibility for older DSDS stacks

Older stacks require that you update the preferred network when
you are changing data subscriptions.  The update to the network mode
internally triggers changes between a 2G only stack and a full
stack.

To support this always set the preferred network mode when changing
data subscriptions.

Additionally, ensure that the full stack is released before attempting
to bind the new subscription to that stack rather than seting them
concurrently.  When set concurrently,  there will be a race condition
as both attempt to use the full stack.

Instead, switch to the 2G stack and only after that completes
make the second switch.

Change-Id: I7de8ac803081362f6fbfce29d9578a3eb5d10c30
parent 4b24aa15
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -1468,6 +1468,7 @@ public class SubscriptionController extends ISub.Stub {
            // Only re-map modems if the new default data sub is valid
            RadioAccessFamily[] rafs = new RadioAccessFamily[len];
            boolean atLeastOneMatch = false;
            int slotId = PhoneConstants.DEFAULT_CARD_INDEX;
            for (int phoneId = 0; phoneId < len; phoneId++) {
                Phone phone = sPhones[phoneId];
                int raf;
@@ -1476,6 +1477,7 @@ public class SubscriptionController extends ISub.Stub {
                    // TODO Handle the general case of N modems and M subscriptions.
                    raf = proxyController.getMaxRafSupported();
                    atLeastOneMatch = true;
                    slotId = phoneId;
                } else {
                    // TODO Handle the general case of N modems and M subscriptions.
                    raf = proxyController.getMinRafSupported();
@@ -1485,6 +1487,9 @@ public class SubscriptionController extends ISub.Stub {
            }
            if (atLeastOneMatch) {
                proxyController.setRadioCapability(rafs);
                if (!SystemProperties.getBoolean("ro.ril.multi_rat_capable", true)) {
                     updateDataSubNetworkType(slotId, subId);
                }
            } else {
                if (DBG) logdl("[setDefaultDataSubId] no valid subId's found - not updating.");
            }
@@ -1498,6 +1503,13 @@ public class SubscriptionController extends ISub.Stub {
        broadcastDefaultDataSubIdChanged(subId);
    }

    private void updateDataSubNetworkType(int slotId, int subId) {
        SubscriptionInfoUpdater subscriptionInfoUpdater = PhoneFactory.getSubscriptionInfoUpdater();
        if (subscriptionInfoUpdater != null) {
            subscriptionInfoUpdater.setDefaultDataSubNetworkType(slotId, subId);
        }
    }

    private void updateAllDataConnectionTrackers() {
        // Tell Phone Proxies to update data connection tracker
        int len = sPhones.length;
+27 −6
Original line number Diff line number Diff line
@@ -78,6 +78,7 @@ public class SubscriptionInfoUpdater extends Handler {
    private static final int EVENT_SIM_IO_ERROR = 6;
    private static final int EVENT_SIM_UNKNOWN = 7;
    private static final int EVENT_SIM_RESTRICTED = 8;
    private static final int EVENT_SET_PREFERRED_NW_MODE = 9;

    private static final String ICCID_STRING_FOR_NO_SIM = "";
    private static final String ICCID_STRING_FOR_NV = "DUMMY_NV_ID";
@@ -291,6 +292,18 @@ public class SubscriptionInfoUpdater extends Handler {
        }
    }

    static class SetPreferredNwModeMessage {
        public int slotId;
        public int subId;
        public int networkType;

        SetPreferredNwModeMessage(int slotId, int subId, int networkType) {
            this.slotId = slotId;
            this.subId = subId;
            this.networkType = networkType;
        }
    }

    @Override
    public void handleMessage(Message msg) {
        switch (msg.what) {
@@ -361,6 +374,12 @@ public class SubscriptionInfoUpdater extends Handler {
                updateCarrierServices(msg.arg1, IccCardConstants.INTENT_VALUE_ICC_CARD_RESTRICTED);
                break;

            case EVENT_SET_PREFERRED_NW_MODE:
                AsyncResult ar = (AsyncResult)msg.obj;
                SetPreferredNwModeMessage mode = (SetPreferredNwModeMessage) ar.userObj;
                setPreferredNwModeForSlot(mode.slotId, mode.subId, mode.networkType, null);
                break;

            default:
                logd("Unknown msg:" + msg.what);
        }
@@ -492,7 +511,7 @@ public class SubscriptionInfoUpdater extends Handler {
        updateCarrierServices(slotId, IccCardConstants.INTENT_VALUE_ICC_LOADED);
    }

    private void setDefaultDataSubNetworkType(int slotId, int subId) {
    public void setDefaultDataSubNetworkType(int slotId, int subId) {
        if (subId == SubscriptionManager.DEFAULT_SUBSCRIPTION_ID) {
            Rlog.e(LOG_TAG, "setDefaultDataSubNetworkType called with DEFAULT_SUB_ID");
            return;
@@ -553,11 +572,12 @@ public class SubscriptionInfoUpdater extends Handler {
                            + networkType2 + ", slotId2: " + slotId2);
                }
            }
            setPreferredNwModeForSlot(slotId1, subId1, networkType);
            setPreferredNwModeForSlot(slotId2, subId2, networkType2);
            Message continuation = obtainMessage(EVENT_SET_PREFERRED_NW_MODE,
                    new SetPreferredNwModeMessage(slotId1, subId1, networkType));
            setPreferredNwModeForSlot(slotId2, subId2, networkType2, continuation);
        } else {
            // Set the modem network mode
            setPreferredNwModeForSlot(slotId, subId, networkType);
            setPreferredNwModeForSlot(slotId, subId, networkType, null);
        }

        // Only support automatic selection mode on SIM change.
@@ -565,8 +585,9 @@ public class SubscriptionInfoUpdater extends Handler {
                obtainMessage(EVENT_GET_NETWORK_SELECTION_MODE_DONE, new Integer(slotId)));
    }

    private void setPreferredNwModeForSlot(int slotId, int subId, int networkType) {
        mPhone[slotId].setPreferredNetworkType(networkType, null);
    private void setPreferredNwModeForSlot(int slotId, int subId, int networkType,
            Message message) {
        mPhone[slotId].setPreferredNetworkType(networkType, message);
        Settings.Global.putInt(mPhone[slotId].getContext().getContentResolver(),
                Settings.Global.PREFERRED_NETWORK_MODE + subId,
                networkType);