OSDN Git Service

Fix issue on infinite retry config in RetryManager
authorKazuhiro Ondo <kazuhiro.ondo@motorola.com>
Fri, 6 May 2011 17:12:35 +0000 (12:12 -0500)
committerWink Saville <wink@google.com>
Tue, 10 May 2011 00:01:07 +0000 (17:01 -0700)
"infinite retry config is lost when "resetRetryCount" is called.

Change-Id: I2b737efa6092ad1254c8dc25840ec429f5c6e882

telephony/java/com/android/internal/telephony/DataConnection.java
telephony/java/com/android/internal/telephony/RetryManager.java
telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java

index c4359a9..0188cf1 100644 (file)
@@ -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);
 
     /**
index b1049a2..29bd104 100644 (file)
@@ -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);
     }
 
index 21c644d..3d7fc54 100644 (file)
@@ -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() {