Loading wifi/java/android/net/wifi/IWifiManager.aidl +4 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,8 @@ import android.net.wifi.WifiInfo; import android.net.wifi.ScanSettings; import android.net.wifi.WifiChannel; import android.net.wifi.ScanResult; import android.net.wifi.WifiConnectionStatistics; import android.net.DhcpInfo; Loading Loading @@ -146,5 +148,7 @@ interface IWifiManager int getAllowScansWithTraffic(); void setAllowScansWithTraffic(int enabled); WifiConnectionStatistics getConnectionStatistics(); } wifi/java/android/net/wifi/ScanResult.java +75 −6 Original line number Diff line number Diff line Loading @@ -28,13 +28,19 @@ import android.os.Parcel; * but does not currently report them to external clients. */ public class ScanResult implements Parcelable { /** The network name. */ /** * The network name. */ public String SSID; /** Ascii encoded SSID. This will replace SSID when we deprecate it. @hide */ /** * Ascii encoded SSID. This will replace SSID when we deprecate it. @hide */ public WifiSsid wifiSsid; /** The address of the access point. */ /** * The address of the access point. */ public String BSSID; /** * Describes the authentication, key management, and encryption schemes Loading Loading @@ -63,6 +69,27 @@ public class ScanResult implements Parcelable { */ public long seen; /** * @hide * Update RSSI of the scan result * @param previousRSSI * @param previousSeen * @param maxAge */ public void averageRssi(int previousRssi, long previousSeen, int maxAge) { if (seen == 0) { seen = System.currentTimeMillis(); } long age = seen - previousSeen; if (previousSeen > 0 && age > 0 && age < maxAge/2) { // Average the RSSI with previously seen instances of this scan result double alpha = 0.5 - (double) age / (double) maxAge; level = (int) ((double) level * (1 - alpha) + (double) previousRssi * alpha); } } /** @hide */ public static final int ENABLED = 0; /** @hide */ Loading @@ -78,6 +105,25 @@ public class ScanResult implements Parcelable { */ public int status; /** * Status: indicating the scan result is not a result * that is part of user's saved configurations * @hide */ public boolean untrusted; /** * Number of time we connected to it * @hide */ public int numConnection; /** * Number of time autojoin used it * @hide */ public int numUsage; /** * The approximate distance to the AP in centimeter, if available. Else * {@link UNSPECIFIED}. Loading Loading @@ -105,18 +151,32 @@ public class ScanResult implements Parcelable { public final static int UNSPECIFIED = -1; /** * @hide * TODO: makes real freq boundaries */ public boolean is24GHz() { return frequency > 2400 && frequency < 2500; return ScanResult.is24GHz(frequency); } /** * @hide * TODO: makes real freq boundaries */ public static boolean is24GHz(int freq) { return freq > 2400 && freq < 2500; } /** * @hide */ public boolean is5GHz() { return frequency > 4900 && frequency < 5900; return ScanResult.is24GHz(frequency); } /** * @hide * TODO: makes real freq boundaries */ public static boolean is5GHz(int freq) { return freq > 4900 && freq < 5900; } /** information element from beacon Loading Loading @@ -175,6 +235,9 @@ public class ScanResult implements Parcelable { seen = source.seen; passpoint = source.passpoint; status = source.status; untrusted = source.untrusted; numConnection = source.numConnection; numUsage = source.numUsage; } } Loading Loading @@ -237,6 +300,9 @@ public class ScanResult implements Parcelable { dest.writeInt(distanceSdCm); dest.writeLong(seen); dest.writeInt(status); dest.writeInt(untrusted ? 1 : 0); dest.writeInt(numConnection); dest.writeInt(numUsage); if (passpoint != null) { dest.writeInt(1); passpoint.writeToParcel(dest, flags); Loading Loading @@ -275,6 +341,9 @@ public class ScanResult implements Parcelable { ); sr.seen = in.readLong(); sr.status = in.readInt(); sr.untrusted = in.readInt() != 0; sr.numConnection = in.readInt(); sr.numUsage = in.readInt(); if (in.readInt() == 1) { sr.passpoint = WifiPasspointInfo.CREATOR.createFromParcel(in); } Loading wifi/java/android/net/wifi/WifiConfiguration.java +11 −0 Original line number Diff line number Diff line Loading @@ -667,6 +667,14 @@ public class WifiConfiguration implements Parcelable { @SystemApi public int numScorerOverrideAndSwitchedNetwork; /** * @hide * Number of time we associated to this configuration. */ @SystemApi public int numAssociation; /** * @hide * Connect choices Loading Loading @@ -1188,6 +1196,7 @@ public class WifiConfiguration implements Parcelable { numConnectionFailures = source.numConnectionFailures; numScorerOverride = source.numScorerOverride; numScorerOverrideAndSwitchedNetwork = source.numScorerOverrideAndSwitchedNetwork; numAssociation = source.numAssociation; } } Loading Loading @@ -1239,6 +1248,7 @@ public class WifiConfiguration implements Parcelable { dest.writeInt(numConnectionFailures); dest.writeInt(numScorerOverride); dest.writeInt(numScorerOverrideAndSwitchedNetwork); dest.writeInt(numAssociation); } /** Implement the Parcelable interface {@hide} */ Loading Loading @@ -1286,6 +1296,7 @@ public class WifiConfiguration implements Parcelable { config.numConnectionFailures = in.readInt(); config.numScorerOverride = in.readInt(); config.numScorerOverrideAndSwitchedNetwork = in.readInt(); config.numAssociation = in.readInt(); return config; } Loading wifi/java/android/net/wifi/WifiConnectionStatistics.aidl 0 → 100644 +19 −0 Original line number Diff line number Diff line /** * Copyright (c) 2014, The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.net.wifi; parcelable WifiConnectionStatistics; wifi/java/android/net/wifi/WifiConnectionStatistics.java 0 → 100644 +138 −0 Original line number Diff line number Diff line /* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.net.wifi; import android.annotation.SystemApi; import android.os.Parcel; import android.os.Parcelable; import android.text.TextUtils; import java.util.HashMap; /** * Wifi Connection Statistics: gather various stats regarding WiFi connections, * connection requests, auto-join * and WiFi usage. * @hide */ @SystemApi public class WifiConnectionStatistics implements Parcelable { private static final String TAG = "WifiConnnectionStatistics"; /** * history of past connection to untrusted SSID * Key = SSID * Value = num connection */ public HashMap<String, WifiNetworkConnectionStatistics> untrustedNetworkHistory; // Number of time we polled the chip and were on 5GHz public int num5GhzConnected; // Number of time we polled the chip and were on 2.4GHz public int num24GhzConnected; public WifiConnectionStatistics() { untrustedNetworkHistory = new HashMap<String, WifiNetworkConnectionStatistics>(); } public void incrementOrAddUntrusted(String SSID, int connection, int usage) { WifiNetworkConnectionStatistics stats; if (TextUtils.isEmpty(SSID)) return; if (untrustedNetworkHistory.containsKey(SSID)) { stats = untrustedNetworkHistory.get(SSID); if (stats != null){ stats.numConnection = connection + stats.numConnection; stats.numUsage = usage + stats.numUsage; } } else { stats = new WifiNetworkConnectionStatistics(connection, usage); } if (stats != null) { untrustedNetworkHistory.put(SSID, stats); } } @Override public String toString() { StringBuilder sbuf = new StringBuilder(); sbuf.append("Connected on: 2.4Ghz=").append(num24GhzConnected); sbuf.append(" 5Ghz=").append(num5GhzConnected).append("\n"); for (String Key : untrustedNetworkHistory.keySet()) { WifiNetworkConnectionStatistics stats = untrustedNetworkHistory.get(Key); if (stats != null) { sbuf.append(Key).append(" ").append(stats.toString()).append("\n"); } } return sbuf.toString(); } /** copy constructor*/ public WifiConnectionStatistics(WifiConnectionStatistics source) { untrustedNetworkHistory = new HashMap<String, WifiNetworkConnectionStatistics>(); if (source != null) { untrustedNetworkHistory.putAll(source.untrustedNetworkHistory); } } /** Implement the Parcelable interface */ public int describeContents() { return 0; } /** Implement the Parcelable interface */ @Override public void writeToParcel(Parcel dest, int flags) { dest.writeInt(num24GhzConnected); dest.writeInt(num5GhzConnected); dest.writeInt(untrustedNetworkHistory.size()); for (String Key : untrustedNetworkHistory.keySet()) { WifiNetworkConnectionStatistics num = untrustedNetworkHistory.get(Key); dest.writeString(Key); dest.writeInt(num.numConnection); dest.writeInt(num.numUsage); } } /** Implement the Parcelable interface */ public static final Creator<WifiConnectionStatistics> CREATOR = new Creator<WifiConnectionStatistics>() { public WifiConnectionStatistics createFromParcel(Parcel in) { WifiConnectionStatistics stats = new WifiConnectionStatistics(); stats.num24GhzConnected = in.readInt(); stats.num5GhzConnected = in.readInt(); int n = in.readInt(); while (n-- > 0) { String Key = in.readString(); int numConnection = in.readInt(); int numUsage = in.readInt(); WifiNetworkConnectionStatistics st = new WifiNetworkConnectionStatistics(numConnection, numUsage); stats.untrustedNetworkHistory.put(Key, st); } return stats; } public WifiConnectionStatistics[] newArray(int size) { return new WifiConnectionStatistics[size]; } }; } Loading
wifi/java/android/net/wifi/IWifiManager.aidl +4 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,8 @@ import android.net.wifi.WifiInfo; import android.net.wifi.ScanSettings; import android.net.wifi.WifiChannel; import android.net.wifi.ScanResult; import android.net.wifi.WifiConnectionStatistics; import android.net.DhcpInfo; Loading Loading @@ -146,5 +148,7 @@ interface IWifiManager int getAllowScansWithTraffic(); void setAllowScansWithTraffic(int enabled); WifiConnectionStatistics getConnectionStatistics(); }
wifi/java/android/net/wifi/ScanResult.java +75 −6 Original line number Diff line number Diff line Loading @@ -28,13 +28,19 @@ import android.os.Parcel; * but does not currently report them to external clients. */ public class ScanResult implements Parcelable { /** The network name. */ /** * The network name. */ public String SSID; /** Ascii encoded SSID. This will replace SSID when we deprecate it. @hide */ /** * Ascii encoded SSID. This will replace SSID when we deprecate it. @hide */ public WifiSsid wifiSsid; /** The address of the access point. */ /** * The address of the access point. */ public String BSSID; /** * Describes the authentication, key management, and encryption schemes Loading Loading @@ -63,6 +69,27 @@ public class ScanResult implements Parcelable { */ public long seen; /** * @hide * Update RSSI of the scan result * @param previousRSSI * @param previousSeen * @param maxAge */ public void averageRssi(int previousRssi, long previousSeen, int maxAge) { if (seen == 0) { seen = System.currentTimeMillis(); } long age = seen - previousSeen; if (previousSeen > 0 && age > 0 && age < maxAge/2) { // Average the RSSI with previously seen instances of this scan result double alpha = 0.5 - (double) age / (double) maxAge; level = (int) ((double) level * (1 - alpha) + (double) previousRssi * alpha); } } /** @hide */ public static final int ENABLED = 0; /** @hide */ Loading @@ -78,6 +105,25 @@ public class ScanResult implements Parcelable { */ public int status; /** * Status: indicating the scan result is not a result * that is part of user's saved configurations * @hide */ public boolean untrusted; /** * Number of time we connected to it * @hide */ public int numConnection; /** * Number of time autojoin used it * @hide */ public int numUsage; /** * The approximate distance to the AP in centimeter, if available. Else * {@link UNSPECIFIED}. Loading Loading @@ -105,18 +151,32 @@ public class ScanResult implements Parcelable { public final static int UNSPECIFIED = -1; /** * @hide * TODO: makes real freq boundaries */ public boolean is24GHz() { return frequency > 2400 && frequency < 2500; return ScanResult.is24GHz(frequency); } /** * @hide * TODO: makes real freq boundaries */ public static boolean is24GHz(int freq) { return freq > 2400 && freq < 2500; } /** * @hide */ public boolean is5GHz() { return frequency > 4900 && frequency < 5900; return ScanResult.is24GHz(frequency); } /** * @hide * TODO: makes real freq boundaries */ public static boolean is5GHz(int freq) { return freq > 4900 && freq < 5900; } /** information element from beacon Loading Loading @@ -175,6 +235,9 @@ public class ScanResult implements Parcelable { seen = source.seen; passpoint = source.passpoint; status = source.status; untrusted = source.untrusted; numConnection = source.numConnection; numUsage = source.numUsage; } } Loading Loading @@ -237,6 +300,9 @@ public class ScanResult implements Parcelable { dest.writeInt(distanceSdCm); dest.writeLong(seen); dest.writeInt(status); dest.writeInt(untrusted ? 1 : 0); dest.writeInt(numConnection); dest.writeInt(numUsage); if (passpoint != null) { dest.writeInt(1); passpoint.writeToParcel(dest, flags); Loading Loading @@ -275,6 +341,9 @@ public class ScanResult implements Parcelable { ); sr.seen = in.readLong(); sr.status = in.readInt(); sr.untrusted = in.readInt() != 0; sr.numConnection = in.readInt(); sr.numUsage = in.readInt(); if (in.readInt() == 1) { sr.passpoint = WifiPasspointInfo.CREATOR.createFromParcel(in); } Loading
wifi/java/android/net/wifi/WifiConfiguration.java +11 −0 Original line number Diff line number Diff line Loading @@ -667,6 +667,14 @@ public class WifiConfiguration implements Parcelable { @SystemApi public int numScorerOverrideAndSwitchedNetwork; /** * @hide * Number of time we associated to this configuration. */ @SystemApi public int numAssociation; /** * @hide * Connect choices Loading Loading @@ -1188,6 +1196,7 @@ public class WifiConfiguration implements Parcelable { numConnectionFailures = source.numConnectionFailures; numScorerOverride = source.numScorerOverride; numScorerOverrideAndSwitchedNetwork = source.numScorerOverrideAndSwitchedNetwork; numAssociation = source.numAssociation; } } Loading Loading @@ -1239,6 +1248,7 @@ public class WifiConfiguration implements Parcelable { dest.writeInt(numConnectionFailures); dest.writeInt(numScorerOverride); dest.writeInt(numScorerOverrideAndSwitchedNetwork); dest.writeInt(numAssociation); } /** Implement the Parcelable interface {@hide} */ Loading Loading @@ -1286,6 +1296,7 @@ public class WifiConfiguration implements Parcelable { config.numConnectionFailures = in.readInt(); config.numScorerOverride = in.readInt(); config.numScorerOverrideAndSwitchedNetwork = in.readInt(); config.numAssociation = in.readInt(); return config; } Loading
wifi/java/android/net/wifi/WifiConnectionStatistics.aidl 0 → 100644 +19 −0 Original line number Diff line number Diff line /** * Copyright (c) 2014, The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.net.wifi; parcelable WifiConnectionStatistics;
wifi/java/android/net/wifi/WifiConnectionStatistics.java 0 → 100644 +138 −0 Original line number Diff line number Diff line /* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.net.wifi; import android.annotation.SystemApi; import android.os.Parcel; import android.os.Parcelable; import android.text.TextUtils; import java.util.HashMap; /** * Wifi Connection Statistics: gather various stats regarding WiFi connections, * connection requests, auto-join * and WiFi usage. * @hide */ @SystemApi public class WifiConnectionStatistics implements Parcelable { private static final String TAG = "WifiConnnectionStatistics"; /** * history of past connection to untrusted SSID * Key = SSID * Value = num connection */ public HashMap<String, WifiNetworkConnectionStatistics> untrustedNetworkHistory; // Number of time we polled the chip and were on 5GHz public int num5GhzConnected; // Number of time we polled the chip and were on 2.4GHz public int num24GhzConnected; public WifiConnectionStatistics() { untrustedNetworkHistory = new HashMap<String, WifiNetworkConnectionStatistics>(); } public void incrementOrAddUntrusted(String SSID, int connection, int usage) { WifiNetworkConnectionStatistics stats; if (TextUtils.isEmpty(SSID)) return; if (untrustedNetworkHistory.containsKey(SSID)) { stats = untrustedNetworkHistory.get(SSID); if (stats != null){ stats.numConnection = connection + stats.numConnection; stats.numUsage = usage + stats.numUsage; } } else { stats = new WifiNetworkConnectionStatistics(connection, usage); } if (stats != null) { untrustedNetworkHistory.put(SSID, stats); } } @Override public String toString() { StringBuilder sbuf = new StringBuilder(); sbuf.append("Connected on: 2.4Ghz=").append(num24GhzConnected); sbuf.append(" 5Ghz=").append(num5GhzConnected).append("\n"); for (String Key : untrustedNetworkHistory.keySet()) { WifiNetworkConnectionStatistics stats = untrustedNetworkHistory.get(Key); if (stats != null) { sbuf.append(Key).append(" ").append(stats.toString()).append("\n"); } } return sbuf.toString(); } /** copy constructor*/ public WifiConnectionStatistics(WifiConnectionStatistics source) { untrustedNetworkHistory = new HashMap<String, WifiNetworkConnectionStatistics>(); if (source != null) { untrustedNetworkHistory.putAll(source.untrustedNetworkHistory); } } /** Implement the Parcelable interface */ public int describeContents() { return 0; } /** Implement the Parcelable interface */ @Override public void writeToParcel(Parcel dest, int flags) { dest.writeInt(num24GhzConnected); dest.writeInt(num5GhzConnected); dest.writeInt(untrustedNetworkHistory.size()); for (String Key : untrustedNetworkHistory.keySet()) { WifiNetworkConnectionStatistics num = untrustedNetworkHistory.get(Key); dest.writeString(Key); dest.writeInt(num.numConnection); dest.writeInt(num.numUsage); } } /** Implement the Parcelable interface */ public static final Creator<WifiConnectionStatistics> CREATOR = new Creator<WifiConnectionStatistics>() { public WifiConnectionStatistics createFromParcel(Parcel in) { WifiConnectionStatistics stats = new WifiConnectionStatistics(); stats.num24GhzConnected = in.readInt(); stats.num5GhzConnected = in.readInt(); int n = in.readInt(); while (n-- > 0) { String Key = in.readString(); int numConnection = in.readInt(); int numUsage = in.readInt(); WifiNetworkConnectionStatistics st = new WifiNetworkConnectionStatistics(numConnection, numUsage); stats.untrustedNetworkHistory.put(Key, st); } return stats; } public WifiConnectionStatistics[] newArray(int size) { return new WifiConnectionStatistics[size]; } }; }