OSDN Git Service

Clean up oddly quoted NetworkPolicies.
authorJeff Sharkey <jsharkey@android.com>
Wed, 19 Dec 2012 01:32:10 +0000 (17:32 -0800)
committerJeff Sharkey <jsharkey@android.com>
Wed, 19 Dec 2012 01:32:10 +0000 (17:32 -0800)
Bug: 7695807
Change-Id: Ia3f04dc3e918d6ca4af62f263a9c90273b3485ff

src/com/android/settings/net/NetworkPolicyEditor.java

index 5fe4c06..078df99 100644 (file)
@@ -31,7 +31,9 @@ import static com.android.internal.util.Preconditions.checkNotNull;
 import android.net.NetworkPolicy;
 import android.net.NetworkPolicyManager;
 import android.net.NetworkTemplate;
+import android.net.wifi.WifiInfo;
 import android.os.AsyncTask;
+import android.text.TextUtils;
 import android.text.format.Time;
 
 import com.android.internal.util.Objects;
@@ -221,6 +223,18 @@ public class NetworkPolicyEditor {
             }
         }
 
+        // Remove any oddly escaped policies while we're here
+        final String networkId = template.getNetworkId();
+        final String strippedNetworkId = WifiInfo.removeDoubleQuotes(networkId);
+        if (!TextUtils.equals(strippedNetworkId, networkId)) {
+            policy = getPolicy(new NetworkTemplate(
+                    template.getMatchRule(), template.getSubscriberId(), strippedNetworkId));
+            if (policy != null) {
+                mPolicies.remove(policy);
+                modified = true;
+            }
+        }
+
         if (modified) writeAsync();
     }