Release DataConnection when a rety is interupted
Robert Greenwalt [Thu, 30 Jul 2015 00:57:12 +0000 (17:57 -0700)]
We had code that simply set the ApnContexts state to IDLE, but
there was still a connection between ApnContext and DataConnection,
so when looking for a DC, we'd skip this one (it's busy) and when
the rety alarm fires we end up with a second DC attempting to connect
to the same APN.

bug:22410092
Change-Id: Id4ab6a4f1f08588e552e846a1986f93192a72568

src/java/com/android/internal/telephony/dataconnection/ApnContext.java
src/java/com/android/internal/telephony/dataconnection/DcTracker.java

index 9e9433e..081e9b7 100644 (file)
@@ -123,6 +123,14 @@ public class ApnContext {
         mDcAc = dcac;
     }
 
+    public synchronized void releaseDataConnection(String reason) {
+        if (mDcAc != null) {
+            mDcAc.tearDown(this, reason, null);
+            mDcAc = null;
+        }
+        setState(DctConstants.State.IDLE);
+    }
+
     public synchronized PendingIntent getReconnectIntent() {
         return mReconnectAlarmIntent;
     }
index c608db0..8d02de9 100644 (file)
@@ -799,11 +799,11 @@ public final class DcTracker extends DcTrackerBase {
             if (apnContext.getState() == DctConstants.State.FAILED
                     || apnContext.getState() == DctConstants.State.RETRYING) {
                 if (retryFailures == RetryFailures.ALWAYS) {
-                    apnContext.setState(DctConstants.State.IDLE);
+                    apnContext.releaseDataConnection(reason);
                 } else if (apnContext.isConcurrentVoiceAndDataAllowed() == false &&
                          mPhone.getServiceStateTracker().isConcurrentVoiceAndDataAllowed()) {
                     // RetryFailures.ONLY_ON_CHANGE - check if voice concurrency has changed
-                    apnContext.setState(DctConstants.State.IDLE);
+                    apnContext.releaseDataConnection(reason);
                 } else {
                     // RetryFailures.ONLY_ON_CHANGE - check if the apns have changed
                     int radioTech = mPhone.getServiceState().getRilDataRadioTechnology();
@@ -812,7 +812,7 @@ public final class DcTracker extends DcTrackerBase {
                         waitingApns = buildWaitingApns(apnContext.getApnType(), radioTech);
                         if (originalApns.size() != waitingApns.size() ||
                                 originalApns.containsAll(waitingApns) == false) {
-                            apnContext.setState(DctConstants.State.IDLE);
+                            apnContext.releaseDataConnection(reason);
                         }
                     }
                 }