From 39e9f9fc74020a59ee48be25c1ffe16be52f7e28 Mon Sep 17 00:00:00 2001 From: Dave Friedman Date: Wed, 4 Oct 2017 16:26:10 -0700 Subject: [PATCH] Docs: Adds brief instructions for how to do Wi-Fi scan. Bug: 67967771 Test: Ran make ds-docs. We don't actually document how to do a Wi-Fi scan anywhere on DAC; at the moment, this seems like the place where it makes the most sense to provide that guidance. The forcing function for doing this is that a new doc explicitly recommends that devs do Wi-Fi scans in certain cases, but doesn't have a place to link to that tells them how to do so. That doc plans to send readers here. Change-Id: Ic35fb77d323e825e5bd5b4eec2716730f0d531e1 --- wifi/java/android/net/wifi/WifiManager.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java index c89a9a458393..f1e7eaf91b63 100644 --- a/wifi/java/android/net/wifi/WifiManager.java +++ b/wifi/java/android/net/wifi/WifiManager.java @@ -67,6 +67,7 @@ import java.util.concurrent.CountDownLatch; * leaks within the calling process. *

* It deals with several categories of items: + *

* + *

* This is the API to use when performing Wi-Fi specific operations. To perform * operations that pertain to network connectivity at an abstract level, use * {@link android.net.ConnectivityManager}. + *

*/ @SystemService(Context.WIFI_SERVICE) public class WifiManager { @@ -1522,7 +1525,21 @@ public class WifiManager { * Request a scan for access points. Returns immediately. The availability * of the results is made known later by means of an asynchronous event sent * on completion of the scan. - * @return {@code true} if the operation succeeded, i.e., the scan was initiated + *

+ * To initiate a Wi-Fi scan, declare the + * {@link android.Manifest.permission#CHANGE_WIFI_STATE} + * permission in the manifest, and perform these steps: + *

+ *
    + *
  1. Invoke the following method: + * {@code ((WifiManager) getSystemService(WIFI_SERVICE)).startScan()}
  2. + *
  3. + * Register a BroadcastReceiver to listen to + * {@code SCAN_RESULTS_AVAILABLE_ACTION}.
  4. + *
  5. When a broadcast is received, call: + * {@code ((WifiManager) getSystemService(WIFI_SERVICE)).getScanResults()}
  6. + *
+ * @return {@code true} if the operation succeeded, i.e., the scan was initiated. */ public boolean startScan() { return startScan(null); -- 2.11.0