am b75369e2: am 7bbf867b: am 0c0c680d: am a741efd5: Merge "adding debug information to bug report for Bug:16751877" into lmp-dev
* commit 'b75369e22c4617371606571398f0faa0838f02ef':
adding debug information to bug report for Bug:16751877
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 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 @@
numConnection = source.numConnection;
numUsage = source.numUsage;
numIpConfigFailures = source.numIpConfigFailures;
+ isAutoJoinCandidate = source.isAutoJoinCandidate;
}
}
@@ -328,6 +335,7 @@
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 @@
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 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 @@
}
}
+ /* @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 @@
}
}
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 @@
* SSID-specific probe request must be used for scans.
*/
public boolean getHiddenSSID() {
+ if (mWifiSsid == null) return false;
return mWifiSsid.isHidden();
}