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

Commit d649887a authored by Wink Saville's avatar Wink Saville Committed by Android Git Automerger
Browse files

am eb8da0fe: Merge "Fix issue on infinite retry config in RetryManager" into honeycomb-LTE

* commit 'eb8da0fe':
  Fix issue on infinite retry config in RetryManager
parents d1736a3d eb8da0fe
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -394,6 +394,20 @@ public abstract class DataConnection extends StateMachine {
        return mRetryMgr.isRetryForever();
    }

    /**
     * @return whether the retry config is set successfully or not
     */
    public boolean configureRetry(int maxRetryCount, int retryTime, int randomizationTime) {
        return mRetryMgr.configure(maxRetryCount, retryTime, randomizationTime);
    }

    /**
     * @return whether the retry config is set successfully or not
     */
    public boolean configureRetry(String configStr) {
        return mRetryMgr.configure(configStr);
    }

    private AtomicInteger mRefCount = new AtomicInteger(0);

    /**
+1 −3
Original line number Diff line number Diff line
@@ -308,12 +308,10 @@ public class RetryManager {
    }

    /**
     * Reset network re-registration indicator and clear the data-retry counter
     * and turns off retrying forever.
     * Clear the data-retry counter
     */
    public void resetRetryCount() {
        mRetryCount = 0;
        mRetryForever = false;
        if (DBG) log("resetRetryCount: " + mRetryCount);
    }

+33 −25
Original line number Diff line number Diff line
@@ -935,7 +935,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
        }

        if (dc == null) {
            dc = createDataConnection(apnContext.getApnType());
            dc = createDataConnection();
        }

        if (dc == null) {
@@ -947,6 +947,11 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
        dc.setActiveApnType(apnContext.getApnType());
        int refCount = dc.incAndGetRefCount();
        if (DBG) log("setupData: init dc and apnContext refCount=" + refCount);

        // configure retry count if no other Apn is using the same connection.
        if (refCount == 1) {
            configureRetry(dc, apnContext.getApnType());
        }
        DataConnectionAc dcac = mDataConnectionAsyncChannels.get(dc.getDataConnectionId());
        apnContext.setDataConnectionAc(mDataConnectionAsyncChannels.get(dc.getDataConnectionId()));
        apnContext.setApnSetting(apn);
@@ -1785,45 +1790,48 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
    }

    /** Return the id for a new data connection */
    private GsmDataConnection createDataConnection(String apnType) {
        if (DBG) log("createDataConnection(" + apnType + ") E");
    private GsmDataConnection createDataConnection() {
        if (DBG) log("createDataConnection E");

        RetryManager rm = new RetryManager();
        int id = mUniqueIdGenerator.getAndIncrement();
        GsmDataConnection conn = GsmDataConnection.makeDataConnection(mPhone, id, rm);
        mDataConnections.put(id, conn);
        DataConnectionAc dcac = new DataConnectionAc(conn, LOG_TAG);
        int status = dcac.fullyConnectSync(mPhone.getContext(), this, conn.getHandler());
        if (status == AsyncChannel.STATUS_SUCCESSFUL) {
            mDataConnectionAsyncChannels.put(dcac.dataConnection.getDataConnectionId(), dcac);
        } else {
            loge("createDataConnection: Could not connect to dcac.mDc=" + dcac.dataConnection +
                    " status=" + status);
        }

        if (DBG) log("createDataConnection() X id=" + id);
        return conn;
    }

    private void configureRetry(DataConnection dc, String apnType) {
        if ((dc == null) || (apnType == null)) return;

        if (apnType.equals(Phone.APN_TYPE_DEFAULT)) {
            if (!rm.configure(SystemProperties.get("ro.gsm.data_retry_config"))) {
                if (!rm.configure(DEFAULT_DATA_RETRY_CONFIG)) {
            if (!dc.configureRetry(SystemProperties.get("ro.gsm.data_retry_config"))) {
                if (!dc.configureRetry(DEFAULT_DATA_RETRY_CONFIG)) {
                    // Should never happen, log an error and default to a simple linear sequence.
                    loge("createDataConnection: Could not configure using " +
                            "DEFAULT_DATA_RETRY_CONFIG=" + DEFAULT_DATA_RETRY_CONFIG);
                    rm.configure(20, 2000, 1000);
                    dc.configureRetry(20, 2000, 1000);
                }
            }
        } else {
            if (!rm.configure(SystemProperties.get("ro.gsm.2nd_data_retry_config"))) {
                if (!rm.configure(SECONDARY_DATA_RETRY_CONFIG)) {
            if (!dc.configureRetry(SystemProperties.get("ro.gsm.2nd_data_retry_config"))) {
                if (!dc.configureRetry(SECONDARY_DATA_RETRY_CONFIG)) {
                    // Should never happen, log an error and default to a simple sequence.
                    loge("createDataConnection: Could note configure using " +
                            "SECONDARY_DATA_RETRY_CONFIG=" + SECONDARY_DATA_RETRY_CONFIG);
                    rm.configure("max_retries=3, 333, 333, 333");
                    dc.configureRetry("max_retries=3, 333, 333, 333");
                }
            }
        }

        int id = mUniqueIdGenerator.getAndIncrement();
        GsmDataConnection conn = GsmDataConnection.makeDataConnection(mPhone, id, rm);
        conn.resetRetryCount();
        mDataConnections.put(id, conn);
        DataConnectionAc dcac = new DataConnectionAc(conn, LOG_TAG);
        int status = dcac.fullyConnectSync(mPhone.getContext(), this, conn.getHandler());
        if (status == AsyncChannel.STATUS_SUCCESSFUL) {
            mDataConnectionAsyncChannels.put(dcac.dataConnection.getDataConnectionId(), dcac);
        } else {
            loge("createDataConnection: Could not connect to dcac.mDc=" + dcac.dataConnection +
                    " status=" + status);
        }

        if (DBG) log("createDataConnection(" + apnType + ") X id=" + id);
        return conn;
    }

    private void destroyDataConnections() {