diff options
author | Vinit Deshpande <vinitd@google.com> | 2015-04-15 18:32:09 -0700 |
---|---|---|
committer | Vinit Deshpande <vinitd@google.com> | 2015-04-17 21:15:26 -0700 |
commit | ff783cd6cfc82870a6126fe1ef019d21131423fc (patch) | |
tree | f9c397296fd54d8d3e08fca1483e2ece2c6adbb7 /packages | |
parent | 597f49cdda63fef1b583e2053341485e8d4e2371 (diff) | |
download | frameworks_base-ff783cd6cfc82870a6126fe1ef019d21131423fc.zip frameworks_base-ff783cd6cfc82870a6126fe1ef019d21131423fc.tar.gz frameworks_base-ff783cd6cfc82870a6126fe1ef019d21131423fc.tar.bz2 |
Implement 'Available via Passpoint' feature
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
Diffstat (limited to 'packages')
3 files changed, 73 insertions, 21 deletions
diff --git a/packages/SettingsLib/res/values/strings.xml b/packages/SettingsLib/res/values/strings.xml index 8fd56cb..6876222 100644 --- a/packages/SettingsLib/res/values/strings.xml +++ b/packages/SettingsLib/res/values/strings.xml @@ -69,6 +69,8 @@ <string name="connected_via_wfa">Connected via Wi\u2011Fi assistant</string> <!-- Status message of Wi-Fi when it is connected by Passpoint configuration. [CHAR LIMIT=NONE] --> <string name="connected_via_passpoint">Connected via %1$s</string> + <!-- Status message of Wi-Fi when network has matching passpoint credentials. [CHAR LIMIT=NONE] --> + <string name="available_via_passpoint">Available via %1$s</string> <!-- Bluetooth settings. Message when a device is disconnected --> <string name="bluetooth_disconnected">Disconnected</string> 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(); } |