diff options
author | Dmitry Shmidt <dimitrysh@google.com> | 2013-02-26 14:47:16 -0800 |
---|---|---|
committer | Dmitry Shmidt <dimitrysh@google.com> | 2013-02-26 16:22:15 -0800 |
commit | 67b3fbf49c0c92641e19e3278a1feab7b68aa7b8 (patch) | |
tree | e6217481cca6fdf6ba8dd75e7c7c6a648a8d3dde /wifi | |
parent | aed205068de293fb92177920a6243fdef98ef310 (diff) | |
download | frameworks_base-67b3fbf49c0c92641e19e3278a1feab7b68aa7b8.zip frameworks_base-67b3fbf49c0c92641e19e3278a1feab7b68aa7b8.tar.gz frameworks_base-67b3fbf49c0c92641e19e3278a1feab7b68aa7b8.tar.bz2 |
wifi: Get full scan results
BUG: 8236341
Change-Id: Ic0b769eed6bfcdc12644bf461060d3e42ab18e86
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
Diffstat (limited to 'wifi')
-rw-r--r-- | wifi/java/android/net/wifi/WifiNative.java | 6 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/WifiStateMachine.java | 40 |
2 files changed, 40 insertions, 6 deletions
diff --git a/wifi/java/android/net/wifi/WifiNative.java b/wifi/java/android/net/wifi/WifiNative.java index 59f1889..9e77b8c 100644 --- a/wifi/java/android/net/wifi/WifiNative.java +++ b/wifi/java/android/net/wifi/WifiNative.java @@ -202,6 +202,7 @@ public class WifiNative { /** * Format of results: * ================= + * id=1 * bssid=68:7f:74:d7:1b:6e * freq=2412 * level=-43 @@ -211,10 +212,11 @@ public class WifiNative { * ssid=zubyb * * RANGE=ALL gets all scan results + * RANGE=ID- gets results from ID * MASK=<N> see wpa_supplicant/src/common/wpa_ctrl.h for details */ - public String scanResults() { - return doStringCommand("BSS RANGE=ALL MASK=0x1986"); + public String scanResults(int sid) { + return doStringCommand("BSS RANGE=" + sid + "- MASK=0x1987"); } public boolean startDriver() { diff --git a/wifi/java/android/net/wifi/WifiStateMachine.java b/wifi/java/android/net/wifi/WifiStateMachine.java index 7da4caa..b3ada43 100644 --- a/wifi/java/android/net/wifi/WifiStateMachine.java +++ b/wifi/java/android/net/wifi/WifiStateMachine.java @@ -72,6 +72,7 @@ import android.os.WorkSource; import android.provider.Settings; import android.util.Log; import android.util.LruCache; +import android.text.TextUtils; import com.android.internal.R; import com.android.internal.app.IBatteryStats; @@ -1369,6 +1370,7 @@ public class WifiStateMachine extends StateMachine { mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL); } + private static final String ID_STR = "id="; private static final String BSSID_STR = "bssid="; private static final String FREQ_STR = "freq="; private static final String LEVEL_STR = "level="; @@ -1376,8 +1378,12 @@ public class WifiStateMachine extends StateMachine { private static final String FLAGS_STR = "flags="; private static final String SSID_STR = "ssid="; private static final String DELIMITER_STR = "===="; + private static final int SCAN_BUF_RANGE = 3900; + /** * Format: + * + * id=1 * bssid=68:7f:76:d7:1a:6e * freq=2412 * level=-44 @@ -1385,6 +1391,7 @@ public class WifiStateMachine extends StateMachine { * flags=[WPA2-PSK-CCMP][WPS][ESS] * ssid=zfdy * ==== + * id=2 * bssid=68:5f:74:d7:1a:6f * freq=5180 * level=-73 @@ -1393,16 +1400,41 @@ public class WifiStateMachine extends StateMachine { * ssid=zuby * ==== */ - private void setScanResults(String scanResults) { + private void setScanResults() { String bssid = ""; int level = 0; int freq = 0; long tsf = 0; String flags = ""; WifiSsid wifiSsid = null; + String scanResults; + String tmpResults; + StringBuffer scanResultsBuf = new StringBuffer(); + int sid = 0; + + while (true) { + tmpResults = mWifiNative.scanResults(sid); + if (TextUtils.isEmpty(tmpResults)) break; + scanResultsBuf.append(tmpResults); + if (tmpResults.length() < SCAN_BUF_RANGE) break; + String[] lines = tmpResults.split("\n"); + sid = -1; + for (int i=lines.length - 1; i >= 0; i--) { + if (lines[i].startsWith(ID_STR)) { + try { + sid = Integer.parseInt(lines[i].substring(ID_STR.length())) + 1; + } catch (NumberFormatException e) { + // Nothing to do + } + break; + } + } + if (sid == -1) break; + } - if (scanResults == null) { - return; + scanResults = scanResultsBuf.toString(); + if (TextUtils.isEmpty(scanResults)) { + return; } synchronized(mScanResultCache) { @@ -2407,7 +2439,7 @@ public class WifiStateMachine extends StateMachine { sendMessageDelayed(CMD_START_SUPPLICANT, SUPPLICANT_RESTART_INTERVAL_MSECS); break; case WifiMonitor.SCAN_RESULTS_EVENT: - setScanResults(mWifiNative.scanResults()); + setScanResults(); sendScanResultsAvailableBroadcast(); mScanResultIsPending = false; break; |