From 154b2cf6bbb99ee258b289846183172139a87dba Mon Sep 17 00:00:00 2001 From: vandwalle Date: Wed, 23 Jul 2014 16:03:43 -0700 Subject: [PATCH] autojoin fixes: - make use of network scorer for autojoin - Bug:16484607 Change-Id: Ib26cfe31aa5646facf781a2345981e06a6fc36e3 --- wifi/java/android/net/wifi/ScanResult.java | 2 +- .../android/net/wifi/WifiConfiguration.java | 57 +++++++++++++++++-- 2 files changed, 53 insertions(+), 6 deletions(-) diff --git a/wifi/java/android/net/wifi/ScanResult.java b/wifi/java/android/net/wifi/ScanResult.java index 0dbf5cae07ac5..4a4b9ff0a7792 100644 --- a/wifi/java/android/net/wifi/ScanResult.java +++ b/wifi/java/android/net/wifi/ScanResult.java @@ -70,7 +70,7 @@ public class ScanResult implements Parcelable { /** @hide */ public static final int AUTO_JOIN_DISABLED = 32; /** @hide */ - public static final int AUTHENTICATIO_ERROR = 128; + public static final int AUTHENTICATION_ERROR = 128; /** * Status: indicating join status diff --git a/wifi/java/android/net/wifi/WifiConfiguration.java b/wifi/java/android/net/wifi/WifiConfiguration.java index a6c2cc39ec8a7..b48269762c8bb 100644 --- a/wifi/java/android/net/wifi/WifiConfiguration.java +++ b/wifi/java/android/net/wifi/WifiConfiguration.java @@ -25,6 +25,7 @@ import android.net.LinkProperties; import android.os.Parcel; import android.os.Parcelable; import android.text.TextUtils; +import android.annotation.SystemApi; import java.util.HashMap; import java.util.BitSet; @@ -430,8 +431,12 @@ public class WifiConfiguration implements Parcelable { public static int INITIAL_AUTO_JOIN_ATTEMPT_MIN_5 = -70; /** @hide - * 5GHz band is prefered over 2.4 if the 5GHz RSSI is higher than this threshold **/ - public static int A_BAND_PREFERENCE_RSSI_THRESHOLD = -65; + * 5GHz band is prefered low over 2.4 if the 5GHz RSSI is higher than this threshold */ + public static int A_BAND_PREFERENCE_RSSI_THRESHOLD_LOW = -65; + + /** @hide + * 5GHz band is prefered hard over 2.4 if the 5GHz RSSI is higher than this threshold */ + public static int A_BAND_PREFERENCE_RSSI_THRESHOLD = -55; /** @hide * 5GHz band is penalized if the 5GHz RSSI is lower than this threshold **/ @@ -582,21 +587,33 @@ public class WifiConfiguration implements Parcelable { */ public int autoJoinStatus; + /** + * @hide + * Number of connection failures + */ + public int numConnectionFailures; /** * @hide + * Last time we blacklisted the configuration */ public long blackListTimestamp; /** * @hide - * last time the system was connected to this configuration. + * Last time the system was connected to this configuration. */ public long lastConnected; /** * @hide - * last time the system was disconnected to this configuration. + * Last time the system tried to connect and failed. + */ + public long lastConnectionFailure; + + /** + * @hide + * Last time the system was disconnected to this configuration. */ public long lastDisconnected; @@ -619,7 +636,7 @@ public class WifiConfiguration implements Parcelable { public boolean didSelfAdd; /** - * peer WifiConfiguration this WifiConfiguration was added for + * Peer WifiConfiguration this WifiConfiguration was added for * @hide */ public String peerWifiConfiguration; @@ -631,6 +648,24 @@ public class WifiConfiguration implements Parcelable { */ public boolean ephemeral; + /** + * @hide + * Number of time the scorer overrode a the priority based choice, when comparing two + * WifiConfigurations, note that since comparing WifiConfiguration happens very often + * potentially at every scan, this number might become very large, even on an idle + * system. + */ + @SystemApi + public int numScorerOverride; + + /** + * @hide + * Number of time the scorer overrode a the priority based choice, and the comparison + * triggered a network switch + */ + @SystemApi + public int numScorerOverrideAndSwitchedNetwork; + /** * @hide * Connect choices @@ -1148,6 +1183,10 @@ public class WifiConfiguration implements Parcelable { blackListTimestamp = source.blackListTimestamp; lastConnected = source.lastConnected; lastDisconnected = source.lastDisconnected; + lastConnectionFailure = source.lastConnectionFailure; + numConnectionFailures = source.numConnectionFailures; + numScorerOverride = source.numScorerOverride; + numScorerOverrideAndSwitchedNetwork = source.numScorerOverrideAndSwitchedNetwork; } } @@ -1195,6 +1234,10 @@ public class WifiConfiguration implements Parcelable { dest.writeInt(lastUpdateUid); dest.writeInt(bssidOwnerUid); dest.writeLong(blackListTimestamp); + dest.writeLong(lastConnectionFailure); + dest.writeInt(numConnectionFailures); + dest.writeInt(numScorerOverride); + dest.writeInt(numScorerOverrideAndSwitchedNetwork); } /** Implement the Parcelable interface {@hide} */ @@ -1238,6 +1281,10 @@ public class WifiConfiguration implements Parcelable { config.lastUpdateUid = in.readInt(); config.bssidOwnerUid = in.readInt(); config.blackListTimestamp = in.readLong(); + config.lastConnectionFailure = in.readLong(); + config.numConnectionFailures = in.readInt(); + config.numScorerOverride = in.readInt(); + config.numScorerOverrideAndSwitchedNetwork = in.readInt(); return config; }