am 540784f9: Merge "Cleanup the shutdown of BatchedScans." into klp-dev

* commit '540784f903c8a9e808ef88d14fe5e1227bda4561':
  Cleanup the shutdown of BatchedScans.
This commit is contained in:
Robert Greenwalt
2013-09-20 10:50:39 -07:00
committed by Android Git Automerger
3 changed files with 13 additions and 9 deletions

View File

@@ -367,14 +367,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);
}
}
@@ -429,13 +429,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;
}
@@ -459,7 +463,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 &&
@@ -468,7 +471,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 &&

View 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);

View 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) {}
}