OSDN Git Service

Cleanup the shutdown of BatchedScans.
authorRobert Greenwalt <rgreenwalt@google.com>
Fri, 20 Sep 2013 00:27:43 +0000 (17:27 -0700)
committerRobert Greenwalt <rgreenwalt@google.com>
Fri, 20 Sep 2013 16:32:47 +0000 (16:32 +0000)
Fixes binder-death as well as disambiguation when an app has multiple requests in.

bug:10641931
Change-Id: Ib701d531fa51e7e2a027848cfdfcad3b47056923

services/java/com/android/server/wifi/WifiService.java
wifi/java/android/net/wifi/IWifiManager.aidl
wifi/java/android/net/wifi/WifiManager.java

index ed2b8fd..8d93b10 100644 (file)
@@ -334,14 +334,14 @@ public final class WifiService extends IWifiManager.Stub {
             this.pid = getCallingPid();
         }
         public void binderDied() {
-            stopBatchedScan(settings, mBinder);
+            stopBatchedScan(settings, uid, pid);
         }
         public String toString() {
             return "BatchedScanRequest{settings=" + settings + ", binder=" + mBinder + "}";
         }
 
-        public boolean isSameApp() {
-            return (this.uid == getCallingUid() && this.pid == getCallingPid());
+        public boolean isSameApp(int uid, int pid) {
+            return (this.uid == uid && this.pid == pid);
         }
     }
 
@@ -396,13 +396,17 @@ public final class WifiService extends IWifiManager.Stub {
     }
 
 
-    public void stopBatchedScan(BatchedScanSettings settings, IBinder binder) {
+    public void stopBatchedScan(BatchedScanSettings settings) {
         enforceChangePermission();
         if (mBatchedScanSupported == false) return;
+        stopBatchedScan(settings, getCallingUid(), getCallingPid());
+    }
+
+    private void stopBatchedScan(BatchedScanSettings settings, int uid, int pid) {
         ArrayList<BatchedScanRequest> found = new ArrayList<BatchedScanRequest>();
         synchronized(mBatchedScanners) {
             for (BatchedScanRequest r : mBatchedScanners) {
-                if (r.isSameApp() && (settings == null || settings.equals(r.settings))) {
+                if (r.isSameApp(uid, pid) && (settings == null || settings.equals(r.settings))) {
                     found.add(r);
                     if (settings != null) break;
                 }
@@ -426,7 +430,6 @@ public final class WifiService extends IWifiManager.Stub {
             mWifiStateMachine.setBatchedScanSettings(null, 0);
             return;
         }
-
         for (BatchedScanRequest r : mBatchedScanners) {
             BatchedScanSettings s = r.settings;
             if (s.maxScansPerBatch != BatchedScanSettings.UNSPECIFIED &&
@@ -435,7 +438,8 @@ public final class WifiService extends IWifiManager.Stub {
                 responsibleUid = r.uid;
             }
             if (s.maxApPerScan != BatchedScanSettings.UNSPECIFIED &&
-                    s.maxApPerScan > setting.maxApPerScan) {
+                    (setting.maxApPerScan == BatchedScanSettings.UNSPECIFIED ||
+                     s.maxApPerScan > setting.maxApPerScan)) {
                 setting.maxApPerScan = s.maxApPerScan;
             }
             if (s.scanIntervalSec != BatchedScanSettings.UNSPECIFIED &&
index 4f68ca0..5a1928c 100644 (file)
@@ -119,7 +119,7 @@ interface IWifiManager
 
     boolean requestBatchedScan(in BatchedScanSettings requested, IBinder binder);
 
-    void stopBatchedScan(in BatchedScanSettings requested, IBinder binder);
+    void stopBatchedScan(in BatchedScanSettings requested);
 
     List<BatchedScanResult> getBatchedScanResults(String callingPackage);
 
index c3bf9c1..31bc1ff 100644 (file)
@@ -826,7 +826,7 @@ public class WifiManager {
      */
     public void stopBatchedScan(BatchedScanSettings requested) {
         try {
-            mService.stopBatchedScan(requested, new Binder());
+            mService.stopBatchedScan(requested);
         } catch (RemoteException e) {}
     }