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

Commit 8c6b883c authored by John Wang's avatar John Wang
Browse files

Use dataRoaming in dataConnectionTracker.

Seperate dataRoaming from gsmRoaming. dataRoaming is based on +CGREG returns in GSM while gsmRoaming is based on +CREG returns. Previously, the status of dataRoaming is always treated the same as gsmRoaming. However there is a situation where +CREG returns 0 and +CGREG returns 5, i.e., gsmRoaming is off and dataRoaming is on. In such situation, the phone should setup data connection if the phone enables data service when roaming (for example, data only card). The phone shouldn't setup data connection if the phone disable data service when roaming (to prevent roaming data charge). So gsmDataConnectionTracker should use dataRoaming instead of gsmRoaming to decide if data service allowed.

	modified:   GsmDataConnectionTracker.java
	modified:   GsmServiceStateTracker.java
parent 4431a065
Loading
Loading
Loading
Loading
+35 −9
Original line number Diff line number Diff line
@@ -412,7 +412,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
     * @return false while no data connection if all above requirements are met.
     */
    public boolean isDataConnectionAsDesired() {
        boolean roaming = phone.getServiceState().getRoaming();
        boolean roaming = getDataRoaming();

        if (mGsmPhone.mSIMRecords.getRecordsLoaded() &&
                mGsmPhone.mSST.getCurrentGprsState() == ServiceState.STATE_IN_SERVICE &&
@@ -424,6 +424,10 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
        return true;
    }

    private boolean getDataRoaming() {
        return mGsmPhone.mSST.getDataRoaming();
    }

    private boolean isApnTypeActive(String type) {
        // TODO: to support simultaneous, mActiveApn can be a List instead.
        return mActiveApn != null && mActiveApn.canHandleType(type);
@@ -533,7 +537,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
    }

    private boolean isDataAllowed() {
        boolean roaming = phone.getServiceState().getRoaming();
        boolean roaming = getDataRoaming();
        return getAnyDataEnabled() && (!roaming || getDataOnRoamingEnabled());
    }

@@ -580,7 +584,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
        }

        int gprsState = mGsmPhone.mSST.getCurrentGprsState();
        boolean roaming = phone.getServiceState().getRoaming();
        boolean roaming = getDataRoaming();
        boolean desiredPowerState = mGsmPhone.mSST.getDesiredPowerState();

        if ((state == State.IDLE || state == State.SCANNING)
@@ -1245,17 +1249,39 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
        }
    }

    /**
     * Check the data roaming consistency since this can be triggered by
     * voice roaming flag of ServiceState in setDataOnRoamingEnabled()
     *
     * TODO make this triggered by data roaming state only
     */
    @Override
    protected void onRoamingOff() {
        if (!getDataRoaming()) { //data roaming is off
            trySetupData(Phone.REASON_ROAMING_OFF);
        } else { // Inconsistent! data roaming is on
            sendMessage(obtainMessage(EVENT_ROAMING_ON));
        }
    }

    /**
     * Check the data roaming consistency since this can be triggered by
     * voice roaming flag of ServiceState in setDataOnRoamingEnabled()
     *
     * TODO make this triggered by data roaming state only
     */
    @Override
    protected void onRoamingOn() {
        if (getDataRoaming()) { // data roaming is on
            if (getDataOnRoamingEnabled()) {
                trySetupData(Phone.REASON_ROAMING_ON);
            } else {
                if (DBG) log("Tear down data connection on roaming.");
                cleanUpConnection(true, Phone.REASON_ROAMING_ON);
            }
        } else { // Inconsistent! data roaming is off
            sendMessage(obtainMessage(EVENT_ROAMING_OFF));
        }
    }

    protected void onRadioAvailable() {
+20 −2
Original line number Diff line number Diff line
@@ -88,6 +88,9 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
    private int newNetworkType = 0;
    /* gsm roaming status solely based on TS 27.007 7.2 CREG */
    private boolean mGsmRoaming = false;
    /* data roaming status solely based on TS 27.007 10.1.19 CGREG */
    private boolean mDataRoaming = false;
    private boolean newDataRoaming = false;

    private RegistrantList gprsAttachedRegistrants = new RegistrantList();
    private RegistrantList gprsDetachedRegistrants = new RegistrantList();
@@ -309,6 +312,10 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
        psRestrictDisabledRegistrants.remove(h);
    }

    /*protected*/ boolean getDataRoaming() {
        return mDataRoaming;
    }

    //***** Called from GSMPhone
    public void
    getLacAndCid(Message onComplete) {
@@ -666,6 +673,7 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
                        }
                    }
                    newGPRSState = regCodeToServiceState(regState);
                    newDataRoaming = regCodeIsRoaming(regState);
                    newNetworkType = type;
                break;

@@ -693,6 +701,11 @@ final class GsmServiceStateTracker extends ServiceStateTracker {

        if (pollingContext[0] == 0) {
            newSS.setRoaming(isRoamingBetweenOperators(mGsmRoaming, newSS));
            // when both roaming indicators are true but not roaming between
            // operators, roaming should set to false.
            if (newDataRoaming && mGsmRoaming && !newSS.getRoaming()) {
                newDataRoaming = false;
            }
            pollStateDone();
        }

@@ -722,6 +735,7 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
                newCellLoc.setStateInvalid();
                setSignalStrengthDefaultValues();
                mGotCountryCode = false;
                newDataRoaming = false;

                pollStateDone();
            break;
@@ -731,6 +745,7 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
                newCellLoc.setStateInvalid();
                setSignalStrengthDefaultValues();
                mGotCountryCode = false;
                newDataRoaming = false;

                pollStateDone();
            break;
@@ -745,6 +760,8 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
                newCellLoc.setStateInvalid();
                setSignalStrengthDefaultValues();
                mGotCountryCode = false;
                newDataRoaming = false;
                mDataRoaming = false;

                //NOTE: pollStateDone() is not needed in this case
                break;
@@ -829,9 +846,9 @@ final class GsmServiceStateTracker extends ServiceStateTracker {

        boolean hasChanged = !newSS.equals(ss);

        boolean hasRoamingOn = !ss.getRoaming() && newSS.getRoaming();
        boolean hasRoamingOn = !mDataRoaming && newDataRoaming;

        boolean hasRoamingOff = ss.getRoaming() && !newSS.getRoaming();
        boolean hasRoamingOff = mDataRoaming && !newDataRoaming;

        boolean hasLocationChanged = !newCellLoc.equals(cellLoc);

@@ -848,6 +865,7 @@ final class GsmServiceStateTracker extends ServiceStateTracker {

        gprsState = newGPRSState;
        networkType = newNetworkType;
        mDataRoaming = newDataRoaming;

        newSS.setStateOutOfService(); // clean slate for next time