diff options
author | Mitchell Wills <mwills@google.com> | 2016-06-23 11:07:28 -0700 |
---|---|---|
committer | Mitchell Wills <mwills@google.com> | 2016-06-24 17:48:45 -0700 |
commit | 1ba04405f98489f0fbd66b6566c64324be11111a (patch) | |
tree | 00f5c77f4bf95a1f110c6d28a1d7fb81f8d550fc /service | |
parent | 55b1b58e72df2362888c7a1c60ad76a43523bfcf (diff) |
Add a WifiScanner API to listen for ongoing scans
Bug: 29412469
Change-Id: I1b8c6f3524e937cbc902af0be391b5e6b23e8ee2
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/scanner/WifiScanningServiceImpl.java | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/service/java/com/android/server/wifi/scanner/WifiScanningServiceImpl.java b/service/java/com/android/server/wifi/scanner/WifiScanningServiceImpl.java index ee0a060cb..b98b4d121 100644 --- a/service/java/com/android/server/wifi/scanner/WifiScanningServiceImpl.java +++ b/service/java/com/android/server/wifi/scanner/WifiScanningServiceImpl.java @@ -214,6 +214,15 @@ public class WifiScanningServiceImpl extends IWifiScanner.Stub { case WifiScanner.CMD_STOP_TRACKING_CHANGE: mWifiChangeStateMachine.sendMessage(Message.obtain(msg)); break; + case WifiScanner.CMD_REGISTER_SCAN_LISTENER: + logScanRequest("registerScanListener", ci, msg.arg2, null, null, null); + mSingleScanListeners.addRequest(ci, msg.arg2, null, null); + replySucceeded(msg); + break; + case WifiScanner.CMD_DEREGISTER_SCAN_LISTENER: + logScanRequest("deregisterScanListener", ci, msg.arg2, null, null, null); + mSingleScanListeners.removeRequest(ci, msg.arg2); + break; default: replyFailed(msg, WifiScanner.REASON_INVALID_REQUEST, "Invalid request"); break; @@ -242,6 +251,8 @@ public class WifiScanningServiceImpl extends IWifiScanner.Stub { private final WifiScannerImpl.WifiScannerImplFactory mScannerImplFactory; private final ArrayMap<Messenger, ClientInfo> mClients; + private final RequestList<Void> mSingleScanListeners = new RequestList<>(); + private ChannelHelper mChannelHelper; private BackgroundScanScheduler mBackgroundScheduler; private WifiNative.ScanSettings mPreviousSchedule; @@ -795,6 +806,10 @@ public class WifiScanningServiceImpl extends IWifiScanner.Stub { entry.reportEvent(WifiScanner.CMD_FULL_SCAN_RESULT, 0, result); } } + + for (RequestInfo<Void> entry : mSingleScanListeners) { + entry.reportEvent(WifiScanner.CMD_FULL_SCAN_RESULT, 0, result); + } } void reportScanResults(ScanData results) { @@ -805,18 +820,26 @@ public class WifiScanningServiceImpl extends IWifiScanner.Stub { mWifiMetrics.incrementEmptyScanResultCount(); } } + ScanData[] allResults = new ScanData[] {results}; for (RequestInfo<ScanSettings> entry : mActiveScans) { - ScanData[] resultsArray = new ScanData[] {results}; ScanData[] resultsToDeliver = ScanScheduleUtil.filterResultsForSettings( - mChannelHelper, resultsArray, entry.settings, -1); - WifiScanner.ParcelableScanData parcelableScanData = + mChannelHelper, allResults, entry.settings, -1); + WifiScanner.ParcelableScanData parcelableResultsToDeliver = new WifiScanner.ParcelableScanData(resultsToDeliver); logCallback("singleScanResults", entry.clientInfo, entry.handlerId, describeForLog(resultsToDeliver)); - entry.reportEvent(WifiScanner.CMD_SCAN_RESULT, 0, parcelableScanData); + entry.reportEvent(WifiScanner.CMD_SCAN_RESULT, 0, parcelableResultsToDeliver); // make sure the handler is removed entry.reportEvent(WifiScanner.CMD_SINGLE_SCAN_COMPLETED, 0, null); } + + WifiScanner.ParcelableScanData parcelableAllResults = + new WifiScanner.ParcelableScanData(allResults); + for (RequestInfo<Void> entry : mSingleScanListeners) { + logCallback("singleScanResults", entry.clientInfo, entry.handlerId, + describeForLog(allResults)); + entry.reportEvent(WifiScanner.CMD_SCAN_RESULT, 0, parcelableAllResults); + } } } @@ -1870,6 +1893,7 @@ public class WifiScanningServiceImpl extends IWifiScanner.Stub { } public void cleanup() { + mSingleScanListeners.removeAllForClient(this); mSingleScanStateMachine.removeSingleScanRequests(this); mBackgroundScanStateMachine.removeBackgroundScanSettings(this); mBackgroundScanStateMachine.removeHotlistSettings(this); |