diff options
author | Vinit Deshpande <vinitd@google.com> | 2015-04-15 18:32:09 -0700 |
---|---|---|
committer | Vinit Deshpande <vinitd@google.com> | 2015-04-29 16:40:51 -0700 |
commit | dcf00c9d0f6f985aef186cfe5d7b63761e2f8104 (patch) | |
tree | 2fcf4ae93cb01549976942acfcc5cb3089f48e78 /packages/SettingsLib/src | |
parent | fc40600e30e281712f6c2fc899fc3894b8ad0050 (diff) | |
download | frameworks_base-dcf00c9d0f6f985aef186cfe5d7b63761e2f8104.zip frameworks_base-dcf00c9d0f6f985aef186cfe5d7b63761e2f8104.tar.gz frameworks_base-dcf00c9d0f6f985aef186cfe5d7b63761e2f8104.tar.bz2 |
Implement 'Available via Passpoint' feature [DO NOT MERGE]
This also fixes the issues related to explicit connection
to passpoint AP, and fixes occassional mention of
'connected via Wi-Fi Assistent'
Change-Id: I152cebafa6259194f1d09a6972a3508156335cb6
(cherry picked from commit ff783cd6cfc82870a6126fe1ef019d21131423fc)
Diffstat (limited to 'packages/SettingsLib/src')
-rw-r--r-- | packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java | 53 | ||||
-rw-r--r-- | packages/SettingsLib/src/com/android/settingslib/wifi/WifiTracker.java | 39 |
2 files changed, 71 insertions, 21 deletions
diff --git a/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java b/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java index 458d002..2fde4f9 100644 --- a/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java +++ b/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java @@ -200,7 +200,10 @@ public class AccessPoint implements Comparable<AccessPoint> { } public boolean matches(WifiConfiguration config) { - return ssid.equals(removeDoubleQuotes(config.SSID)) && security == getSecurity(config); + if (config.isPasspoint() && mConfig != null && mConfig.isPasspoint()) + return config.FQDN.equals(mConfig.providerFriendlyName); + else + return ssid.equals(removeDoubleQuotes(config.SSID)) && security == getSecurity(config); } public WifiConfiguration getConfig() { @@ -266,21 +269,47 @@ public class AccessPoint implements Comparable<AccessPoint> { return ssid; } + public String getConfigName() { + if (mConfig != null && mConfig.isPasspoint()) { + return mConfig.providerFriendlyName; + } else { + return ssid; + } + } + public DetailedState getDetailedState() { return mNetworkInfo != null ? mNetworkInfo.getDetailedState() : null; } + public String getSavedNetworkSummary() { + // Update to new summary + if (mConfig != null && mConfig.isPasspoint()) { + return ""; + } else { + return getSettingsSummary(); + } + } + public String getSummary() { + return getSettingsSummary(); + } + + public String getSettingsSummary() { // Update to new summary StringBuilder summary = new StringBuilder(); - if (isActive()) { // This is the active connection - String passpointProvider = (mConfig != null && mConfig.isPasspoint()) ? - mConfig.providerFriendlyName : null; + if (isActive() && mConfig != null && mConfig.isPasspoint()) { + // This is the active connection on passpoint summary.append(getSummary(mContext, getDetailedState(), - networkId == WifiConfiguration.INVALID_NETWORK_ID, passpointProvider)); - } else if (mConfig != null - && mConfig.hasNoInternetAccess()) { + false, mConfig.providerFriendlyName)); + } else if (isActive()) { + // This is the active connection on non-passpoint network + summary.append(getSummary(mContext, getDetailedState(), + networkId == WifiConfiguration.INVALID_NETWORK_ID)); + } else if (mConfig != null && mConfig.isPasspoint()) { + String format = mContext.getString(R.string.available_via_passpoint); + summary.append(String.format(format, mConfig.providerFriendlyName)); + } else if (mConfig != null && mConfig.hasNoInternetAccess()) { summary.append(mContext.getString(R.string.wifi_no_internet)); } else if (mConfig != null && ((mConfig.status == WifiConfiguration.Status.DISABLED && mConfig.disableReason != WifiConfiguration.DISABLED_UNKNOWN_REASON) @@ -652,16 +681,20 @@ public class AccessPoint implements Comparable<AccessPoint> { void update(WifiConfiguration config) { mConfig = config; + networkId = config.networkId; + if (mAccessPointListener != null) { + mAccessPointListener.onAccessPointChanged(this); + } } public static String getSummary(Context context, String ssid, DetailedState state, boolean isEphemeral, String passpointProvider) { - if (state == DetailedState.CONNECTED && isEphemeral && ssid == null) { + if (state == DetailedState.CONNECTED && ssid == null) { if (TextUtils.isEmpty(passpointProvider) == false) { - // Special case for connected + ephemeral networks. + // Special case for connected + passpoint networks. String format = context.getString(R.string.connected_via_passpoint); return String.format(format, passpointProvider); - } else if (isEphemeral && ssid == null) { + } else if (isEphemeral) { // Special case for connected + ephemeral networks. return context.getString(R.string.connected_via_wfa); } diff --git a/packages/SettingsLib/src/com/android/settingslib/wifi/WifiTracker.java b/packages/SettingsLib/src/com/android/settingslib/wifi/WifiTracker.java index 3240d0f..09e6912 100644 --- a/packages/SettingsLib/src/com/android/settingslib/wifi/WifiTracker.java +++ b/packages/SettingsLib/src/com/android/settingslib/wifi/WifiTracker.java @@ -61,6 +61,7 @@ public class WifiTracker { private final WifiListener mListener; private final boolean mIncludeSaved; private final boolean mIncludeScans; + private final boolean mIncludePasspoints; private boolean mSavedNetworksExist; private boolean mRegistered; @@ -74,14 +75,18 @@ public class WifiTracker { Scanner mScanner; public WifiTracker(Context context, WifiListener wifiListener, boolean includeSaved, - boolean includeScans) { - this(context, wifiListener, includeSaved, includeScans, + boolean includeScans) { + this(context, wifiListener, includeSaved, includeScans, false); + } + public WifiTracker(Context context, WifiListener wifiListener, boolean includeSaved, + boolean includeScans, boolean includePasspoints) { + this(context, wifiListener, includeSaved, includeScans, includePasspoints, (WifiManager) context.getSystemService(Context.WIFI_SERVICE)); } @VisibleForTesting WifiTracker(Context context, WifiListener wifiListener, boolean includeSaved, - boolean includeScans, WifiManager wifiManager) { + boolean includeScans, boolean includePasspoints, WifiManager wifiManager) { if (!includeSaved && !includeScans) { throw new IllegalArgumentException("Must include either saved or scans"); } @@ -89,6 +94,7 @@ public class WifiTracker { mWifiManager = wifiManager; mIncludeSaved = includeSaved; mIncludeScans = includeScans; + mIncludePasspoints = includePasspoints; mListener = wifiListener; // check if verbose logging has been turned on or off @@ -232,16 +238,19 @@ public class WifiTracker { if (config.selfAdded && config.numAssociation == 0) { continue; } - if (config.isPasspoint()) { - continue; - } AccessPoint accessPoint = getCachedOrCreate(config); if (mLastInfo != null && mLastNetworkInfo != null) { - accessPoint.update(mLastInfo, mLastNetworkInfo); + if (config.isPasspoint() == false) { + accessPoint.update(mLastInfo, mLastNetworkInfo); + } } if (mIncludeSaved) { - mAccessPoints.add(accessPoint); - apMap.put(accessPoint.getSsid(), accessPoint); + if (!config.isPasspoint() || mIncludePasspoints) + mAccessPoints.add(accessPoint); + + if (config.isPasspoint() == false) { + apMap.put(accessPoint.getSsid(), accessPoint); + } } else { // If we aren't using saved networks, drop them into the cache so that // we have access to their saved info. @@ -272,6 +281,13 @@ public class WifiTracker { accessPoint.update(mLastInfo, mLastNetworkInfo); } + if (result.passpointNetwork) { + WifiConfiguration config = mWifiManager.getMatchingWifiConfig(result); + if (config != null) { + accessPoint.update(config); + } + } + if (mLastInfo != null && mLastInfo.getBSSID() != null && mLastInfo.getBSSID().equals(result.BSSID) && connectionConfig != null && connectionConfig.isPasspoint()) { @@ -370,8 +386,9 @@ public class WifiTracker { } public static List<AccessPoint> getCurrentAccessPoints(Context context, boolean includeSaved, - boolean includeScans) { - WifiTracker tracker = new WifiTracker(context, null, includeSaved, includeScans); + boolean includeScans, boolean includePasspoints) { + WifiTracker tracker = new WifiTracker(context, + null, includeSaved, includeScans, includePasspoints); tracker.forceUpdate(); return tracker.getAccessPoints(); } |