diff options
Diffstat (limited to 'wifi/java/android')
| -rw-r--r-- | wifi/java/android/net/wifi/IWifiManager.aidl | 4 | ||||
| -rw-r--r-- | wifi/java/android/net/wifi/WifiConfiguration.java | 97 | ||||
| -rw-r--r-- | wifi/java/android/net/wifi/WifiInfo.java | 2 | ||||
| -rw-r--r-- | wifi/java/android/net/wifi/WifiManager.java | 33 |
4 files changed, 122 insertions, 14 deletions
diff --git a/wifi/java/android/net/wifi/IWifiManager.aidl b/wifi/java/android/net/wifi/IWifiManager.aidl index a752686..b87a1e9 100644 --- a/wifi/java/android/net/wifi/IWifiManager.aidl +++ b/wifi/java/android/net/wifi/IWifiManager.aidl @@ -61,6 +61,8 @@ interface IWifiManager void startScan(in ScanSettings requested, in WorkSource ws); + void startLocationRestrictedScan(in WorkSource ws); + List<ScanResult> getScanResults(String callingPackage); void disconnect(); @@ -152,5 +154,7 @@ interface IWifiManager void setAllowScansWithTraffic(int enabled); WifiConnectionStatistics getConnectionStatistics(); + + void disableEphemeralNetwork(String SSID); } diff --git a/wifi/java/android/net/wifi/WifiConfiguration.java b/wifi/java/android/net/wifi/WifiConfiguration.java index 02e610c..6543c03 100644 --- a/wifi/java/android/net/wifi/WifiConfiguration.java +++ b/wifi/java/android/net/wifi/WifiConfiguration.java @@ -352,9 +352,9 @@ public class WifiConfiguration implements Parcelable { /** * @hide - * last time we connected, this configuration had no internet access + * last time we connected, this configuration had validated internet access */ - public boolean noInternetAccess; + public boolean validatedInternetAccess; /** * @hide @@ -487,6 +487,11 @@ public class WifiConfiguration implements Parcelable { public long age24; // timestamp of the strongest 2.4GHz BSSID (last time it was seen) public String BSSID24; public String BSSID5; + public int score; // Debug only, indicate last score used for autojoin/cell-handover + public int currentNetworkBoost; // Debug only, indicate boost applied to RSSI if current + public int bandPreferenceBoost; // Debug only, indicate boost applied to RSSI if current + public int lastChoiceBoost; // Debug only, indicate last choice applied to this configuration + public String lastChoiceConfig; // Debug only, indicate last choice applied to this configuration public Visibility() { rssi5 = INVALID_RSSI; @@ -513,16 +518,23 @@ public class WifiConfiguration implements Parcelable { sbuf.append(","); sbuf.append(Integer.toString(num24)); if (BSSID24 != null) sbuf.append(",").append(BSSID24); - } else { - sbuf.append("*"); } - sbuf.append(" - "); + sbuf.append("; "); if (rssi5 > INVALID_RSSI) { sbuf.append(Integer.toString(rssi5)); sbuf.append(","); sbuf.append(Integer.toString(num5)); if (BSSID5 != null) sbuf.append(",").append(BSSID5); } + if (score != 0) { + sbuf.append("; ").append(score); + sbuf.append(", ").append(currentNetworkBoost); + sbuf.append(", ").append(bandPreferenceBoost); + if (lastChoiceConfig != null) { + sbuf.append(", ").append(lastChoiceBoost); + sbuf.append(", ").append(lastChoiceConfig); + } + } sbuf.append("]"); return sbuf.toString(); } @@ -642,6 +654,22 @@ public class WifiConfiguration implements Parcelable { /** * @hide + * Number of reports indicating no Internet Access + */ + public int numNoInternetAccessReports; + + /** + * @hide + * The WiFi configuration is considered to have no internet access for purpose of autojoining + * if there has been a report of it having no internet access, and, it never have had + * internet access in the past. + */ + public boolean hasNoInternetAccess() { + return numNoInternetAccessReports > 0 && !validatedInternetAccess; + } + + /** + * @hide * Last time we blacklisted the configuration */ public long blackListTimestamp; @@ -827,7 +855,7 @@ public class WifiConfiguration implements Parcelable { selfAdded = false; didSelfAdd = false; ephemeral = false; - noInternetAccess = false; + validatedInternetAccess = false; mIpConfiguration = new IpConfiguration(); } @@ -911,6 +939,42 @@ public class WifiConfiguration implements Parcelable { } } + /** @hide + * trim the scan Result Cache + * @param: number of entries to keep in the cache + */ + public void trimScanResultsCache(int num) { + if (this.scanResultCache == null) { + return; + } + int currenSize = this.scanResultCache.size(); + if (currenSize <= num) { + return; // Nothing to trim + } + ArrayList<ScanResult> list = new ArrayList<ScanResult>(this.scanResultCache.values()); + if (list.size() != 0) { + // Sort by descending timestamp + Collections.sort(list, new Comparator() { + public int compare(Object o1, Object o2) { + ScanResult a = (ScanResult)o1; + ScanResult b = (ScanResult)o2; + if (a.seen > b.seen) { + return 1; + } + if (a.seen < b.seen) { + return -1; + } + return a.BSSID.compareTo(b.BSSID); + } + }); + } + for (int i = 0; i < currenSize - num ; i++) { + // Remove oldest results from scan cache + ScanResult result = list.get(i); + this.scanResultCache.remove(result.BSSID); + } + } + /* @hide */ private ArrayList<ScanResult> sortScanResults() { ArrayList<ScanResult> list = new ArrayList<ScanResult>(this.scanResultCache.values()); @@ -974,10 +1038,15 @@ public class WifiConfiguration implements Parcelable { if (this.numAssociation > 0) { sbuf.append(" numAssociation ").append(this.numAssociation).append("\n"); } + if (this.numNoInternetAccessReports > 0) { + sbuf.append(" numNoInternetAccessReports "); + sbuf.append(this.numNoInternetAccessReports).append("\n"); + } if (this.didSelfAdd) sbuf.append(" didSelfAdd"); if (this.selfAdded) sbuf.append(" selfAdded"); - if (this.noInternetAccess) sbuf.append(" noInternetAccess"); - if (this.didSelfAdd || this.selfAdded || this.noInternetAccess) { + if (this.validatedInternetAccess) sbuf.append(" validatedInternetAccess"); + if (this.ephemeral) sbuf.append(" ephemeral"); + if (this.didSelfAdd || this.selfAdded || this.validatedInternetAccess || this.ephemeral) { sbuf.append("\n"); } sbuf.append(" KeyMgmt:"); @@ -1433,7 +1502,8 @@ public class WifiConfiguration implements Parcelable { mCachedConfigKey = null; //force null configKey autoJoinStatus = source.autoJoinStatus; selfAdded = source.selfAdded; - noInternetAccess = source.noInternetAccess; + validatedInternetAccess = source.validatedInternetAccess; + ephemeral = source.ephemeral; if (source.visibility != null) { visibility = new Visibility(source.visibility); } @@ -1466,6 +1536,7 @@ public class WifiConfiguration implements Parcelable { = source.autoJoinUseAggressiveJoinAttemptThreshold; autoJoinBailedDueToLowRssi = source.autoJoinBailedDueToLowRssi; dirty = source.dirty; + numNoInternetAccessReports = source.numNoInternetAccessReports; } } @@ -1509,7 +1580,8 @@ public class WifiConfiguration implements Parcelable { dest.writeInt(autoJoinStatus); dest.writeInt(selfAdded ? 1 : 0); dest.writeInt(didSelfAdd ? 1 : 0); - dest.writeInt(noInternetAccess ? 1 : 0); + dest.writeInt(validatedInternetAccess ? 1 : 0); + dest.writeInt(ephemeral ? 1 : 0); dest.writeInt(creatorUid); dest.writeInt(lastConnectUid); dest.writeInt(lastUpdateUid); @@ -1530,6 +1602,7 @@ public class WifiConfiguration implements Parcelable { dest.writeInt(numUserTriggeredJoinAttempts); dest.writeInt(autoJoinUseAggressiveJoinAttemptThreshold); dest.writeInt(autoJoinBailedDueToLowRssi ? 1 : 0); + dest.writeInt(numNoInternetAccessReports); } /** Implement the Parcelable interface {@hide} */ @@ -1569,7 +1642,8 @@ public class WifiConfiguration implements Parcelable { config.autoJoinStatus = in.readInt(); config.selfAdded = in.readInt() != 0; config.didSelfAdd = in.readInt() != 0; - config.noInternetAccess = in.readInt() != 0; + config.validatedInternetAccess = in.readInt() != 0; + config.ephemeral = in.readInt() != 0; config.creatorUid = in.readInt(); config.lastConnectUid = in.readInt(); config.lastUpdateUid = in.readInt(); @@ -1590,6 +1664,7 @@ public class WifiConfiguration implements Parcelable { config.numUserTriggeredJoinAttempts = in.readInt(); config.autoJoinUseAggressiveJoinAttemptThreshold = in.readInt(); config.autoJoinBailedDueToLowRssi = in.readInt() != 0; + config.numNoInternetAccessReports = in.readInt(); return config; } diff --git a/wifi/java/android/net/wifi/WifiInfo.java b/wifi/java/android/net/wifi/WifiInfo.java index 5bf3470..75198e5 100644 --- a/wifi/java/android/net/wifi/WifiInfo.java +++ b/wifi/java/android/net/wifi/WifiInfo.java @@ -286,7 +286,7 @@ public class WifiInfo implements Parcelable { * Returns the service set identifier (SSID) of the current 802.11 network. * If the SSID can be decoded as UTF-8, it will be returned surrounded by double * quotation marks. Otherwise, it is returned as a string of hex digits. The - * SSID may be {@code null} if there is no network currently connected. + * SSID may be <unknown ssid> if there is no network currently connected. * @return the SSID */ public String getSSID() { diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java index 1393bce..b001bb8 100644 --- a/wifi/java/android/net/wifi/WifiManager.java +++ b/wifi/java/android/net/wifi/WifiManager.java @@ -1011,6 +1011,22 @@ public class WifiManager { } /** + * startLocationRestrictedScan() + * Trigger a scan which will not make use of DFS channels and is thus not suitable for + * establishing wifi connection. + * @hide + */ + @SystemApi + public boolean startLocationRestrictedScan(WorkSource workSource) { + try { + mService.startLocationRestrictedScan(workSource); + return true; + } catch (RemoteException e) { + return false; + } + } + + /** * Request a scan for access points in specified channel list. Each channel is specified by its * frequency in MHz, e.g. "5500" (do NOT include "DFS" even though it is). The availability of * the results is made known later in the same way as {@link #startScan}. @@ -1616,7 +1632,6 @@ public class WifiManager { /** @hide */ public static final int RSSI_PKTCNT_FETCH_FAILED = BASE + 22; - /** * Passed with {@link ActionListener#onFailure}. * Indicates that the operation failed due to an internal error. @@ -1966,9 +1981,23 @@ public class WifiManager { } /** + * Disable ephemeral Network + * + * @param SSID, in the format of WifiConfiguration's SSID. + * @hide + */ + public void disableEphemeralNetwork(String SSID) { + if (SSID == null) throw new IllegalArgumentException("SSID cannot be null"); + try { + mService.disableEphemeralNetwork(SSID); + } catch (RemoteException e) { + } + } + + /** * Start Wi-fi Protected Setup * - * @param config WPS configuration + * @param config WPS configuration (does not support {@link WpsInfo#LABEL}) * @param listener for callbacks on success or failure. Can be null. * @throws IllegalStateException if the WifiManager instance needs to be * initialized again |
