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

Commit 59471260 authored by Junda Liu's avatar Junda Liu Committed by android-build-merger
Browse files

DO NOT MERGE If set data profile with roaming protocol, set back to home when roaming off.

am: 4b17d6f8

Change-Id: I7ff89e4f2f389cf27377630664749988124ceef6
parents fccef9a1 4b17d6f8
Loading
Loading
Loading
Loading
+27 −11
Original line number Original line Diff line number Diff line
@@ -613,6 +613,15 @@ public class DcTracker extends Handler {
     *  undesired network load */
     *  undesired network load */
    private boolean mMeteredApnDisabled = false;
    private boolean mMeteredApnDisabled = false;


    /**
     * int to remember whether has setDataProfiles and with roaming or not.
     * 0: default, has never set data profile
     * 1: has set data profile with home protocol
     * 2: has set data profile with roaming protocol
     * This is not needed once RIL command is updated to support both home and roaming protocol.
     */
    private int mSetDataProfileStatus = 0;

    /**
    /**
     * Handles changes to the APN db.
     * Handles changes to the APN db.
     */
     */
@@ -2766,6 +2775,10 @@ public class DcTracker extends Handler {


        if (!mDataEnabledSettings.isUserDataEnabled()) return;
        if (!mDataEnabledSettings.isUserDataEnabled()) return;


        // Note onRoamingOff will be called immediately when DcTracker registerForDataRoamingOff,
        // and will be called again if SST calls mDataRoamingOffRegistrants.notify().
        setDataProfilesAsNeeded();

        if (getDataOnRoamingEnabled() == false) {
        if (getDataOnRoamingEnabled() == false) {
            notifyOffApnsOfAvailability(Phone.REASON_ROAMING_OFF);
            notifyOffApnsOfAvailability(Phone.REASON_ROAMING_OFF);
            setupDataOnConnectableApns(Phone.REASON_ROAMING_OFF);
            setupDataOnConnectableApns(Phone.REASON_ROAMING_OFF);
@@ -3299,27 +3312,29 @@ public class DcTracker extends Handler {
    }
    }


    private void setDataProfilesAsNeeded() {
    private void setDataProfilesAsNeeded() {
        if (DBG) log("setDataProfilesAsNeeded");
        if (DBG) log("setDataProfilesAsNeeded mSetDataProfileStatus: " + mSetDataProfileStatus);
        if (mAllApnSettings != null && !mAllApnSettings.isEmpty()) {
        if (mAllApnSettings != null && !mAllApnSettings.isEmpty()) {
            ArrayList<DataProfile> dps = new ArrayList<DataProfile>();
            ArrayList<DataProfile> dps = new ArrayList<DataProfile>();
            // Note getDataRoaming is also false if data not registered
            boolean isRoaming = mPhone.getServiceState().getDataRoaming();
            // If has set profile with home, and isRoaming is also false, no need to resend
            // Also skip if has set profile with roaming and isRoaming is true.
            if ((mSetDataProfileStatus == 1 && !isRoaming) ||
                (mSetDataProfileStatus == 2 && isRoaming)) {
                return;
            }
            for (ApnSetting apn : mAllApnSettings) {
            for (ApnSetting apn : mAllApnSettings) {
                if (apn.modemCognitive) {
                if (apn.modemCognitive) {
                    DataProfile dp = new DataProfile(apn,
                    DataProfile dp = new DataProfile(apn, isRoaming);
                            mPhone.getServiceState().getDataRoaming());
                    // ArrayList.contains will call object.equals
                    boolean isDup = false;
                    if (!dps.contains(dp)) {
                    for(DataProfile dpIn : dps) {
                        if (dp.equals(dpIn)) {
                            isDup = true;
                            break;
                        }
                    }
                    if (!isDup) {
                        dps.add(dp);
                        dps.add(dp);
                    }
                    }
                }
                }
            }
            }
            if(dps.size() > 0) {
            if(dps.size() > 0) {
                mPhone.mCi.setDataProfile(dps.toArray(new DataProfile[0]), null);
                mPhone.mCi.setDataProfile(dps.toArray(new DataProfile[0]), null);
                mSetDataProfileStatus = isRoaming ? 2 : 1;
            }
            }
        }
        }
    }
    }
@@ -4234,6 +4249,7 @@ public class DcTracker extends Handler {
        pw.println(" mAutoAttachOnCreation=" + mAutoAttachOnCreation.get());
        pw.println(" mAutoAttachOnCreation=" + mAutoAttachOnCreation.get());
        pw.println(" mIsScreenOn=" + mIsScreenOn);
        pw.println(" mIsScreenOn=" + mIsScreenOn);
        pw.println(" mUniqueIdGenerator=" + mUniqueIdGenerator);
        pw.println(" mUniqueIdGenerator=" + mUniqueIdGenerator);
        pw.println(" mSetDataProfileStatus=" + mSetDataProfileStatus);
        pw.flush();
        pw.flush();
        pw.println(" ***************************************");
        pw.println(" ***************************************");
        DcController dcc = mDcc;
        DcController dcc = mDcc;