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

Commit ac5bd144 authored by Android (Google) Code Review's avatar Android (Google) Code Review
Browse files

Merge change Ib23e57cf into eclair

* changes:
  Set roaming based on both data and voice.
parents b0702880 37b80ee4
Loading
Loading
Loading
Loading
+9 −34
Original line number Diff line number Diff line
@@ -351,7 +351,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
     * @return false while no data connection if all above requirements are met.
     */
    public boolean isDataConnectionAsDesired() {
        boolean roaming = getDataRoaming();
        boolean roaming = phone.getServiceState().getRoaming();

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

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

    @Override
    protected boolean isApnTypeActive(String type) {
        // TODO: support simultaneous with List instead
@@ -394,7 +390,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
    }

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

@@ -441,7 +437,6 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
        }

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

        if ((state == State.IDLE || state == State.SCANNING)
@@ -477,7 +472,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
                    " phoneState=" + phone.getState() +
                    " isDataAllowed=" + isDataAllowed() +
                    " dataEnabled=" + getAnyDataEnabled() +
                    " roaming=" + roaming +
                    " roaming=" + phone.getServiceState().getRoaming() +
                    " dataOnRoamingEnable=" + getDataOnRoamingEnabled() +
                    " ps restricted=" + mIsPsRestricted +
                    " desiredPowerState=" + desiredPowerState);
@@ -1112,39 +1107,19 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
        return trySetupData(reason);
    }

    /**
     * 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() {
+24 −24
Original line number Diff line number Diff line
@@ -83,12 +83,17 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
    private int networkType = 0;
    private int newNetworkType = 0;

    /** GSM roaming status solely based on TS 27.007 7.2 CREG. */
    /**
     * GSM roaming status solely based on TS 27.007 7.2 CREG. Only used by
     * handlePollStateResult to store CREG roaming result.
     */
    private boolean mGsmRoaming = false;

    /** Data roaming status solely based on TS 27.007 10.1.19 CGREG. */
    /**
     * Data roaming status solely based on TS 27.007 10.1.19 CGREG. Only used by
     * handlePollStateResult to store CGREG roaming result.
     */
    private boolean mDataRoaming = false;
    private boolean newDataRoaming = false;

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

    boolean getDataRoaming() {
        return mDataRoaming;
    }

    public void handleMessage (Message msg) {
        AsyncResult ar;
        int[] ints;
@@ -627,7 +628,6 @@ final class GsmServiceStateTracker extends ServiceStateTracker {

                    mGsmRoaming = regCodeIsRoaming(regState);
                    newSS.setState (regCodeToServiceState(regState));

                    // LAC and CID are -1 if not avail
                    newCellLoc.setLacAndCid(lac, cid);
                break;
@@ -650,7 +650,7 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
                        }
                    }
                    newGPRSState = regCodeToServiceState(regState);
                    newDataRoaming = regCodeIsRoaming(regState);
                    mDataRoaming = regCodeIsRoaming(regState);
                    newNetworkType = type;
                    newSS.setRadioTechnology(type);
                break;
@@ -678,15 +678,22 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
        pollingContext[0]--;

        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;
            /**
             *  Since the roaming states of gsm service (from +CREG) and
             *  data service (from +CGREG) could be different, the new SS
             *  is set roaming while either one is roaming.
             *
             *  There is an exception for the above rule. The new SS is not set
             *  as roaming while gsm service reports roaming but indeed it is
             *  not roaming between operators.
             */
            boolean roaming = (mGsmRoaming || mDataRoaming);
            if (mGsmRoaming && !isRoamingBetweenOperators(mGsmRoaming, newSS)) {
                roaming = false;
            }
            newSS.setRoaming(roaming);
            pollStateDone();
        }

    }

    private void setSignalStrengthDefaultValues() {
@@ -711,8 +718,6 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
                newCellLoc.setStateInvalid();
                setSignalStrengthDefaultValues();
                mGotCountryCode = false;
                newDataRoaming = false;

                pollStateDone();
            break;

@@ -721,8 +726,6 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
                newCellLoc.setStateInvalid();
                setSignalStrengthDefaultValues();
                mGotCountryCode = false;
                newDataRoaming = false;

                pollStateDone();
            break;

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

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

        boolean hasChanged = !newSS.equals(ss);

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

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

        boolean hasLocationChanged = !newCellLoc.equals(cellLoc);

@@ -849,7 +850,6 @@ final class GsmServiceStateTracker extends ServiceStateTracker {

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

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