summaryrefslogtreecommitdiffstats
path: root/wifi/java/android
diff options
context:
space:
mode:
authorvandwalle <vandwalle@google.com>2014-06-02 15:30:39 -0700
committervandwalle <vandwalle@google.com>2014-06-09 14:50:47 -0700
commit2ab9089dfa0c0526e8bf0aaade8a09dec021dc90 (patch)
tree63bd402f29294824c38749afe678338539f2ccdc /wifi/java/android
parentbb1b857841ad10674930f3b88499cd1fe7cc9f24 (diff)
downloadframeworks_base-2ab9089dfa0c0526e8bf0aaade8a09dec021dc90.zip
frameworks_base-2ab9089dfa0c0526e8bf0aaade8a09dec021dc90.tar.gz
frameworks_base-2ab9089dfa0c0526e8bf0aaade8a09dec021dc90.tar.bz2
remember and report network score
Change-Id: Iccb2ec603bc9c0d3cf1976d0cc3f343cb1096494
Diffstat (limited to 'wifi/java/android')
-rw-r--r--wifi/java/android/net/wifi/RssiPacketCountInfo.java6
-rw-r--r--wifi/java/android/net/wifi/WifiConfiguration.java127
-rw-r--r--wifi/java/android/net/wifi/WifiInfo.java140
-rw-r--r--wifi/java/android/net/wifi/WifiLinkLayerStats.java2
4 files changed, 236 insertions, 39 deletions
diff --git a/wifi/java/android/net/wifi/RssiPacketCountInfo.java b/wifi/java/android/net/wifi/RssiPacketCountInfo.java
index f549e1d..0de2033 100644
--- a/wifi/java/android/net/wifi/RssiPacketCountInfo.java
+++ b/wifi/java/android/net/wifi/RssiPacketCountInfo.java
@@ -34,14 +34,17 @@ public class RssiPacketCountInfo implements Parcelable {
public int txbad;
+ public int rxgood;
+
public RssiPacketCountInfo() {
- rssi = txgood = txbad = 0;
+ rssi = txgood = txbad = rxgood = 0;
}
private RssiPacketCountInfo(Parcel in) {
rssi = in.readInt();
txgood = in.readInt();
txbad = in.readInt();
+ rxgood = in.readInt();
}
@Override
@@ -49,6 +52,7 @@ public class RssiPacketCountInfo implements Parcelable {
out.writeInt(rssi);
out.writeInt(txgood);
out.writeInt(txbad);
+ out.writeInt(rxgood);
}
@Override
diff --git a/wifi/java/android/net/wifi/WifiConfiguration.java b/wifi/java/android/net/wifi/WifiConfiguration.java
index 5dfc318..192cba6 100644
--- a/wifi/java/android/net/wifi/WifiConfiguration.java
+++ b/wifi/java/android/net/wifi/WifiConfiguration.java
@@ -347,9 +347,64 @@ public class WifiConfiguration implements Parcelable {
*/
public HashMap<String, ScanResult> scanResultCache;
+ /** The Below RSSI thresholds are used to configure AutoJoin
+ * - GOOD/LOW/BAD thresholds are used so as to calculate link score
+ * - UNWANTED_SOFT are used by the blacklisting logic so as to handle the unwanted network message coming from CS
+ * - UNBLACKLIST thresholds are used so as to tweak the speed at which the network is unblacklisted (i.e. if
+ * it is seen with good RSSI, it is blacklisted faster)
+ * - INITIAL_AUTOJOIN_ATTEMPT, used to determine how close from the network we need to be before autojoin kicks in
+ */
/** @hide **/
public static int INVALID_RSSI = -127;
+ /** @hide **/
+ public static int UNWANTED_BLACKLIST_SOFT_RSSI_24 = -80;
+
+ /** @hide **/
+ public static int UNWANTED_BLACKLIST_SOFT_RSSI_5 = -70;
+
+ /** @hide **/
+ public static int GOOD_RSSI_24 = -65;
+
+ /** @hide **/
+ public static int LOW_RSSI_24 = -75;
+
+ /** @hide **/
+ public static int BAD_RSSI_24 = -85;
+
+ /** @hide **/
+ public static int GOOD_RSSI_5 = -55;
+
+ /** @hide **/
+ public static int LOW_RSSI_5 = -65;
+
+ /** @hide **/
+ public static int BAD_RSSI_5 = -75;
+
+ /** @hide **/
+ public static int UNWANTED_BLACKLIST_SOFT_BUMP = 4;
+
+ /** @hide **/
+ public static int UNWANTED_BLACKLIST_HARD_BUMP = 8;
+
+ /** @hide **/
+ public static int UNBLACKLIST_THRESHOLD_24_SOFT = -75;
+
+ /** @hide **/
+ public static int UNBLACKLIST_THRESHOLD_24_HARD = -68;
+
+ /** @hide **/
+ public static int UNBLACKLIST_THRESHOLD_5_SOFT = -63;
+
+ /** @hide **/
+ public static int UNBLACKLIST_THRESHOLD_5_HARD = -56;
+
+ /** @hide **/
+ public static int INITIAL_AUTO_JOIN_ATTEMPT_MIN_24 = -80;
+
+ /** @hide **/
+ public static int INITIAL_AUTO_JOIN_ATTEMPT_MIN_5 = -70;
+
/**
* @hide
* A summary of the RSSI and Band status for that configuration
@@ -456,7 +511,7 @@ public class WifiConfiguration implements Parcelable {
/** @hide */
public static final int AUTO_JOIN_ENABLED = 0;
- /** @hide
+ /**
* if this is set, the WifiConfiguration cannot use linkages so as to bump
* it's relative priority.
* - status between and 128 indicate various level of blacklisting depending
@@ -465,7 +520,17 @@ public class WifiConfiguration implements Parcelable {
* although it may have been self added we will not re-self-add it, ignore it,
* not return it to applications, and not connect to it
* */
+
+ /** @hide
+ * network was temporary disabled due to bad connection, most likely due
+ * to weak RSSI */
public static final int AUTO_JOIN_TEMPORARY_DISABLED = 1;
+ /** @hide
+ * network was temporary disabled due to bad connection, which cant be attributed
+ * to weak RSSI */
+ public static final int AUTO_JOIN_TEMPORARY_DISABLED_LINK_ERRORS = 32;
+ /** @hide */
+ public static final int AUTO_JOIN_TEMPORARY_DISABLED_AT_SUPPLICANT = 64;
/** @hide */
public static final int AUTO_JOIN_DISABLED_ON_AUTH_FAILURE = 128;
/** @hide */
@@ -476,6 +541,13 @@ public class WifiConfiguration implements Parcelable {
*/
public int autoJoinStatus;
+
+ /**
+ * @hide
+ */
+ public long blackListTimestamp;
+
+
/**
* Set if the configuration was self added by the framework
* This boolean is cleared if we get a connect/save/ update or
@@ -614,6 +686,16 @@ public class WifiConfiguration implements Parcelable {
return mostRecent;
}
+ /** @hide **/
+ public void setAutoJoinStatus(int status) {
+ if (status == 0) {
+ blackListTimestamp = 0;
+ } else if (status > autoJoinStatus) {
+ blackListTimestamp = System.currentTimeMillis();
+ }
+ autoJoinStatus = status;
+ }
+
@Override
public String toString() {
StringBuilder sbuf = new StringBuilder();
@@ -697,6 +779,15 @@ public class WifiConfiguration implements Parcelable {
if (selfAdded) sbuf.append("selfAdded");
if (creatorUid != 0) sbuf.append("uid=" + Integer.toString(creatorUid));
+ if (blackListTimestamp != 0) {
+ long now_ms = System.currentTimeMillis();
+ long diff = now_ms - blackListTimestamp;
+ if (diff <= 0) {
+ sbuf.append("blackListed since <incorrect>");
+ } else {
+ sbuf.append("blackListed since ").append(Long.toString(diff/1000)).append( "sec");
+ }
+ }
return sbuf.toString();
}
@@ -987,6 +1078,7 @@ public class WifiConfiguration implements Parcelable {
lastUpdateUid = source.lastUpdateUid;
creatorUid = source.creatorUid;
peerWifiConfiguration = source.peerWifiConfiguration;
+ blackListTimestamp = source.blackListTimestamp;
}
}
@@ -1030,17 +1122,7 @@ public class WifiConfiguration implements Parcelable {
dest.writeInt(creatorUid);
dest.writeInt(lastConnectUid);
dest.writeInt(lastUpdateUid);
- /*
- TODO: should we write the cache results to the parcel?
- if (scanResultCache != null) {
- dest.writeInt(WifiConfiguration.SCAN_CACHE_TAG);
- dest.writeInt(scanResultCache.size());
- for (ScanResult result : scanResultCache.values()) {
- result.writeToParcel(dest, flags);
- }
- } else {
- dest.writeInt(WifiConfiguration.NOTHING_TAG);
- }*/
+ dest.writeLong(blackListTimestamp);
}
/** Implement the Parcelable interface {@hide} */
@@ -1079,26 +1161,7 @@ public class WifiConfiguration implements Parcelable {
config.creatorUid = in.readInt();
config.lastConnectUid = in.readInt();
config.lastUpdateUid = in.readInt();
- /*
- TODO: should we write the cache results to the parcel?
- boolean done = false;
- do {
- int tag = in.readInt();
- switch (tag) {
- case WifiConfiguration.SCAN_CACHE_TAG:
- int size = in.readInt();
- config.scanResultCache = new HashMap<String, ScanResult>();
- while (size > 0) {
- ScanResult result = ScanResult.CREATOR.createFromParcel(in);
- config.scanResultCache.put(result.BSSID, result);
- size--;
- }
- break;
- case WifiConfiguration.NOTHING_TAG:
- done = true;
- break;
- }
- } while (!done);*/
+ config.blackListTimestamp = in.readLong();
return config;
}
diff --git a/wifi/java/android/net/wifi/WifiInfo.java b/wifi/java/android/net/wifi/WifiInfo.java
index f44cb0a..f6a94d0 100644
--- a/wifi/java/android/net/wifi/WifiInfo.java
+++ b/wifi/java/android/net/wifi/WifiInfo.java
@@ -40,7 +40,7 @@ public class WifiInfo implements Parcelable {
* of <code>DetailedState</code>.
*/
private static final EnumMap<SupplicantState, DetailedState> stateMap =
- new EnumMap<SupplicantState, DetailedState>(SupplicantState.class);
+ new EnumMap<SupplicantState, DetailedState>(SupplicantState.class);
static {
stateMap.put(SupplicantState.DISCONNECTED, DetailedState.DISCONNECTED);
@@ -62,14 +62,20 @@ public class WifiInfo implements Parcelable {
private String mBSSID;
private WifiSsid mWifiSsid;
private int mNetworkId;
- /** Received Signal Strength Indicator */
+ /**
+ * Received Signal Strength Indicator
+ */
private int mRssi;
- /** Link speed in Mbps */
+ /**
+ * Link speed in Mbps
+ */
public static final String LINK_SPEED_UNITS = "Mbps";
private int mLinkSpeed;
- /** Frequency in MHz */
+ /**
+ * Frequency in MHz
+ */
public static final String FREQUENCY_UNITS = "MHz";
private int mFrequency;
@@ -77,6 +83,87 @@ public class WifiInfo implements Parcelable {
private String mMacAddress;
/**
+ * @hide
+ */
+ public long txBad;
+ /**
+ * @hide
+ */
+ public long txRetries;
+ /**
+ * @hide
+ */
+ public long txSuccess;
+ /**
+ * @hide
+ */
+ public long rxSuccess;
+ /**
+ * @hide
+ */
+ public double txBadRate;
+ /**
+ * @hide
+ */
+ public double txRetriesRate;
+ /**
+ * @hide
+ */
+ public double txSuccessRate;
+ /**
+ * @hide
+ */
+ public double rxSuccessRate;
+
+ /**
+ * @hide
+ */
+ public int badRssiCount;
+
+ /**
+ * @hide
+ */
+ public int lowRssiCount;
+
+ /**
+ * @hide *
+ */
+ public int score;
+
+ /**
+ * @hide *
+ */
+ public void updatePacketRates(WifiLinkLayerStats stats) {
+ if (stats != null) {
+ long txgood = stats.txmpdu_be + stats.txmpdu_bk + stats.txmpdu_vi + stats.txmpdu_vo;
+ long txretries = stats.retries_be + stats.retries_bk
+ + stats.retries_vi + stats.retries_vo;
+ long rxgood = stats.rxmpdu_be + stats.rxmpdu_bk + stats.rxmpdu_vi + stats.rxmpdu_vo;
+ long txbad = stats.lostmpdu_be + stats.lostmpdu_bk
+ + stats.lostmpdu_vi + stats.lostmpdu_vo;
+
+ txBadRate = (txBadRate * 0.5)
+ + ((double) (txbad - txBad) * 0.5);
+ txSuccessRate = (txSuccessRate * 0.5)
+ + ((double) (txgood - txSuccess) * 0.5);
+ rxSuccessRate = (rxSuccessRate * 0.5)
+ + ((double) (rxgood - rxSuccess) * 0.5);
+ txRetriesRate = (txRetriesRate * 0.5)
+ + ((double) (txretries - txRetries) * 0.5);
+
+ txBad = txbad;
+ txSuccess = txgood;
+ rxSuccess = rxgood;
+ txRetries = txretries;
+ } else {
+ txBadRate = 0;
+ txSuccess = 0;
+ rxSuccess = 0;
+ txRetries = 0;
+ }
+ }
+
+ /**
* Flag indicating that AP has hinted that upstream connection is metered,
* and sensitive to heavy data transfers.
*/
@@ -109,6 +196,17 @@ public class WifiInfo implements Parcelable {
mIpAddress = source.mIpAddress;
mMacAddress = source.mMacAddress;
mMeteredHint = source.mMeteredHint;
+ txBad = source.txBad;
+ txRetries = source.txRetries;
+ txSuccess = source.txSuccess;
+ rxSuccess = source.rxSuccess;
+ txBadRate = source.txBadRate;
+ txRetriesRate = source.txRetriesRate;
+ txSuccessRate = source.txSuccessRate;
+ rxSuccessRate = source.rxSuccessRate;
+ score = source.score;
+ badRssiCount = source.badRssiCount;
+ lowRssiCount = source.lowRssiCount;
}
}
@@ -198,6 +296,22 @@ public class WifiInfo implements Parcelable {
}
/**
+ * @hide
+ * TODO: makes real freq boundaries
+ */
+ public boolean is24GHz() {
+ return mFrequency < 4000;
+ }
+
+ /**
+ * @hide
+ * TODO: makes real freq boundaries
+ */
+ public boolean is5GHz() {
+ return mFrequency > 4000;
+ }
+
+ /**
* Record the MAC address of the WLAN interface
* @param macAddress the MAC address in {@code XX:XX:XX:XX:XX:XX} form
* @hide
@@ -325,8 +439,8 @@ public class WifiInfo implements Parcelable {
append(", Link speed: ").append(mLinkSpeed).append(LINK_SPEED_UNITS).
append(", Frequency: ").append(mFrequency).append(FREQUENCY_UNITS).
append(", Net ID: ").append(mNetworkId).
- append(", Metered hint: ").append(mMeteredHint);
-
+ append(", Metered hint: ").append(mMeteredHint).
+ append(", score: ").append(Integer.toString(score));
return sb.toString();
}
@@ -356,6 +470,13 @@ public class WifiInfo implements Parcelable {
dest.writeString(mBSSID);
dest.writeString(mMacAddress);
dest.writeInt(mMeteredHint ? 1 : 0);
+ dest.writeInt(score);
+ dest.writeDouble(txSuccessRate);
+ dest.writeDouble(txRetriesRate);
+ dest.writeDouble(txBadRate);
+ dest.writeDouble(rxSuccessRate);
+ dest.writeInt(badRssiCount);
+ dest.writeInt(lowRssiCount);
mSupplicantState.writeToParcel(dest, flags);
}
@@ -379,6 +500,13 @@ public class WifiInfo implements Parcelable {
info.mBSSID = in.readString();
info.mMacAddress = in.readString();
info.mMeteredHint = in.readInt() != 0;
+ info.score = in.readInt();
+ info.txSuccessRate = in.readDouble();
+ info.txRetriesRate = in.readDouble();
+ info.txBadRate = in.readDouble();
+ info.rxSuccessRate = in.readDouble();
+ info.badRssiCount = in.readInt();
+ info.lowRssiCount = in.readInt();
info.mSupplicantState = SupplicantState.CREATOR.createFromParcel(in);
return info;
}
diff --git a/wifi/java/android/net/wifi/WifiLinkLayerStats.java b/wifi/java/android/net/wifi/WifiLinkLayerStats.java
index 922eddd..ae2fa98 100644
--- a/wifi/java/android/net/wifi/WifiLinkLayerStats.java
+++ b/wifi/java/android/net/wifi/WifiLinkLayerStats.java
@@ -111,6 +111,8 @@ public class WifiLinkLayerStats implements Parcelable {
/** {@hide} */
public String toString() {
StringBuilder sbuf = new StringBuilder();
+ sbuf.append(" WifiLinkLayerStats: ").append('\n');
+
if (this.SSID != null) {
sbuf.append(" SSID: ").append(this.SSID).append('\n');
}