Loading wifi/java/android/net/wifi/ScanResult.java +15 −0 Original line number Diff line number Diff line Loading @@ -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 Loading wifi/java/android/net/wifi/WifiConfiguration.java +35 −4 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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; Loading @@ -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; Loading Loading @@ -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 Loading Loading @@ -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; } /** Loading Loading @@ -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) { Loading Loading @@ -1079,6 +1108,8 @@ public class WifiConfiguration implements Parcelable { creatorUid = source.creatorUid; peerWifiConfiguration = source.peerWifiConfiguration; blackListTimestamp = source.blackListTimestamp; lastConnected = source.lastConnected; lastDisconnected = source.lastDisconnected; } } Loading wifi/java/android/net/wifi/WifiInfo.java +70 −6 Original line number Diff line number Diff line Loading @@ -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 */ Loading Loading @@ -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) { Loading @@ -156,13 +168,38 @@ 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; } } /** * 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. Loading @@ -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); } /** Loading Loading @@ -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; Loading @@ -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; } Loading Loading
wifi/java/android/net/wifi/ScanResult.java +15 −0 Original line number Diff line number Diff line Loading @@ -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 Loading
wifi/java/android/net/wifi/WifiConfiguration.java +35 −4 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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; Loading @@ -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; Loading Loading @@ -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 Loading Loading @@ -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; } /** Loading Loading @@ -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) { Loading Loading @@ -1079,6 +1108,8 @@ public class WifiConfiguration implements Parcelable { creatorUid = source.creatorUid; peerWifiConfiguration = source.peerWifiConfiguration; blackListTimestamp = source.blackListTimestamp; lastConnected = source.lastConnected; lastDisconnected = source.lastDisconnected; } } Loading
wifi/java/android/net/wifi/WifiInfo.java +70 −6 Original line number Diff line number Diff line Loading @@ -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 */ Loading Loading @@ -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) { Loading @@ -156,13 +168,38 @@ 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; } } /** * 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. Loading @@ -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); } /** Loading Loading @@ -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; Loading @@ -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; } Loading