summaryrefslogtreecommitdiffstats
path: root/wifi/java/android/net
diff options
context:
space:
mode:
authorIliyan Malchev <malchev@google.com>2013-06-21 03:09:44 +0000
committerIliyan Malchev <malchev@google.com>2013-06-21 03:10:20 +0000
commit9233fc0023755e190e7c28374c5c6fa6558dec70 (patch)
tree1fbb8d3c3b415ec0493303cb95f4e710a57168c2 /wifi/java/android/net
parent748f6c854822c01ebf805202935037300d351104 (diff)
downloadframeworks_base-9233fc0023755e190e7c28374c5c6fa6558dec70.zip
frameworks_base-9233fc0023755e190e7c28374c5c6fa6558dec70.tar.gz
frameworks_base-9233fc0023755e190e7c28374c5c6fa6558dec70.tar.bz2
Revert "Revert "wifi: Get full scan results""
This reverts commit c2cbd4c11bfb83344502bd80389538795bae03cb. Change-Id: Ia1cbde588ae9706966d6340c702fcfe1a82cfa79
Diffstat (limited to 'wifi/java/android/net')
-rw-r--r--wifi/java/android/net/wifi/WifiNative.java6
-rw-r--r--wifi/java/android/net/wifi/WifiStateMachine.java41
2 files changed, 40 insertions, 7 deletions
diff --git a/wifi/java/android/net/wifi/WifiNative.java b/wifi/java/android/net/wifi/WifiNative.java
index ab289b3..f637e89 100644
--- a/wifi/java/android/net/wifi/WifiNative.java
+++ b/wifi/java/android/net/wifi/WifiNative.java
@@ -198,6 +198,7 @@ public class WifiNative {
/**
* Format of results:
* =================
+ * id=1
* bssid=68:7f:74:d7:1b:6e
* freq=2412
* level=-43
@@ -208,10 +209,11 @@ public class WifiNative {
* ====
*
* 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=0x21987");
+ public String scanResults(int sid) {
+ return doStringCommand("BSS RANGE=" + sid + "- MASK=0x21987");
}
public boolean startDriver() {
diff --git a/wifi/java/android/net/wifi/WifiStateMachine.java b/wifi/java/android/net/wifi/WifiStateMachine.java
index 32d48ac..3e3752e 100644
--- a/wifi/java/android/net/wifi/WifiStateMachine.java
+++ b/wifi/java/android/net/wifi/WifiStateMachine.java
@@ -67,8 +67,8 @@ import android.os.SystemProperties;
import android.os.UserHandle;
import android.os.WorkSource;
import android.provider.Settings;
-import android.text.TextUtils;
import android.util.LruCache;
+import android.text.TextUtils;
import com.android.internal.R;
import com.android.internal.app.IBatteryStats;
@@ -1337,6 +1337,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=";
@@ -1348,6 +1349,8 @@ public class WifiStateMachine extends StateMachine {
/**
* Format:
+ *
+ * id=1
* bssid=68:7f:76:d7:1a:6e
* freq=2412
* level=-44
@@ -1355,6 +1358,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
@@ -1363,16 +1367,43 @@ 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);
+ scanResultsBuf.append("\n");
+ String[] lines = tmpResults.split("\n");
+ sid = -1;
+ for (int i=lines.length - 1; i >= 0; i--) {
+ if (lines[i].startsWith(END_STR)) {
+ break;
+ } else 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) {
@@ -2198,7 +2229,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;