From bfc76e06469f8123a6a1f2a28cc3db7118070ee3 Mon Sep 17 00:00:00 2001 From: Rebecca Silberstein Date: Wed, 14 Sep 2016 22:07:04 -0700 Subject: [PATCH] WifiScanner: retrieve single scan results Add a new CMD_GET_SINGLE_SCAN_RESULTS message type and getSingleScanResults method that allow WifiService to get scan results directly from WifiScanner. BUG: 31444878 Test: manually tested on angler Test: frameworks/opt/net/wifi/tests/wifitests/runtests.sh on angler Test: ran GTS CtsNetTestCases on angler Change-Id: I705233d7dc4ae7e8480c53ff0f9e1b6c8875fecb --- wifi/java/android/net/wifi/WifiScanner.java | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/wifi/java/android/net/wifi/WifiScanner.java b/wifi/java/android/net/wifi/WifiScanner.java index 06e1b681fbefa..5847f798712d0 100644 --- a/wifi/java/android/net/wifi/WifiScanner.java +++ b/wifi/java/android/net/wifi/WifiScanner.java @@ -34,9 +34,10 @@ import com.android.internal.util.AsyncChannel; import com.android.internal.util.Preconditions; import com.android.internal.util.Protocol; +import java.util.ArrayList; +import java.util.Arrays; import java.util.List; - /** * This class provides a way to scan the Wifi universe around the device * Get an instance of this class by calling @@ -822,6 +823,22 @@ public class WifiScanner { mAsyncChannel.sendMessage(CMD_STOP_SINGLE_SCAN, 0, key); } + /** + * Retrieve the most recent scan results from a single scan request. + * {@hide} + */ + public List getSingleScanResults() { + validateChannel(); + Message reply = mAsyncChannel.sendMessageSynchronously(CMD_GET_SINGLE_SCAN_RESULTS, 0); + if (reply.what == WifiScanner.CMD_OP_SUCCEEDED) { + return Arrays.asList(((ParcelableScanResults) reply.obj).getResults()); + } + OperationResult result = (OperationResult) reply.obj; + Log.e(TAG, "Error retrieving SingleScan results reason: " + result.reason + + " description: " + result.description); + return new ArrayList(); + } + private void startPnoScan(ScanSettings scanSettings, PnoSettings pnoSettings, int key) { // Bundle up both the settings and send it across. Bundle pnoParams = new Bundle(); @@ -1201,6 +1218,8 @@ public class WifiScanner { public static final int CMD_REGISTER_SCAN_LISTENER = BASE + 27; /** @hide */ public static final int CMD_DEREGISTER_SCAN_LISTENER = BASE + 28; + /** @hide */ + public static final int CMD_GET_SINGLE_SCAN_RESULTS = BASE + 29; private Context mContext; private IWifiScanner mService;