From 24dc6bb288a15516c89ab507bb86511556824144 Mon Sep 17 00:00:00 2001 From: Roshan Pius Date: Tue, 30 May 2017 14:10:32 -0700 Subject: WifiScanningService: Don't cache results of partial scan These partial scan requests are initiated by the wifi stack when connected to a network for network selection purposes. This might interfere with full scan requests made by external apps. So, don't cache such partial scan results. The apps will always get results of the last full scan request made. Bug: 38212080 Test: Unit tests Test: Verified manually that the WifiManager#getScanResults() no longer outputs partial scan results. Change-Id: I5e320435e34c6bd74639dd13a480bb26ecea1edb --- .../com/android/server/wifi/scanner/WifiScanningServiceImpl.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'service/java/com/android/server/wifi/scanner/WifiScanningServiceImpl.java') diff --git a/service/java/com/android/server/wifi/scanner/WifiScanningServiceImpl.java b/service/java/com/android/server/wifi/scanner/WifiScanningServiceImpl.java index ef881dad6..d73bf053c 100644 --- a/service/java/com/android/server/wifi/scanner/WifiScanningServiceImpl.java +++ b/service/java/com/android/server/wifi/scanner/WifiScanningServiceImpl.java @@ -447,6 +447,7 @@ public class WifiScanningServiceImpl extends IWifiScanner.Stub { private RequestList mActiveScans = new RequestList<>(); private RequestList mPendingScans = new RequestList<>(); + // Scan results cached from the last full single scan request. private ScanResult[] mCachedScanResults = new ScanResult[0]; WifiSingleScanStateMachine(Looper looper) { @@ -879,8 +880,11 @@ public class WifiScanningServiceImpl extends IWifiScanner.Stub { entry.reportEvent(WifiScanner.CMD_SCAN_RESULT, 0, parcelableAllResults); } - // Cache the results here so that apps can retrieve them. - mCachedScanResults = results.getResults(); + // Since we use NoBandChannelHelper, as long as a specific band is mentioned, the scan + // request is treated as full band (WifiScanner.WIFI_BAND_*). + if (results.isAllChannelsScanned()) { + mCachedScanResults = results.getResults(); + } sendScanResultBroadcast(true); } -- cgit v1.2.3