diff options
| author | 2016-06-27 18:24:23 +0000 | |
|---|---|---|
| committer | 2016-06-27 18:24:24 +0000 | |
| commit | 9b62f770dd7359cea45229e500c3e7bee317156c (patch) | |
| tree | 87b4a8cb39adcfbe6f50ef29379ade675113cff9 | |
| parent | 11343088423d84c7255a2264bf8cfe776124a4a6 (diff) | |
| parent | dd1816902a5b2995e7b90ec510f4f85c2aecd4c4 (diff) | |
Merge "Merge \"Add a WifiScanner API to listener for ongoing scans\" into nyc-mr1-dev am: 9f750bf5f4" into nyc-mr1-dev-plus-aosp
| -rw-r--r-- | wifi/java/android/net/wifi/WifiScanner.java | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/wifi/java/android/net/wifi/WifiScanner.java b/wifi/java/android/net/wifi/WifiScanner.java index 2636c3f3e079..716f1d32ec84 100644 --- a/wifi/java/android/net/wifi/WifiScanner.java +++ b/wifi/java/android/net/wifi/WifiScanner.java @@ -656,6 +656,40 @@ public class WifiScanner { void onPnoNetworkFound(ScanResult[] results); } + /** + * Register a listener that will receive results from all single scans + * Either the onSuccess/onFailure will be called once when the listener is registered. After + * (assuming onSuccess was called) all subsequent single scan results will be delivered to the + * listener. It is possible that onFullResult will not be called for all results of the first + * scan if the listener was registered during the scan. + * + * @param listener specifies the object to report events to. This object is also treated as a + * key for this request, and must also be specified to cancel the request. + * Multiple requests should also not share this object. + * {@hide} + */ + public void registerScanListener(ScanListener listener) { + Preconditions.checkNotNull(listener, "listener cannot be null"); + int key = addListener(listener); + if (key == INVALID_KEY) return; + validateChannel(); + mAsyncChannel.sendMessage(CMD_REGISTER_SCAN_LISTENER, 0, key); + } + + /** + * Deregister a listener for ongoing single scans + * @param listener specifies which scan to cancel; must be same object as passed in {@link + * #registerScanListener} + * {@hide} + */ + public void deregisterScanListener(ScanListener listener) { + Preconditions.checkNotNull(listener, "listener cannot be null"); + int key = removeListener(listener); + if (key == INVALID_KEY) return; + validateChannel(); + mAsyncChannel.sendMessage(CMD_DEREGISTER_SCAN_LISTENER, 0, key); + } + /** start wifi scan in background * @param settings specifies various parameters for the scan; for more information look at * {@link ScanSettings} @@ -1129,6 +1163,10 @@ public class WifiScanner { public static final int CMD_STOP_PNO_SCAN = BASE + 25; /** @hide */ public static final int CMD_PNO_NETWORK_FOUND = BASE + 26; + /** @hide */ + public static final int CMD_REGISTER_SCAN_LISTENER = BASE + 27; + /** @hide */ + public static final int CMD_DEREGISTER_SCAN_LISTENER = BASE + 28; private Context mContext; private IWifiScanner mService; |