OSDN Git Service

Be careful sharing connections when dun is in play
authorRobert Greenwalt <rgreenwalt@google.com>
Sat, 3 Dec 2011 00:05:51 +0000 (16:05 -0800)
committerRobert Greenwalt <rgreenwalt@google.com>
Sat, 3 Dec 2011 00:42:18 +0000 (16:42 -0800)
A request for a DUN connection should only use the carriers requested dun connection.  Don't
share another connection unless it matches the carriers settings.

bug:5701374
Change-Id: I75a65fcfce1b218bd9ca4ce2ab85cbe850813321

telephony/java/com/android/internal/telephony/ApnSetting.java
telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java

index 002ffad..980bb49 100755 (executable)
@@ -189,4 +189,11 @@ public class ApnSetting {
         }
         return false;
     }
+
+    // TODO - if we have this function we should also have hashCode.
+    // Also should handle changes in type order and perhaps case-insensitivity
+    public boolean equals(Object o) {
+        if (o instanceof ApnSetting == false) return false;
+        return (this.toString().equals(o.toString()));
+    }
 }
index de09dfb..11f1623 100644 (file)
@@ -1720,11 +1720,25 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
     private DataConnection checkForConnectionForApnContext(ApnContext apnContext) {
         // Loop through all apnContexts looking for one with a conn that satisfies this apnType
         String apnType = apnContext.getApnType();
+        ApnSetting dunSetting = null;
+
+        if (Phone.APN_TYPE_DUN.equals(apnType)) {
+            dunSetting = fetchDunApn();
+        }
+
         for (ApnContext c : mApnContexts.values()) {
             DataConnection conn = c.getDataConnection();
             if (conn != null) {
                 ApnSetting apnSetting = c.getApnSetting();
-                if (apnSetting != null && apnSetting.canHandleType(apnType)) {
+                if (dunSetting != null) {
+                    if (dunSetting.equals(apnSetting)) {
+                        if (DBG) {
+                            log("checkForConnectionForApnContext: apnContext=" + apnContext +
+                                    " found conn=" + conn);
+                        }
+                        return conn;
+                    }
+                } else if (apnSetting != null && apnSetting.canHandleType(apnType)) {
                     if (DBG) {
                         log("checkForConnectionForApnContext: apnContext=" + apnContext +
                                 " found conn=" + conn);