[Passpoint] Allow multiple profiles w/identical FQDN
Allow to install multiple Passpoint profiles with identical FQDN. The FQDN is not used as a key for profiles. Existing Passpoint APIs that require FQDN (e.g. remove, allow auto-join) , will apply the request to all matching profiles with the same FQDN. Bug: 148556276 Test: atest android.net.wifi Test: atest com.android.server.wifi Change-Id: Iac93895dd078aa4db7baf2f6d53126de4a7dbc05
This commit is contained in:
@@ -181,6 +181,7 @@ public class AccessPoint implements Comparable<AccessPoint> {
|
||||
static final String KEY_SCANRESULTS = "key_scanresults";
|
||||
static final String KEY_SCOREDNETWORKCACHE = "key_scorednetworkcache";
|
||||
static final String KEY_CONFIG = "key_config";
|
||||
static final String KEY_PASSPOINT_UNIQUE_ID = "key_passpoint_unique_id";
|
||||
static final String KEY_FQDN = "key_fqdn";
|
||||
static final String KEY_PROVIDER_FRIENDLY_NAME = "key_provider_friendly_name";
|
||||
static final String KEY_EAPTYPE = "eap_psktype";
|
||||
@@ -217,7 +218,7 @@ public class AccessPoint implements Comparable<AccessPoint> {
|
||||
public static final int UNREACHABLE_RSSI = Integer.MIN_VALUE;
|
||||
|
||||
public static final String KEY_PREFIX_AP = "AP:";
|
||||
public static final String KEY_PREFIX_FQDN = "FQDN:";
|
||||
public static final String KEY_PREFIX_PASSPOINT_UNIQUE_ID = "PASSPOINT:";
|
||||
public static final String KEY_PREFIX_OSU = "OSU:";
|
||||
|
||||
private final Context mContext;
|
||||
@@ -250,6 +251,7 @@ public class AccessPoint implements Comparable<AccessPoint> {
|
||||
* Information associated with the {@link PasspointConfiguration}. Only maintaining
|
||||
* the relevant info to preserve spaces.
|
||||
*/
|
||||
private String mPasspointUniqueId;
|
||||
private String mFqdn;
|
||||
private String mProviderFriendlyName;
|
||||
private boolean mIsRoaming = false;
|
||||
@@ -308,6 +310,9 @@ public class AccessPoint implements Comparable<AccessPoint> {
|
||||
mScoredNetworkCache.put(timedScore.getScore().networkKey.wifiKey.bssid, timedScore);
|
||||
}
|
||||
}
|
||||
if (savedState.containsKey(KEY_PASSPOINT_UNIQUE_ID)) {
|
||||
mPasspointUniqueId = savedState.getString(KEY_PASSPOINT_UNIQUE_ID);
|
||||
}
|
||||
if (savedState.containsKey(KEY_FQDN)) {
|
||||
mFqdn = savedState.getString(KEY_FQDN);
|
||||
}
|
||||
@@ -351,6 +356,7 @@ public class AccessPoint implements Comparable<AccessPoint> {
|
||||
*/
|
||||
public AccessPoint(Context context, PasspointConfiguration config) {
|
||||
mContext = context;
|
||||
mPasspointUniqueId = config.getUniqueId();
|
||||
mFqdn = config.getHomeSp().getFqdn();
|
||||
mProviderFriendlyName = config.getHomeSp().getFriendlyName();
|
||||
mSubscriptionExpirationTimeInMillis = config.getSubscriptionExpirationTimeInMillis();
|
||||
@@ -371,6 +377,7 @@ public class AccessPoint implements Comparable<AccessPoint> {
|
||||
mContext = context;
|
||||
networkId = config.networkId;
|
||||
mConfig = config;
|
||||
mPasspointUniqueId = config.getKey();
|
||||
mFqdn = config.FQDN;
|
||||
setScanResultsPasspoint(homeScans, roamingScans);
|
||||
updateKey();
|
||||
@@ -407,7 +414,7 @@ public class AccessPoint implements Comparable<AccessPoint> {
|
||||
if (isPasspoint()) {
|
||||
mKey = getKey(mConfig);
|
||||
} else if (isPasspointConfig()) {
|
||||
mKey = getKey(mFqdn);
|
||||
mKey = getKey(mPasspointUniqueId);
|
||||
} else if (isOsuProvider()) {
|
||||
mKey = getKey(mOsuProvider);
|
||||
} else { // Non-Passpoint AP
|
||||
@@ -677,19 +684,19 @@ public class AccessPoint implements Comparable<AccessPoint> {
|
||||
*/
|
||||
public static String getKey(WifiConfiguration config) {
|
||||
if (config.isPasspoint()) {
|
||||
return getKey(config.FQDN);
|
||||
return getKey(config.getKey());
|
||||
} else {
|
||||
return getKey(removeDoubleQuotes(config.SSID), config.BSSID, getSecurity(config));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the AccessPoint key corresponding to a Passpoint network by its FQDN.
|
||||
* Returns the AccessPoint key corresponding to a Passpoint network by its unique identifier.
|
||||
*/
|
||||
public static String getKey(String fqdn) {
|
||||
public static String getKey(String passpointUniqueId) {
|
||||
return new StringBuilder()
|
||||
.append(KEY_PREFIX_FQDN)
|
||||
.append(fqdn).toString();
|
||||
.append(KEY_PREFIX_PASSPOINT_UNIQUE_ID)
|
||||
.append(passpointUniqueId).toString();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -766,7 +773,7 @@ public class AccessPoint implements Comparable<AccessPoint> {
|
||||
|
||||
public boolean matches(WifiConfiguration config) {
|
||||
if (config.isPasspoint()) {
|
||||
return (isPasspoint() && config.FQDN.equals(mConfig.FQDN));
|
||||
return (isPasspoint() && config.getKey().equals(mConfig.getKey()));
|
||||
}
|
||||
|
||||
if (!ssid.equals(removeDoubleQuotes(config.SSID))
|
||||
@@ -1052,7 +1059,7 @@ public class AccessPoint implements Comparable<AccessPoint> {
|
||||
public String getConfigName() {
|
||||
if (mConfig != null && mConfig.isPasspoint()) {
|
||||
return mConfig.providerFriendlyName;
|
||||
} else if (mFqdn != null) {
|
||||
} else if (mPasspointUniqueId != null) {
|
||||
return mProviderFriendlyName;
|
||||
} else {
|
||||
return ssid;
|
||||
@@ -1254,7 +1261,7 @@ public class AccessPoint implements Comparable<AccessPoint> {
|
||||
* Return true if this AccessPoint represents a Passpoint provider configuration.
|
||||
*/
|
||||
public boolean isPasspointConfig() {
|
||||
return mFqdn != null && mConfig == null;
|
||||
return mPasspointUniqueId != null && mConfig == null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1310,8 +1317,12 @@ public class AccessPoint implements Comparable<AccessPoint> {
|
||||
if (info.isOsuAp() || mOsuStatus != null) {
|
||||
return (info.isOsuAp() && mOsuStatus != null);
|
||||
} else if (info.isPasspointAp() || isPasspoint()) {
|
||||
// TODO: Use TextUtils.equals(info.getPasspointUniqueId(), mConfig.getKey()) when API
|
||||
// is available
|
||||
return (info.isPasspointAp() && isPasspoint()
|
||||
&& TextUtils.equals(info.getPasspointFqdn(), mConfig.FQDN));
|
||||
&& TextUtils.equals(info.getPasspointFqdn(), mConfig.FQDN)
|
||||
&& TextUtils.equals(info.getPasspointProviderFriendlyName(),
|
||||
mConfig.providerFriendlyName));
|
||||
}
|
||||
|
||||
if (networkId != WifiConfiguration.INVALID_NETWORK_ID) {
|
||||
@@ -1377,6 +1388,9 @@ public class AccessPoint implements Comparable<AccessPoint> {
|
||||
if (mNetworkInfo != null) {
|
||||
savedState.putParcelable(KEY_NETWORKINFO, mNetworkInfo);
|
||||
}
|
||||
if (mPasspointUniqueId != null) {
|
||||
savedState.putString(KEY_PASSPOINT_UNIQUE_ID, mPasspointUniqueId);
|
||||
}
|
||||
if (mFqdn != null) {
|
||||
savedState.putString(KEY_FQDN, mFqdn);
|
||||
}
|
||||
@@ -1949,11 +1963,11 @@ public class AccessPoint implements Comparable<AccessPoint> {
|
||||
return;
|
||||
}
|
||||
|
||||
String fqdn = passpointConfig.getHomeSp().getFqdn();
|
||||
String uniqueId = passpointConfig.getUniqueId();
|
||||
for (Pair<WifiConfiguration, Map<Integer, List<ScanResult>>> pairing :
|
||||
wifiManager.getAllMatchingWifiConfigs(wifiManager.getScanResults())) {
|
||||
WifiConfiguration config = pairing.first;
|
||||
if (TextUtils.equals(config.FQDN, fqdn)) {
|
||||
if (TextUtils.equals(config.getKey(), uniqueId)) {
|
||||
List<ScanResult> homeScans =
|
||||
pairing.second.get(WifiManager.PASSPOINT_HOME_NETWORK);
|
||||
List<ScanResult> roamingScans =
|
||||
|
||||
@@ -84,7 +84,7 @@ public class TestAccessPointBuilder {
|
||||
bundle.putParcelable(AccessPoint.KEY_NETWORKINFO, mNetworkInfo);
|
||||
bundle.putParcelable(AccessPoint.KEY_WIFIINFO, mWifiInfo);
|
||||
if (mFqdn != null) {
|
||||
bundle.putString(AccessPoint.KEY_FQDN, mFqdn);
|
||||
bundle.putString(AccessPoint.KEY_PASSPOINT_UNIQUE_ID, mFqdn);
|
||||
}
|
||||
if (mProviderFriendlyName != null) {
|
||||
bundle.putString(AccessPoint.KEY_PROVIDER_FRIENDLY_NAME, mProviderFriendlyName);
|
||||
|
||||
@@ -606,7 +606,7 @@ public class WifiTracker implements LifecycleObserver, OnStart, OnStop, OnDestro
|
||||
|
||||
List<ScanResult> cachedScanResults = new ArrayList<>(mScanResultCache.values());
|
||||
|
||||
// Add a unique Passpoint AccessPoint for each Passpoint profile's FQDN.
|
||||
// Add a unique Passpoint AccessPoint for each Passpoint profile's unique identifier.
|
||||
accessPoints.addAll(updatePasspointAccessPoints(
|
||||
mWifiManager.getAllMatchingWifiConfigs(cachedScanResults), cachedAccessPoints));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user