summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--wifi/java/android/net/wifi/ScanResult.java9
-rw-r--r--wifi/java/android/net/wifi/WifiConfiguration.java82
-rw-r--r--wifi/java/android/net/wifi/WifiInfo.java1
3 files changed, 79 insertions, 13 deletions
diff --git a/wifi/java/android/net/wifi/ScanResult.java b/wifi/java/android/net/wifi/ScanResult.java
index 29656c9..9729c91 100644
--- a/wifi/java/android/net/wifi/ScanResult.java
+++ b/wifi/java/android/net/wifi/ScanResult.java
@@ -71,6 +71,12 @@ public class ScanResult implements Parcelable {
public long seen;
/**
+ * If the scan result is a valid autojoin candidate
+ * {@hide}
+ */
+ public int isAutoJoinCandidate;
+
+ /**
* @hide
* Update RSSI of the scan result
* @param previousRSSI
@@ -263,6 +269,7 @@ public class ScanResult implements Parcelable {
numConnection = source.numConnection;
numUsage = source.numUsage;
numIpConfigFailures = source.numIpConfigFailures;
+ isAutoJoinCandidate = source.isAutoJoinCandidate;
}
}
@@ -328,6 +335,7 @@ public class ScanResult implements Parcelable {
dest.writeInt(numConnection);
dest.writeInt(numUsage);
dest.writeInt(numIpConfigFailures);
+ dest.writeInt(isAutoJoinCandidate);
if (informationElements != null) {
dest.writeInt(informationElements.length);
for (int i = 0; i < informationElements.length; i++) {
@@ -364,6 +372,7 @@ public class ScanResult implements Parcelable {
sr.numConnection = in.readInt();
sr.numUsage = in.readInt();
sr.numIpConfigFailures = in.readInt();
+ sr.isAutoJoinCandidate = in.readInt();
int n = in.readInt();
if (n != 0) {
sr.informationElements = new InformationElement[n];
diff --git a/wifi/java/android/net/wifi/WifiConfiguration.java b/wifi/java/android/net/wifi/WifiConfiguration.java
index 53756d2..02e610c 100644
--- a/wifi/java/android/net/wifi/WifiConfiguration.java
+++ b/wifi/java/android/net/wifi/WifiConfiguration.java
@@ -29,6 +29,9 @@ import android.annotation.SystemApi;
import java.util.HashMap;
import java.util.BitSet;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
/**
* A class representing a configured Wi-Fi network, including the
@@ -908,13 +911,46 @@ public class WifiConfiguration implements Parcelable {
}
}
+ /* @hide */
+ private ArrayList<ScanResult> sortScanResults() {
+ ArrayList<ScanResult> list = new ArrayList<ScanResult>(this.scanResultCache.values());
+ if (list.size() != 0) {
+ Collections.sort(list, new Comparator() {
+ public int compare(Object o1, Object o2) {
+ ScanResult a = (ScanResult)o1;
+ ScanResult b = (ScanResult)o2;
+ if (a.numIpConfigFailures > b.numIpConfigFailures) {
+ return 1;
+ }
+ if (a.numIpConfigFailures < b.numIpConfigFailures) {
+ return -1;
+ }
+ if (a.seen > b.seen) {
+ return -1;
+ }
+ if (a.seen < b.seen) {
+ return 1;
+ }
+ if (a.level > b.level) {
+ return -1;
+ }
+ if (a.level < b.level) {
+ return 1;
+ }
+ return a.BSSID.compareTo(b.BSSID);
+ }
+ });
+ }
+ return list;
+ }
+
@Override
public String toString() {
StringBuilder sbuf = new StringBuilder();
if (this.status == WifiConfiguration.Status.CURRENT) {
sbuf.append("* ");
} else if (this.status == WifiConfiguration.Status.DISABLED) {
- sbuf.append("- DSBLE");
+ sbuf.append("- DSBLE ");
}
sbuf.append("ID: ").append(this.networkId).append(" SSID: ").append(this.SSID).
append(" BSSID: ").append(this.BSSID).append(" FQDN: ").append(this.FQDN).
@@ -1061,20 +1097,40 @@ public class WifiConfiguration implements Parcelable {
}
}
if (this.scanResultCache != null) {
- sbuf.append("Scan Cache: ");
- for(ScanResult result : this.scanResultCache.values()) {
- sbuf.append("{").append(result.BSSID).append(",").append(result.frequency);
- sbuf.append(",").append(result.level);
- if (result.autoJoinStatus > 0) {
- sbuf.append(",st=").append(result.autoJoinStatus);
+ sbuf.append("Scan Cache: ").append('\n');
+ ArrayList<ScanResult> list = sortScanResults();
+ if (list.size() > 0) {
+ for (ScanResult result : list) {
+ long milli = now_ms - result.seen;
+ long ageSec = 0;
+ long ageMin = 0;
+ long ageHour = 0;
+ long ageMilli = 0;
+ long ageDay = 0;
+ if (now_ms > result.seen && result.seen > 0) {
+ ageMilli = milli % 1000;
+ ageSec = (milli / 1000) % 60;
+ ageMin = (milli / (60*1000)) % 60;
+ ageHour = (milli / (60*60*1000)) % 24;
+ ageDay = (milli / (24*60*60*1000));
+ }
+ sbuf.append("{").append(result.BSSID).append(",").append(result.frequency);
+ sbuf.append(",").append(String.format("%3d", result.level));
+ if (result.autoJoinStatus > 0) {
+ sbuf.append(",st=").append(result.autoJoinStatus);
+ }
+ if (ageSec > 0 || ageMilli > 0) {
+ sbuf.append(String.format(",%4d.%02d.%02d.%02d.%03dms", ageDay,
+ ageHour, ageMin, ageSec, ageMilli));
+ }
+ if (result.numIpConfigFailures > 0) {
+ sbuf.append(",ipfail=");
+ sbuf.append(result.numIpConfigFailures);
+ }
+ sbuf.append("} ");
}
- if (result.numIpConfigFailures > 0) {
- sbuf.append(",ipfail=");
- sbuf.append(result.numIpConfigFailures);
- }
- sbuf.append(",").append(result.autoJoinStatus).append("} ");
+ sbuf.append('\n');
}
- sbuf.append('\n');
}
sbuf.append("triggeredLow: ").append(this.numUserTriggeredWifiDisableLowRSSI);
sbuf.append(" triggeredBad: ").append(this.numUserTriggeredWifiDisableBadRSSI);
diff --git a/wifi/java/android/net/wifi/WifiInfo.java b/wifi/java/android/net/wifi/WifiInfo.java
index 44a7108..5bf3470 100644
--- a/wifi/java/android/net/wifi/WifiInfo.java
+++ b/wifi/java/android/net/wifi/WifiInfo.java
@@ -456,6 +456,7 @@ public class WifiInfo implements Parcelable {
* SSID-specific probe request must be used for scans.
*/
public boolean getHiddenSSID() {
+ if (mWifiSsid == null) return false;
return mWifiSsid.isHidden();
}