summaryrefslogtreecommitdiffstats
path: root/service/java/com/android/server/wifi/scanner/WifiScanningServiceImpl.java
diff options
context:
space:
mode:
authorMitchell Wills <mwills@google.com>2016-06-24 22:31:04 +0000
committerandroid-build-merger <android-build-merger@google.com>2016-06-24 22:31:04 +0000
commit4dcf7a8d2b9253e5a58328a9cd954c524c76c7af (patch)
tree232b20046ffc7093ce83c94cccddbf3e597832a9 /service/java/com/android/server/wifi/scanner/WifiScanningServiceImpl.java
parent147c210d0da98a064a9cd61276ef8725a6faa785 (diff)
parentb5dcbf476fe1626131de575dfc46981c713843b0 (diff)
downloadandroid_frameworks_opt_net_wifi-4dcf7a8d2b9253e5a58328a9cd954c524c76c7af.tar.gz
android_frameworks_opt_net_wifi-4dcf7a8d2b9253e5a58328a9cd954c524c76c7af.tar.bz2
android_frameworks_opt_net_wifi-4dcf7a8d2b9253e5a58328a9cd954c524c76c7af.zip
Merge \\"Reuse single scan results if a request comes in during an ongoing scan\\" into nyc-mr1-dev am: 55b1b58e72
am: b5dcbf476f Change-Id: I341a4d5523ef20e0e44558ee12d448fd7324e0e4
Diffstat (limited to 'service/java/com/android/server/wifi/scanner/WifiScanningServiceImpl.java')
-rw-r--r--service/java/com/android/server/wifi/scanner/WifiScanningServiceImpl.java61
1 files changed, 56 insertions, 5 deletions
diff --git a/service/java/com/android/server/wifi/scanner/WifiScanningServiceImpl.java b/service/java/com/android/server/wifi/scanner/WifiScanningServiceImpl.java
index bceae602e..2912aee5e 100644
--- a/service/java/com/android/server/wifi/scanner/WifiScanningServiceImpl.java
+++ b/service/java/com/android/server/wifi/scanner/WifiScanningServiceImpl.java
@@ -418,6 +418,7 @@ public class WifiScanningServiceImpl extends IWifiScanner.Stub {
private final IdleState mIdleState = new IdleState();
private final ScanningState mScanningState = new ScanningState();
+ private WifiNative.ScanSettings mActiveScanSettings = null;
private RequestList<ScanSettings> mActiveScans = new RequestList<>();
private RequestList<ScanSettings> mPendingScans = new RequestList<>();
@@ -546,12 +547,24 @@ public class WifiScanningServiceImpl extends IWifiScanner.Stub {
scanParams.getParcelable(WifiScanner.SCAN_PARAMS_SCAN_SETTINGS_KEY);
WorkSource workSource =
scanParams.getParcelable(WifiScanner.SCAN_PARAMS_WORK_SOURCE_KEY);
- if (validateAndAddToScanQueue(ci, handler, scanSettings, workSource)) {
+ if (validateScanRequest(ci, handler, scanSettings, workSource)) {
+ logScanRequest("addSingleScanRequest", ci, handler, workSource,
+ scanSettings, null);
replySucceeded(msg);
+
+ // If there is an active scan that will fulfill the scan request then
+ // mark this request as an active scan, otherwise mark it pending.
// If were not currently scanning then try to start a scan. Otherwise
// this scan will be scheduled when transitioning back to IdleState
// after finishing the current scan.
- if (getCurrentState() != mScanningState) {
+ if (getCurrentState() == mScanningState) {
+ if (activeScanSatisfies(scanSettings)) {
+ mActiveScans.addRequest(ci, handler, workSource, scanSettings);
+ } else {
+ mPendingScans.addRequest(ci, handler, workSource, scanSettings);
+ }
+ } else {
+ mPendingScans.addRequest(ci, handler, workSource, scanSettings);
tryToStartNewScan();
}
} else {
@@ -597,6 +610,7 @@ public class WifiScanningServiceImpl extends IWifiScanner.Stub {
@Override
public void exit() {
+ mActiveScanSettings = null;
try {
mBatteryStats.noteWifiScanStoppedFromSource(mScanWorkSource);
} catch (RemoteException e) {
@@ -638,7 +652,7 @@ public class WifiScanningServiceImpl extends IWifiScanner.Stub {
}
}
- boolean validateAndAddToScanQueue(ClientInfo ci, int handler, ScanSettings settings,
+ boolean validateScanRequest(ClientInfo ci, int handler, ScanSettings settings,
WorkSource workSource) {
if (ci == null) {
Log.d(TAG, "Failing single scan request ClientInfo not found " + handler);
@@ -650,8 +664,43 @@ public class WifiScanningServiceImpl extends IWifiScanner.Stub {
return false;
}
}
- logScanRequest("addSingleScanRequest", ci, handler, workSource, settings, null);
- mPendingScans.addRequest(ci, handler, workSource, settings);
+ return true;
+ }
+
+ boolean activeScanSatisfies(ScanSettings settings) {
+ if (mActiveScanSettings == null) {
+ return false;
+ }
+
+ // there is always one bucket for a single scan
+ WifiNative.BucketSettings activeBucket = mActiveScanSettings.buckets[0];
+
+ // validate that all requested channels are being scanned
+ ChannelCollection activeChannels = mChannelHelper.createChannelCollection();
+ activeChannels.addChannels(activeBucket);
+ if (!activeChannels.containsSettings(settings)) {
+ return false;
+ }
+
+ // if the request is for a full scan, but there is no ongoing full scan
+ if ((settings.reportEvents & WifiScanner.REPORT_EVENT_FULL_SCAN_RESULT) != 0
+ && (activeBucket.report_events & WifiScanner.REPORT_EVENT_FULL_SCAN_RESULT)
+ == 0) {
+ return false;
+ }
+
+ if (settings.hiddenNetworkIds != null) {
+ Set<Integer> activeHiddenNetworkIds = new HashSet<>();
+ for (int id : mActiveScanSettings.hiddenNetworkIds) {
+ activeHiddenNetworkIds.add(id);
+ }
+ for (int id : settings.hiddenNetworkIds) {
+ if (!activeHiddenNetworkIds.contains(id)) {
+ return false;
+ }
+ }
+ }
+
return true;
}
@@ -710,6 +759,8 @@ public class WifiScanningServiceImpl extends IWifiScanner.Stub {
settings.buckets = new WifiNative.BucketSettings[] {bucketSettings};
if (mScannerImpl.startSingleScan(settings, this)) {
+ // store the active scan settings
+ mActiveScanSettings = settings;
// swap pending and active scan requests
RequestList<ScanSettings> tmp = mActiveScans;
mActiveScans = mPendingScans;