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

Commit ce87d60a authored by Yashdev Singh's avatar Yashdev Singh Committed by Linux Build Service Account
Browse files

Telephony: Allow setDefaultDataSubId to be called multiple times

- Allow setDefaultDataSubId() to be called on same subscription
multiple times without causing PS DETACH on that sub.
- Call setDefaultDataSubid() after bootup.
- Inform OemHookDdsService about default DDS even during on-demand
PS attach requests.

Conflicts:
        src/java/com/android/internal/telephony/dataconnection/DctController.java

Change-Id: I7e40998e1ff239e2cd6360568d217b801a475da9
parent 587465dc
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import com.android.internal.util.Protocol;
import com.android.internal.util.State;
import com.android.internal.util.StateMachine;

import com.android.internal.telephony.SubscriptionController;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.PhoneBase;
@@ -163,7 +164,11 @@ public class DcSwitchState extends StateMachine {
                    }

                    PhoneBase pb = (PhoneBase)((PhoneProxy)mPhone).getActivePhone();
                    pb.mCi.setDataAllowed(true, null);
                    long subId = pb.getSubId();
                    SubscriptionController subscriptionController
                        = SubscriptionController.getInstance();
                    log("Setting default DDS on " + subId);
                    subscriptionController.setDefaultDataSubId(subId);

                    int result = setupConnection(type);
                    if (msg.what == DcSwitchAsyncChannel.REQ_CONNECT) {
+37 −15
Original line number Diff line number Diff line
@@ -73,6 +73,7 @@ public class DctController extends Handler {
    private static final int EVENT_ALL_DATA_DISCONNECTED = 1;
    private static final int EVENT_SET_DATA_ALLOW_DONE = 2;
    private static final int EVENT_DELAYED_RETRY = 3;
    private static final int EVENT_LEGACY_SET_DATA_SUBSCRIPTION = 4;

    private RegistrantList mNotifyDefaultDataSwitchInfo = new RegistrantList();
    private RegistrantList mNotifyOnDemandDataSwitchInfo = new RegistrantList();
@@ -497,9 +498,19 @@ public class DctController extends Handler {
        }
    }

    private void doDetach(int phoneId) {
        Phone phone = mPhones[phoneId].getActivePhone();
        DcTrackerBase dcTracker =((PhoneBase)phone).mDcTracker;
        dcTracker.setDataAllowed(false, null);
        if (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA) {
            //cleanup data from apss as there is no detach procedure for CDMA
            dcTracker.cleanUpAllConnections("DDS switch");
        }
    }
    public void setDefaultDataSubId(long subId) {
        Rlog.d(LOG_TAG, "setDataAllowed subId :" + subId);
        Rlog.d(LOG_TAG, "setDefaultDataSubId subId :" + subId);
        int phoneId = mSubController.getPhoneId(subId);
        SwitchInfo s = new SwitchInfo(new Integer(phoneId), true);
        int prefPhoneId = mSubController.getPhoneId(mSubController.getCurrentDds());
        if (prefPhoneId < 0 || prefPhoneId >= mPhoneNum) {
            // If Current dds subId is invalid set the received subId as curretn DDS
@@ -512,18 +523,31 @@ public class DctController extends Handler {
            return;
        }

        Phone phone = mPhones[prefPhoneId].getActivePhone();
        DcTrackerBase dcTracker =((PhoneBase)phone).mDcTracker;
        dcTracker.setDataAllowed(false, null);
        if (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA) {
            //cleanup data from apss as there is no detach procedure for CDMA
            dcTracker.cleanUpAllConnections("DDS switch");
        if (subId != mSubController.getDefaultDataSubId()) {
            doDetach(prefPhoneId);
        } else {
            logd("setDefaultDataSubId for default DDS, skip PS detach on DDS subs");
            sendMessage(obtainMessage(EVENT_LEGACY_SET_DATA_SUBSCRIPTION,
                        new AsyncResult(s, null, null)));
            return;
        }
        SwitchInfo s = new SwitchInfo(new Integer(phoneId), true);

        mPhones[prefPhoneId].registerForAllDataDisconnected(
                this, EVENT_ALL_DATA_DISCONNECTED, s);
    }

    private void informDefaultDdsToPropServ(int defDdsPhoneId) {
        if (mDdsSwitchPropService != null) {
            logd("Inform OemHookDDS service of current DDS = " + defDdsPhoneId);
            mDdsSwitchPropService.sendMessageSynchronously(1, defDdsPhoneId,
                    mPhoneNum);
            logd("OemHookDDS service finished");
        } else {
            logd("OemHookDds service not ready yet");
        }

    }

    public void doPsAttach(NetworkRequest n) {
        Rlog.d(LOG_TAG, "doPsAttach for :" + n);

@@ -540,6 +564,8 @@ public class DctController extends Handler {
        Message psAttachDone = Message.obtain(this,
                EVENT_SET_DATA_ALLOW_DONE, s);

        int defDdsPhoneId = getDataConnectionFromSetting();
        informDefaultDdsToPropServ(defDdsPhoneId);
        dcTracker.setDataAllowed(true, psAttachDone);
    }

@@ -592,6 +618,8 @@ public class DctController extends Handler {
            Rlog.d(LOG_TAG, "handleMessage msg=" + msg);

            switch (msg.what) {
                case EVENT_LEGACY_SET_DATA_SUBSCRIPTION:
                    //intentional fall through, no break.
                case EVENT_ALL_DATA_DISCONNECTED: {
                    AsyncResult ar = (AsyncResult)msg.obj;
                    SwitchInfo s = (SwitchInfo)ar.userObj;
@@ -604,13 +632,7 @@ public class DctController extends Handler {
                            EVENT_SET_DATA_ALLOW_DONE, s);
                    Phone phone = mPhones[phoneId].getActivePhone();

                    if (mDdsSwitchPropService != null) {

                        logd("Request OemHookDDS service for DDS switch");
                        mDdsSwitchPropService.sendMessageSynchronously(1, phoneId,
                                mPhoneNum);
                        logd("OemHookDDS service finished");
                    }
                    informDefaultDdsToPropServ(phoneId);

                    DcTrackerBase dcTracker =((PhoneBase)phone).mDcTracker;
                    dcTracker.setDataAllowed(true, allowedDataDone);