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