From 71c4c2a898a827a867564159ce78e41aedd2295b Mon Sep 17 00:00:00 2001 From: Sohani Rao Date: Sun, 9 Jul 2017 15:23:01 -0700 Subject: Introduce new API for retrieving PNO scan results Create a seperation of code paths for retrieving scan results from single scan vs those from a PNO scan. This enables the underlying implementation to return PNO scan results from the interface that most recently completed the scans while ensuring no changes to the way single scan results are returned to the framework. Bug: 63148974 Test: Unit tests, on-device test for connecting to a network found by Offload HAL during Pno scans Change-Id: I6002f6df05e40fe24ff12f4a49599343578873f4 --- service/java/com/android/server/wifi/WifiNative.java | 11 ++++++++++- .../java/com/android/server/wifi/WificondControl.java | 16 ++++++++++++++-- .../android/server/wifi/scanner/WificondScannerImpl.java | 2 +- 3 files changed, 25 insertions(+), 4 deletions(-) (limited to 'service') diff --git a/service/java/com/android/server/wifi/WifiNative.java b/service/java/com/android/server/wifi/WifiNative.java index 973b659d2..1d6c9d4af 100644 --- a/service/java/com/android/server/wifi/WifiNative.java +++ b/service/java/com/android/server/wifi/WifiNative.java @@ -227,7 +227,16 @@ public class WifiNative { * Returns an empty ArrayList on failure. */ public ArrayList getScanResults() { - return mWificondControl.getScanResults(); + return mWificondControl.getScanResults(WificondControl.SCAN_TYPE_SINGLE_SCAN); + } + + /** + * Fetch the latest scan result from kernel via wificond. + * @return Returns an ArrayList of ScanDetail. + * Returns an empty ArrayList on failure. + */ + public ArrayList getPnoScanResults() { + return mWificondControl.getScanResults(WificondControl.SCAN_TYPE_PNO_SCAN); } /** diff --git a/service/java/com/android/server/wifi/WificondControl.java b/service/java/com/android/server/wifi/WificondControl.java index 005f36042..70ecabccf 100644 --- a/service/java/com/android/server/wifi/WificondControl.java +++ b/service/java/com/android/server/wifi/WificondControl.java @@ -51,6 +51,13 @@ public class WificondControl { private boolean mVerboseLoggingEnabled = false; private static final String TAG = "WificondControl"; + + /* Get scan results for a single scan */ + public static final int SCAN_TYPE_SINGLE_SCAN = 0; + + /* Get scan results for Pno Scan */ + public static final int SCAN_TYPE_PNO_SCAN = 1; + private WifiInjector mWifiInjector; private WifiMonitor mWifiMonitor; private final CarrierNetworkConfig mCarrierNetworkConfig; @@ -334,14 +341,19 @@ public class WificondControl { * @return Returns an ArrayList of ScanDetail. * Returns an empty ArrayList on failure. */ - public ArrayList getScanResults() { + public ArrayList getScanResults(int scanType) { ArrayList results = new ArrayList<>(); if (mWificondScanner == null) { Log.e(TAG, "No valid wificond scanner interface handler"); return results; } try { - NativeScanResult[] nativeResults = mWificondScanner.getScanResults(); + NativeScanResult[] nativeResults; + if (scanType == SCAN_TYPE_SINGLE_SCAN) { + nativeResults = mWificondScanner.getScanResults(); + } else { + nativeResults = mWificondScanner.getPnoScanResults(); + } for (NativeScanResult result : nativeResults) { WifiSsid wifiSsid = WifiSsid.createFromByteArray(result.ssid); String bssid; diff --git a/service/java/com/android/server/wifi/scanner/WificondScannerImpl.java b/service/java/com/android/server/wifi/scanner/WificondScannerImpl.java index 84105ee61..12a0bdee0 100644 --- a/service/java/com/android/server/wifi/scanner/WificondScannerImpl.java +++ b/service/java/com/android/server/wifi/scanner/WificondScannerImpl.java @@ -538,7 +538,7 @@ public class WificondScannerImpl extends WifiScannerImpl implements Handler.Call // got a scan before we started scanning or after scan was canceled return; } - mNativeScanResults = mWifiNative.getScanResults(); + mNativeScanResults = mWifiNative.getPnoScanResults(); List hwPnoScanResults = new ArrayList<>(); int numFilteredScanResults = 0; for (int i = 0; i < mNativeScanResults.size(); ++i) { -- cgit v1.2.3