diff options
author | vandwalle <vandwalle@google.com> | 2014-06-10 20:47:58 -0700 |
---|---|---|
committer | vandwalle <vandwalle@google.com> | 2014-06-11 14:38:06 -0700 |
commit | 111fa0274d1d6620f9634783585387f3b773949e (patch) | |
tree | eb89259b273e2d4e6594494556d540aec6c2dcbc /wifi/java/android | |
parent | 961dda77965203da05df2c865d42a1968d622343 (diff) | |
download | frameworks_base-111fa0274d1d6620f9634783585387f3b773949e.zip frameworks_base-111fa0274d1d6620f9634783585387f3b773949e.tar.gz frameworks_base-111fa0274d1d6620f9634783585387f3b773949e.tar.bz2 |
auto-roam initial implementation
Change-Id: Iad207974b2fea97420cc6131c5fa0a1f17bf2aac
Diffstat (limited to 'wifi/java/android')
-rw-r--r-- | wifi/java/android/net/wifi/ScanResult.java | 15 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/WifiConfiguration.java | 39 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/WifiInfo.java | 76 |
3 files changed, 120 insertions, 10 deletions
diff --git a/wifi/java/android/net/wifi/ScanResult.java b/wifi/java/android/net/wifi/ScanResult.java index 99151c3..8191edd 100644 --- a/wifi/java/android/net/wifi/ScanResult.java +++ b/wifi/java/android/net/wifi/ScanResult.java @@ -89,6 +89,21 @@ public class ScanResult implements Parcelable { * {@hide} */ public final static int UNSPECIFIED = -1; + /** + * @hide + * TODO: makes real freq boundaries + */ + public boolean is24GHz() { + return frequency > 2400 && frequency < 2500; + } + + /** + * @hide + * TODO: makes real freq boundaries + */ + public boolean is5GHz() { + return frequency > 4900 && frequency < 5900; + } /** information element from beacon * @hide diff --git a/wifi/java/android/net/wifi/WifiConfiguration.java b/wifi/java/android/net/wifi/WifiConfiguration.java index 192cba6..48396d5 100644 --- a/wifi/java/android/net/wifi/WifiConfiguration.java +++ b/wifi/java/android/net/wifi/WifiConfiguration.java @@ -405,6 +405,10 @@ public class WifiConfiguration implements Parcelable { /** @hide **/ 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; + /** * @hide * A summary of the RSSI and Band status for that configuration @@ -481,11 +485,11 @@ public class WifiConfiguration implements Parcelable { if (result.seen == 0) continue; - if ((result.frequency > 4900) && (result.frequency < 5900)) { + if (result.is5GHz()) { //strictly speaking: [4915, 5825] //number of known BSSID on 5GHz band status.num5 = status.num5 + 1; - } else if ((result.frequency > 2400) && (result.frequency < 2500)) { + } else if (result.is24GHz()) { //strictly speaking: [2412, 2482] //number of known BSSID on 2.4Ghz band status.num24 = status.num24 + 1; @@ -493,12 +497,12 @@ public class WifiConfiguration implements Parcelable { if ((now_ms - result.seen) > age) continue; - if ((result.frequency > 4900) && (result.frequency < 5900)) { + if (result.is5GHz()) { if (result.level > status.rssi5) { status.rssi5 = result.level; status.age5 = result.seen; } - } else if ((result.frequency > 2400) && (result.frequency < 2500)) { + } else if (result.is24GHz()) { if (result.level > status.rssi24) { status.rssi24 = result.level; status.age24 = result.seen; @@ -547,6 +551,17 @@ public class WifiConfiguration implements Parcelable { */ public long blackListTimestamp; + /** + * @hide + * last time the system was connected to this configuration. + */ + public long lastConnected; + + /** + * @hide + * last time the system was disconnected to this configuration. + */ + public long lastDisconnected; /** * Set if the configuration was self added by the framework @@ -658,7 +673,20 @@ public class WifiConfiguration implements Parcelable { // TODO: Add more checks return true; + } + /** + * Helper function, identify if a configuration is linked + * @hide + */ + public boolean isLinked(WifiConfiguration config) { + if (config.linkedConfigurations != null && linkedConfigurations != null) { + if (config.linkedConfigurations.get(configKey()) != null + && linkedConfigurations.get(config.configKey()) != null) { + return true; + } + } + return false; } /** @@ -688,6 +716,7 @@ public class WifiConfiguration implements Parcelable { /** @hide **/ public void setAutoJoinStatus(int status) { + if (status < 0) status = 0; if (status == 0) { blackListTimestamp = 0; } else if (status > autoJoinStatus) { @@ -1079,6 +1108,8 @@ public class WifiConfiguration implements Parcelable { creatorUid = source.creatorUid; peerWifiConfiguration = source.peerWifiConfiguration; blackListTimestamp = source.blackListTimestamp; + lastConnected = source.lastConnected; + lastDisconnected = source.lastDisconnected; } } diff --git a/wifi/java/android/net/wifi/WifiInfo.java b/wifi/java/android/net/wifi/WifiInfo.java index f6a94d0..8abc6b8 100644 --- a/wifi/java/android/net/wifi/WifiInfo.java +++ b/wifi/java/android/net/wifi/WifiInfo.java @@ -62,6 +62,17 @@ public class WifiInfo implements Parcelable { private String mBSSID; private WifiSsid mWifiSsid; private int mNetworkId; + + /** @hide **/ + public static final int INVALID_RSSI = -127; + + /** @hide **/ + public static final int MIN_RSSI = -126; + + /** @hide **/ + public static final int MAX_RSSI = 200; + + /** * Received Signal Strength Indicator */ @@ -131,7 +142,8 @@ public class WifiInfo implements Parcelable { public int score; /** - * @hide * + * TODO: get actual timestamp and calculate true rates + * @hide */ public void updatePacketRates(WifiLinkLayerStats stats) { if (stats != null) { @@ -156,17 +168,42 @@ public class WifiInfo implements Parcelable { rxSuccess = rxgood; txRetries = txretries; } else { - txBadRate = 0; + txBad = 0; txSuccess = 0; rxSuccess = 0; txRetries = 0; + txBadRate = 0; + txSuccessRate = 0; + rxSuccessRate = 0; + txRetriesRate = 0; } } + /** - * Flag indicating that AP has hinted that upstream connection is metered, - * and sensitive to heavy data transfers. + * This function is less powerful and used if the WifiLinkLayerStats API is not implemented + * at the Wifi HAL + * @hide */ + public void updatePacketRates(long txPackets, long rxPackets) { + //paranoia + txBad = 0; + txRetries = 0; + txBadRate = 0; + txRetriesRate = 0; + + txSuccessRate = (txSuccessRate * 0.5) + + ((double) (txPackets - txSuccess) * 0.5); + rxSuccessRate = (rxSuccessRate * 0.5) + + ((double) (rxPackets - rxSuccess) * 0.5); + txSuccess = txPackets; + rxSuccess = rxPackets; + } + + /** + * Flag indicating that AP has hinted that upstream connection is metered, + * and sensitive to heavy data transfers. + */ private boolean mMeteredHint; /** @hide */ @@ -175,9 +212,32 @@ public class WifiInfo implements Parcelable { mBSSID = null; mNetworkId = -1; mSupplicantState = SupplicantState.UNINITIALIZED; - mRssi = -9999; + mRssi = INVALID_RSSI; mLinkSpeed = -1; mFrequency = -1; + txBad = 0; + txSuccess = 0; + rxSuccess = 0; + txRetries = 0; + txBadRate = 0; + txSuccessRate = 0; + rxSuccessRate = 0; + txRetriesRate = 0; + lowRssiCount = 0; + badRssiCount = 0; + score = 0; + } + + /** @hide */ + public void reset() { + setInetAddress(null); + setBSSID(null); + setSSID(null); + setNetworkId(-1); + setRssi(INVALID_RSSI); + setLinkSpeed(-1); + setFrequency(-1); + setMeteredHint(false); } /** @@ -256,7 +316,7 @@ public class WifiInfo implements Parcelable { /** * Returns the received signal strength indicator of the current 802.11 * network, in dBm. - * @return the RSSI, in the range -110 to 10 + * @return the RSSI, in the range -127 to 200 */ public int getRssi() { return mRssi; @@ -264,6 +324,10 @@ public class WifiInfo implements Parcelable { /** @hide */ public void setRssi(int rssi) { + if (rssi < INVALID_RSSI) + rssi = INVALID_RSSI; + if (rssi > MAX_RSSI) + rssi = MAX_RSSI; mRssi = rssi; } |