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

Commit 2802dda8 authored by Wink Saville's avatar Wink Saville Committed by Android (Google) Code Review
Browse files

Merge "Remove mRetryMgr and directly use DataConnection retry mgr."

parents a36d360c 89586a7d
Loading
Loading
Loading
Loading
+82 −12
Original line number Diff line number Diff line
@@ -219,10 +219,8 @@ public abstract class DataConnection extends HierarchicalStateMachine {
    protected static final int EVENT_LOG_BAD_DNS_ADDRESS = 50100;

    //***** Member Variables
    protected int mId;
    protected int mTag;
    protected PhoneBase phone;
    protected RetryManager mRetryMgr;
    protected int cid;
    protected LinkProperties mLinkProperties = new LinkProperties();
    protected LinkCapabilities mCapabilities = new LinkCapabilities();
@@ -244,10 +242,11 @@ public abstract class DataConnection extends HierarchicalStateMachine {


   //***** Constructor
    protected DataConnection(PhoneBase phone, String name, RetryManager rm) {
    protected DataConnection(PhoneBase phone, String name, int id, RetryManager rm) {
        super(name);
        if (DBG) log("DataConnection constructor E");
        this.phone = phone;
        mId = id;
        mRetryMgr = rm;
        this.cid = -1;
        clearSettings();
@@ -342,10 +341,88 @@ public abstract class DataConnection extends HierarchicalStateMachine {
        clearSettings();
    }

    public RetryManager getRetryMgr() {
        return mRetryMgr;
    /*
     * **************************************************************************
     * Begin Members and methods owned by DataConnectionTracker but stored
     * in a DataConnection because there is one per connection.
     * **************************************************************************
     */

    /*
     * The id is owned by DataConnectionTracker.
     */
    private int mId;

    /**
     * Get the DataConnection ID
     */
    public int getDataConnectionId() {
        return mId;
    }

    /*
     * The retry manager is currently owned by the DataConnectionTracker but is stored
     * in the DataConnection because there is one per connection. These methods
     * should only be used by the DataConnectionTracker although someday the retrying
     * maybe managed by the DataConnection itself and these methods could disappear.
     */
    private RetryManager mRetryMgr;

    /**
     * @return retry manager retryCount
     */
    public int getRetryCount() {
        return mRetryMgr.getRetryCount();
    }

    /**
     * @return retry manager retryTimer
     */
    public int getRetryTimer() {
        return mRetryMgr.getRetryTimer();
    }

    /**
     * increaseRetryCount of retry manager
     */
    public void increaseRetryCount() {
        mRetryMgr.increaseRetryCount();
    }

    /**
     * @return retry manager isRetryNeeded
     */
    public boolean isRetryNeeded() {
        return mRetryMgr.isRetryNeeded();
    }

    /**
     * resetRetryCount of retry manager
     */
    public void resetRetryCount() {
        mRetryMgr.resetRetryCount();
    }

    /**
     * set retryForeverUsingLasttimeout of retry manager
     */
    public void retryForeverUsingLastTimeout() {
        mRetryMgr.retryForeverUsingLastTimeout();
    }

    /**
     * @return retry manager isRetryForever
     */
    public boolean isRetryForever() {
        return mRetryMgr.isRetryForever();
    }

    /*
     * **************************************************************************
     * End members owned by DataConnectionTracker
     * **************************************************************************
     */

    /**
     * Clear all settings called when entering mInactiveState.
     */
@@ -963,13 +1040,6 @@ public abstract class DataConnection extends HierarchicalStateMachine {
        return retVal;
    }

    /**
     * Get the DataConnection ID
     */
    public int getDataConnectionId() {
        return mId;
    }

    /**
     * Return the LinkProperties for the connection.
     *
+10 −7
Original line number Diff line number Diff line
@@ -209,9 +209,6 @@ public abstract class DataConnectionTracker extends Handler {
    protected int mNoRecvPollCount = 0;
    protected boolean mNetStatPollEnabled = false;

    /** Manage the behavior of data retry after failure (TODO: One per connection in the future?) */
    protected RetryManager mRetryMgr = new RetryManager();

    // wifi connection status will be updated by sticky intent
    protected boolean mIsWifiConnected = false;

@@ -397,7 +394,7 @@ public abstract class DataConnectionTracker extends Handler {
                Settings.Secure.DATA_ROAMING, enabled ? 1 : 0);
            if (mPhone.getServiceState().getRoaming()) {
                if (enabled) {
                    mRetryMgr.resetRetryCount();
                    resetAllRetryCounts();
                }
                sendMessage(obtainMessage(EVENT_ROAMING_ON));
            }
@@ -449,7 +446,7 @@ public abstract class DataConnectionTracker extends Handler {

            case EVENT_ROAMING_OFF:
                if (getDataOnRoamingEnabled() == false) {
                    mRetryMgr.resetRetryCount();
                    resetAllRetryCounts();
                }
                onRoamingOff();
                break;
@@ -883,7 +880,7 @@ public abstract class DataConnectionTracker extends Handler {
            }
            if (prevEnabled != getAnyDataEnabled()) {
                if (!prevEnabled) {
                    mRetryMgr.resetRetryCount();
                    resetAllRetryCounts();
                    onTrySetupData(Phone.REASON_DATA_ENABLED);
                } else {
                    cleanUpAllConnections();
@@ -917,7 +914,7 @@ public abstract class DataConnectionTracker extends Handler {
                    Settings.Secure.MOBILE_DATA, enable ? 1 : 0);
            if (prevEnabled != getAnyDataEnabled()) {
                if (!prevEnabled) {
                    mRetryMgr.resetRetryCount();
                    resetAllRetryCounts();
                    onTrySetupData(Phone.REASON_DATA_ENABLED);
                } else {
                    onCleanUpConnection(true, APN_DEFAULT_ID, Phone.REASON_DATA_DISABLED);
@@ -925,4 +922,10 @@ public abstract class DataConnectionTracker extends Handler {
            }
        }
    }

    protected void resetAllRetryCounts() {
        for (DataConnection dc : mDataConnections.values()) {
            dc.resetRetryCount();
        }
    }
}
+4 −5
Original line number Diff line number Diff line
@@ -33,8 +33,8 @@ public class CdmaDataConnection extends DataConnection {
    private static final String LOG_TAG = "CDMA";

    // ***** Constructor
    private CdmaDataConnection(CDMAPhone phone, String name, RetryManager rm) {
        super(phone, name, rm);
    private CdmaDataConnection(CDMAPhone phone, String name, int id, RetryManager rm) {
        super(phone, name, id, rm);
    }

    /**
@@ -49,11 +49,10 @@ public class CdmaDataConnection extends DataConnection {
        synchronized (mCountLock) {
            mCount += 1;
        }
        CdmaDataConnection cdmaDc = new CdmaDataConnection(phone,
                "CdmaDataConnection-" + mCount, rm);
        CdmaDataConnection cdmaDc = new CdmaDataConnection(phone, "CdmaDataConnection-" + mCount,
                id, rm);
        cdmaDc.start();
        if (DBG) cdmaDc.log("Made " + cdmaDc.getName());
        cdmaDc.mId = id;
        return cdmaDc;
    }

+8 −8
Original line number Diff line number Diff line
@@ -328,7 +328,7 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
        setState(State.CONNECTED);
        notifyDataConnection(reason);
        startNetStatPoll();
        mRetryMgr.resetRetryCount();
        mDataConnections.get(0).resetRetryCount();
    }

    private void resetPollStats() {
@@ -478,7 +478,7 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
             * at the last time until the state is changed.
             * TODO: Make this configurable?
             */
            int nextReconnectDelay = mRetryMgr.getRetryTimer();
            int nextReconnectDelay = mDataConnections.get(0).getRetryTimer();
            log("Data Connection activate failed. Scheduling next attempt for "
                    + (nextReconnectDelay / 1000) + "s");

@@ -492,7 +492,7 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
                    SystemClock.elapsedRealtime() + nextReconnectDelay,
                    mReconnectIntent);

            mRetryMgr.increaseRetryCount();
            mDataConnections.get(0).increaseRetryCount();

            if (!shouldPostNotification(lastFailCauseCode)) {
                log("NOT Posting Data Connection Unavailable notification "
@@ -593,7 +593,7 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
     */
    @Override
    protected void onRadioOffOrNotAvailable() {
        mRetryMgr.resetRetryCount();
        mDataConnections.get(0).resetRetryCount();

        if (mPhone.getSimulatedRadioControl() != null) {
            // Assume data is connected on the simulator
@@ -708,7 +708,7 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
            }
            notifyDataAvailability(Phone.REASON_VOICE_CALL_ENDED);
        } else {
            mRetryMgr.resetRetryCount();
            mDataConnections.get(0).resetRetryCount();
            // in case data setup was attempted when we were on a voice call
            trySetupData(Phone.REASON_VOICE_CALL_ENDED);
        }
@@ -730,7 +730,7 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
        CdmaDataConnection dataConn;

        /** TODO: Use one retry manager for all connections for now */
        RetryManager rm = mRetryMgr;
        RetryManager rm = new RetryManager();
        if (!rm.configure(SystemProperties.get("ro.cdma.data_retry_config"))) {
            if (!rm.configure(DEFAULT_DATA_RETRY_CONFIG)) {
                // Should never happen, log an error and default to a simple linear sequence.
@@ -761,7 +761,7 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
        } else {
            if (mState == State.FAILED) {
                cleanUpConnection(false, Phone.REASON_CDMA_DATA_DETACHED);
                mRetryMgr.resetRetryCount();
                mDataConnections.get(0).resetRetryCount();

                CdmaCellLocation loc = (CdmaCellLocation)(mPhone.getCellLocation());
                EventLog.writeEvent(EventLogTags.CDMA_DATA_SETUP_FAILED,
@@ -779,7 +779,7 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
                switch (otaPrivision[0]) {
                case Phone.CDMA_OTA_PROVISION_STATUS_COMMITTED:
                case Phone.CDMA_OTA_PROVISION_STATUS_OTAPA_STOPPED:
                    mRetryMgr.resetRetryCount();
                    mDataConnections.get(0).resetRetryCount();
                    break;
                default:
                    break;
+4 −5
Original line number Diff line number Diff line
@@ -41,8 +41,8 @@ public class GsmDataConnection extends DataConnection {
    protected int mProfileId = RILConstants.DATA_PROFILE_DEFAULT;
    protected String mActiveApnType = Phone.APN_TYPE_DEFAULT;
    //***** Constructor
    private GsmDataConnection(PhoneBase phone, String name, RetryManager rm) {
        super(phone, name, rm);
    private GsmDataConnection(PhoneBase phone, String name, int id, RetryManager rm) {
        super(phone, name, id, rm);
    }

    /**
@@ -57,11 +57,10 @@ public class GsmDataConnection extends DataConnection {
        synchronized (mCountLock) {
            mCount += 1;
        }
        GsmDataConnection gsmDc = new GsmDataConnection(phone, "GsmDataConnection-" + mCount, rm);
        GsmDataConnection gsmDc = new GsmDataConnection(phone, "GsmDataConnection-" + mCount,
                id, rm);
        gsmDc.start();
        if (DBG) gsmDc.log("Made " + gsmDc.getName());
        gsmDc.mId = id;
        gsmDc.mRetryMgr = rm;
        return gsmDc;
    }

Loading