diff --git a/res/values/strings.xml b/res/values/strings.xml
index 706f13f0277..020f98b15fa 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -3153,10 +3153,12 @@
Wireless display certification
-
+
Enable WiFi Verbose Logging
Show options for wireless display certification
+
+ Increase Wifi logging level, show per SSID RSSI in WiFi Picker
Allow mock locations
diff --git a/res/xml/development_prefs.xml b/res/xml/development_prefs.xml
index 1d7d9677f41..d4353710871 100644
--- a/res/xml/development_prefs.xml
+++ b/res/xml/development_prefs.xml
@@ -109,6 +109,7 @@
+ android:summary="@string/wifi_verbose_logging_summary"/>
diff --git a/src/com/android/settings/wifi/AccessPoint.java b/src/com/android/settings/wifi/AccessPoint.java
index 688fc6396c1..4ac91129a8a 100644
--- a/src/com/android/settings/wifi/AccessPoint.java
+++ b/src/com/android/settings/wifi/AccessPoint.java
@@ -28,9 +28,13 @@ import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.preference.Preference;
import android.util.Log;
+import android.util.LruCache;
import android.view.View;
import android.widget.ImageView;
+import java.util.Map;
+
+
class AccessPoint extends Preference {
static final String TAG = "Settings.AccessPoint";
@@ -74,6 +78,21 @@ class AccessPoint extends Preference {
private WifiInfo mInfo;
private DetailedState mState;
+ private static final int VISIBILITY_MAX_AGE_IN_MILLI = 1000000;
+ private static final int VISIBILITY_OUTDATED_AGE_IN_MILLI = 20000;
+ private static final int LOWER_FREQ_24GHZ = 2400;
+ private static final int HIGHER_FREQ_24GHZ = 2500;
+ private static final int LOWER_FREQ_5GHZ = 4900;
+ private static final int HIGHER_FREQ_5GHZ = 5900;
+ private static final int SECOND_TO_MILLI = 1000;
+
+ /** Experiemental: we should be able to show the user the list of BSSIDs and bands
+ * for that SSID.
+ * For now this data is used only with Verbose Logging so as to show the band and number
+ * of BSSIDs on which that network is seen.
+ */
+ public LruCache scanResultCache;
+
static int getSecurity(WifiConfiguration config) {
if (config.allowedKeyManagement.get(KeyMgmt.WPA_PSK)) {
return SECURITY_PSK;
@@ -201,6 +220,9 @@ class AccessPoint extends Preference {
pskType = getPskType(result);
mRssi = result.level;
mScanResult = result;
+ if (result.seen > mSeen) {
+ mSeen = result.seen;
+ }
}
@Override
@@ -267,6 +289,13 @@ class AccessPoint extends Preference {
if (result.seen > mSeen) {
mSeen = result.seen;
}
+ if (WifiSettings.mVerboseLogging > 0) {
+ if (scanResultCache == null) {
+ scanResultCache = new LruCache(32);
+ }
+ scanResultCache.put(result.BSSID, result);
+ }
+
if (ssid.equals(result.SSID) && security == getSecurity(result)) {
if (WifiManager.compareSignalLevel(result.level, mRssi) > 0) {
int oldLevel = getLevel();
@@ -340,25 +369,84 @@ class AccessPoint extends Preference {
/** visibility status of the WifiConfiguration
* @return RSSI and update indicator
- * TODO: indicate both 2.4 and 5GHz RSSI as well as number of results
+ * TODO: use a string formatter
* ["rssi 5Ghz", "num results on 5GHz" / "rssi 5Ghz", "num results on 5GHz"]
* For instance [-40,5/-30,2]
*/
private String getVisibilityStatus() {
- String visibility ;
+ StringBuilder visibility = new StringBuilder();
+
long now = System.currentTimeMillis();
long age = (now - mSeen);
- if (age < 1000000) {
+ if (age < VISIBILITY_MAX_AGE_IN_MILLI) {
//show age in seconds, in the form xx
- visibility = Long.toString((age / 1000) % 1000);
+ visibility.append(Long.toString((age / SECOND_TO_MILLI) % SECOND_TO_MILLI));
} else {
//not seen for more than 1000 seconds
- visibility = "!";
+ visibility.append("!");
}
- if (mRssi != Integer.MAX_VALUE) {
- visibility = visibility + ", " + Integer.toString(mRssi);
+
+ if (scanResultCache != null) {
+ int rssi5 = WifiConfiguration.INVALID_RSSI;
+ int rssi24 = WifiConfiguration.INVALID_RSSI;
+ int num5 = 0;
+ int num24 = 0;
+ Map list = scanResultCache.snapshot();
+ for (ScanResult result : list.values()) {
+ if (result.seen == 0)
+ continue;
+
+ if (result.frequency > LOWER_FREQ_5GHZ
+ && result.frequency < HIGHER_FREQ_5GHZ) {
+ //strictly speaking: [4915, 5825]
+ //number of known BSSID on 5GHz band
+ num5 = num5 + 1;
+ } else if (result.frequency > LOWER_FREQ_24GHZ
+ && result.frequency < HIGHER_FREQ_24GHZ) {
+ //strictly speaking: [2412, 2482]
+ //number of known BSSID on 2.4Ghz band
+ num24 = num24 + 1;
+ }
+
+ //ignore results seen, older than 20 seconds
+ if (now - result.seen > VISIBILITY_OUTDATED_AGE_IN_MILLI) continue;
+
+ if (result.frequency > LOWER_FREQ_5GHZ
+ &&result.frequency < HIGHER_FREQ_5GHZ) {
+ if (result.level > rssi5) {
+ rssi5 = result.level;
+ }
+ } else if (result.frequency > LOWER_FREQ_24GHZ
+ && result.frequency < HIGHER_FREQ_24GHZ) {
+ if (result.level > rssi24) {
+ rssi24 = result.level;
+ }
+ }
+ }
+ visibility.append(" [");
+ if (num24 > 0 || rssi24 > WifiConfiguration.INVALID_RSSI) {
+ visibility.append(Integer.toString(rssi24));
+ visibility.append(",");
+ visibility.append(Integer.toString(num24));
+ }
+ visibility.append(";");
+ if (num5 > 0 || rssi5 > WifiConfiguration.INVALID_RSSI) {
+ visibility.append(Integer.toString(rssi5));
+ visibility.append(",");
+ visibility.append(Integer.toString(num5));
+ }
+ visibility.append("]");
+ } else {
+ if (mRssi != Integer.MAX_VALUE) {
+ visibility.append(", ");
+ visibility.append(Integer.toString(mRssi));
+ if (mScanResult != null) {
+ visibility.append(", ");
+ visibility.append(Integer.toString(mScanResult.frequency));
+ }
+ }
}
- return visibility;
+ return visibility.toString();
}
/** Updates the title and summary; may indirectly call notifyChanged() */
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index 604275ad442..a6539105ec8 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -178,6 +178,10 @@ public class WifiSettings extends RestrictedSettingsFragment
private SwitchBar mSwitchBar;
+ /** verbose logging flag. this flag is set thru developer debugging options
+ * and used so as to assist with in-the-field WiFi connectivity debugging */
+ public static int mVerboseLogging = 0;
+
/* End of "used in Wifi Setup context" */
public WifiSettings() {
@@ -712,8 +716,6 @@ public class WifiSettings extends RestrictedSettingsFragment
return super.onCreateDialog(dialogId);
}
- /** verbose logging flag is set only thru developer debugging options */
- public static int mVerboseLogging = 0;
/**
* Shows the latest access points available with supplimental information like
* the strength of network and the security for it.
@@ -728,7 +730,7 @@ public class WifiSettings extends RestrictedSettingsFragment
}
final int wifiState = mWifiManager.getWifiState();
- //check if verbose logging has been turned on or off
+ //when we update the screen, check if verbose logging has been turned on or off
mVerboseLogging = mWifiManager.getVerboseLoggingLevel();
switch (wifiState) {