Merge "Fix settings UI for passpoint networks" into m-wireless-dev
This commit is contained in:
committed by
Android Partner Code Review
commit
279cb4a590
@@ -1333,6 +1333,8 @@
|
||||
<string name="wifi_assistant_title">Wi\u2011Fi Assistant</string>
|
||||
<!-- Status message of Wi-Fi when it is connected by a Wi-Fi assistant application. [CHAR LIMIT=NONE] -->
|
||||
<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>
|
||||
|
||||
<!-- Wifi Display settings. The title of the screen. [CHAR LIMIT=40] -->
|
||||
<string name="wifi_display_settings_title">Cast screen</string>
|
||||
|
@@ -230,7 +230,11 @@ class AccessPoint extends Preference {
|
||||
}
|
||||
|
||||
private void loadConfig(WifiConfiguration config) {
|
||||
if (config.isPasspoint())
|
||||
ssid = config.providerFriendlyName;
|
||||
else
|
||||
ssid = (config.SSID == null ? "" : removeDoubleQuotes(config.SSID));
|
||||
|
||||
bssid = config.BSSID;
|
||||
security = getSecurity(config);
|
||||
networkId = config.networkId;
|
||||
@@ -360,6 +364,7 @@ class AccessPoint extends Preference {
|
||||
refresh();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -394,6 +399,11 @@ class AccessPoint extends Preference {
|
||||
}
|
||||
}
|
||||
|
||||
void update(WifiConfiguration config) {
|
||||
mConfig = config;
|
||||
refresh();
|
||||
}
|
||||
|
||||
int getLevel() {
|
||||
if (mRssi == Integer.MAX_VALUE) {
|
||||
return -1;
|
||||
@@ -617,8 +627,10 @@ class AccessPoint extends Preference {
|
||||
StringBuilder summary = new StringBuilder();
|
||||
|
||||
if (isActive()) { // This is the active connection
|
||||
String passpointProvider = (mConfig != null && mConfig.isPasspoint()) ?
|
||||
mConfig.providerFriendlyName : null;
|
||||
summary.append(Summary.get(context, getState(),
|
||||
networkId == WifiConfiguration.INVALID_NETWORK_ID));
|
||||
networkId == WifiConfiguration.INVALID_NETWORK_ID, passpointProvider));
|
||||
} else if (mConfig != null
|
||||
&& mConfig.hasNoInternetAccess()) {
|
||||
summary.append(context.getString(R.string.wifi_no_internet));
|
||||
|
@@ -20,13 +20,21 @@ import com.android.settings.R;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.NetworkInfo.DetailedState;
|
||||
import android.text.TextUtils;
|
||||
|
||||
class Summary {
|
||||
static String get(Context context, String ssid, DetailedState state, boolean isEphemeral) {
|
||||
if (state == DetailedState.CONNECTED && isEphemeral && ssid == null) {
|
||||
static String get(Context context, String ssid, DetailedState state, boolean isEphemeral,
|
||||
String passpointProvider) {
|
||||
if (state == DetailedState.CONNECTED) {
|
||||
if (TextUtils.isEmpty(passpointProvider) == false) {
|
||||
// Special case for connected + ephemeral networks.
|
||||
String format = context.getString(R.string.connected_via_passpoint);
|
||||
return String.format(format, passpointProvider);
|
||||
} else if (isEphemeral && ssid == null) {
|
||||
// Special case for connected + ephemeral networks.
|
||||
return context.getString(R.string.connected_via_wfa);
|
||||
}
|
||||
}
|
||||
|
||||
String[] formats = context.getResources().getStringArray((ssid == null)
|
||||
? R.array.wifi_status : R.array.wifi_status_with_ssid);
|
||||
@@ -38,7 +46,15 @@ class Summary {
|
||||
return String.format(formats[index], ssid);
|
||||
}
|
||||
|
||||
static String get(Context context, String ssid, DetailedState state, boolean isEphemeral) {
|
||||
return get(context, ssid, state, isEphemeral, null);
|
||||
}
|
||||
static String get(Context context, DetailedState state, boolean isEphemeral) {
|
||||
return get(context, null, state, isEphemeral);
|
||||
return get(context, null, state, isEphemeral, null);
|
||||
}
|
||||
|
||||
static String get(Context context, DetailedState state, boolean isEphemeral,
|
||||
String passpointProvider) {
|
||||
return get(context, null, state, isEphemeral, passpointProvider);
|
||||
}
|
||||
}
|
||||
|
@@ -653,6 +653,7 @@ public class WifiSettings extends RestrictedSettingsFragment
|
||||
switch (wifiState) {
|
||||
case WifiManager.WIFI_STATE_ENABLED:
|
||||
// AccessPoints are automatically sorted with TreeSet.
|
||||
mLastInfo = mWifiManager.getConnectionInfo();
|
||||
final Collection<AccessPoint> accessPoints =
|
||||
constructAccessPoints(getActivity(), mWifiManager, mLastInfo,
|
||||
mLastNetworkInfo);
|
||||
@@ -721,6 +722,7 @@ public class WifiSettings extends RestrictedSettingsFragment
|
||||
/** Lookup table to more quickly update AccessPoints by only considering objects with the
|
||||
* correct SSID. Maps SSID -> List of AccessPoints with the given SSID. */
|
||||
Multimap<String, AccessPoint> apMap = new Multimap<String, AccessPoint>();
|
||||
WifiConfiguration connectionConfig = null;
|
||||
|
||||
final List<WifiConfiguration> configs = wifiManager.getConfiguredNetworks();
|
||||
if (configs != null) {
|
||||
@@ -732,13 +734,23 @@ public class WifiSettings extends RestrictedSettingsFragment
|
||||
}
|
||||
}
|
||||
for (WifiConfiguration config : configs) {
|
||||
if (lastInfo != null && lastInfo.getNetworkId() == config.networkId) {
|
||||
connectionConfig = config;
|
||||
}
|
||||
|
||||
if (config.selfAdded && config.numAssociation == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (config.isPasspoint()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
AccessPoint accessPoint = new AccessPoint(context, config);
|
||||
if (lastInfo != null && lastNetworkInfo != null) {
|
||||
accessPoint.update(lastInfo, lastNetworkInfo);
|
||||
}
|
||||
|
||||
accessPoints.add(accessPoint);
|
||||
apMap.put(accessPoint.ssid, accessPoint);
|
||||
}
|
||||
@@ -758,11 +770,22 @@ public class WifiSettings extends RestrictedSettingsFragment
|
||||
if (accessPoint.update(result))
|
||||
found = true;
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
|
||||
AccessPoint accessPoint = new AccessPoint(context, result);
|
||||
if (lastInfo != null && lastNetworkInfo != null) {
|
||||
accessPoint.update(lastInfo, lastNetworkInfo);
|
||||
}
|
||||
|
||||
if (lastInfo != null && lastInfo.getBSSID() != null
|
||||
&& lastInfo.getBSSID().equals(result.BSSID)
|
||||
&& connectionConfig != null && connectionConfig.isPasspoint()) {
|
||||
/* This network is connected via this passpoint config */
|
||||
/* SSID match is not going to work for it; so update explicitly */
|
||||
accessPoint.update(connectionConfig);
|
||||
}
|
||||
|
||||
accessPoints.add(accessPoint);
|
||||
apMap.put(accessPoint.ssid, accessPoint);
|
||||
}
|
||||
|
Reference in New Issue
Block a user