Merge changes from topic "Passpoint_FQDN"
* changes: [Passpoint] Allow multiple profiles w/identical FQDN [Passpoint] Allow multiple profiles w/identical FQDN
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));
|
||||
|
||||
|
||||
@@ -270,4 +270,6 @@ interface IWifiManager
|
||||
void setScanThrottleEnabled(boolean enable);
|
||||
|
||||
boolean isScanThrottleEnabled();
|
||||
|
||||
Map getAllMatchingPasspointProfilesForScanResults(in List<ScanResult> scanResult);
|
||||
}
|
||||
|
||||
@@ -2112,7 +2112,8 @@ public class WifiConfiguration implements Parcelable {
|
||||
return !TextUtils.isEmpty(FQDN)
|
||||
&& !TextUtils.isEmpty(providerFriendlyName)
|
||||
&& enterpriseConfig != null
|
||||
&& enterpriseConfig.getEapMethod() != WifiEnterpriseConfig.Eap.NONE;
|
||||
&& enterpriseConfig.getEapMethod() != WifiEnterpriseConfig.Eap.NONE
|
||||
&& !TextUtils.isEmpty(mPasspointUniqueId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2494,12 +2495,17 @@ public class WifiConfiguration implements Parcelable {
|
||||
*/
|
||||
@NonNull
|
||||
public String getKey() {
|
||||
String key = providerFriendlyName == null
|
||||
? getSsidAndSecurityTypeString()
|
||||
: FQDN + KeyMgmt.strings[KeyMgmt.WPA_EAP];
|
||||
// Passpoint ephemeral networks have their unique identifier set. Return it as is to be
|
||||
// able to match internally.
|
||||
if (mPasspointUniqueId != null) {
|
||||
return mPasspointUniqueId;
|
||||
}
|
||||
|
||||
String key = getSsidAndSecurityTypeString();
|
||||
if (!shared) {
|
||||
key += "-" + UserHandle.getUserHandleForUid(creatorUid).getIdentifier();
|
||||
}
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
@@ -2754,6 +2760,7 @@ public class WifiConfiguration implements Parcelable {
|
||||
requirePMF = source.requirePMF;
|
||||
updateIdentifier = source.updateIdentifier;
|
||||
carrierId = source.carrierId;
|
||||
mPasspointUniqueId = source.mPasspointUniqueId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2826,6 +2833,7 @@ public class WifiConfiguration implements Parcelable {
|
||||
dest.writeInt(osu ? 1 : 0);
|
||||
dest.writeLong(randomizedMacExpirationTimeMs);
|
||||
dest.writeInt(carrierId);
|
||||
dest.writeString(mPasspointUniqueId);
|
||||
}
|
||||
|
||||
/** Implement the Parcelable interface {@hide} */
|
||||
@@ -2900,6 +2908,7 @@ public class WifiConfiguration implements Parcelable {
|
||||
config.osu = in.readInt() != 0;
|
||||
config.randomizedMacExpirationTimeMs = in.readLong();
|
||||
config.carrierId = in.readInt();
|
||||
config.mPasspointUniqueId = in.readString();
|
||||
return config;
|
||||
}
|
||||
|
||||
@@ -2907,4 +2916,28 @@ public class WifiConfiguration implements Parcelable {
|
||||
return new WifiConfiguration[size];
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Passpoint Unique identifier
|
||||
* @hide
|
||||
*/
|
||||
private String mPasspointUniqueId = null;
|
||||
|
||||
/**
|
||||
* Set the Passpoint unique identifier
|
||||
* @param uniqueId Passpoint unique identifier to be set
|
||||
* @hide
|
||||
*/
|
||||
public void setPasspointUniqueId(String uniqueId) {
|
||||
mPasspointUniqueId = uniqueId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Passpoint unique identifier
|
||||
* @hide
|
||||
*/
|
||||
public String getPasspointUniqueId() {
|
||||
return mPasspointUniqueId;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -291,6 +291,11 @@ public class WifiInfo implements Parcelable {
|
||||
*/
|
||||
private boolean mMeteredHint;
|
||||
|
||||
/**
|
||||
* Passpoint unique key
|
||||
*/
|
||||
private String mPasspointUniqueId;
|
||||
|
||||
/** @hide */
|
||||
@UnsupportedAppUsage
|
||||
public WifiInfo() {
|
||||
@@ -322,6 +327,7 @@ public class WifiInfo implements Parcelable {
|
||||
setRequestingPackageName(null);
|
||||
setFQDN(null);
|
||||
setProviderFriendlyName(null);
|
||||
setPasspointUniqueId(null);
|
||||
txBad = 0;
|
||||
txSuccess = 0;
|
||||
rxSuccess = 0;
|
||||
@@ -370,6 +376,7 @@ public class WifiInfo implements Parcelable {
|
||||
mWifiStandard = source.mWifiStandard;
|
||||
mMaxSupportedTxLinkSpeed = source.mMaxSupportedTxLinkSpeed;
|
||||
mMaxSupportedRxLinkSpeed = source.mMaxSupportedRxLinkSpeed;
|
||||
mPasspointUniqueId = source.mPasspointUniqueId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -977,6 +984,7 @@ public class WifiInfo implements Parcelable {
|
||||
dest.writeInt(mWifiStandard);
|
||||
dest.writeInt(mMaxSupportedTxLinkSpeed);
|
||||
dest.writeInt(mMaxSupportedRxLinkSpeed);
|
||||
dest.writeString(mPasspointUniqueId);
|
||||
}
|
||||
|
||||
/** Implement the Parcelable interface {@hide} */
|
||||
@@ -1021,6 +1029,7 @@ public class WifiInfo implements Parcelable {
|
||||
info.mWifiStandard = in.readInt();
|
||||
info.mMaxSupportedTxLinkSpeed = in.readInt();
|
||||
info.mMaxSupportedRxLinkSpeed = in.readInt();
|
||||
info.mPasspointUniqueId = in.readString();
|
||||
return info;
|
||||
}
|
||||
|
||||
@@ -1028,4 +1037,24 @@ public class WifiInfo implements Parcelable {
|
||||
return new WifiInfo[size];
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Set the Passpoint unique identifier for the current connection
|
||||
*
|
||||
* @param passpointUniqueId Unique identifier
|
||||
* @hide
|
||||
*/
|
||||
public void setPasspointUniqueId(@Nullable String passpointUniqueId) {
|
||||
mPasspointUniqueId = passpointUniqueId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Passpoint unique identifier for the current connection
|
||||
*
|
||||
* @return Passpoint unique identifier
|
||||
* @hide
|
||||
*/
|
||||
public @Nullable String getPasspointUniqueId() {
|
||||
return mPasspointUniqueId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1400,8 +1400,7 @@ public class WifiManager {
|
||||
List<Pair<WifiConfiguration, Map<Integer, List<ScanResult>>>> configs = new ArrayList<>();
|
||||
try {
|
||||
Map<String, Map<Integer, List<ScanResult>>> results =
|
||||
mService.getAllMatchingFqdnsForScanResults(
|
||||
scanResults);
|
||||
mService.getAllMatchingPasspointProfilesForScanResults(scanResults);
|
||||
if (results.isEmpty()) {
|
||||
return configs;
|
||||
}
|
||||
@@ -1409,8 +1408,8 @@ public class WifiManager {
|
||||
mService.getWifiConfigsForPasspointProfiles(
|
||||
new ArrayList<>(results.keySet()));
|
||||
for (WifiConfiguration configuration : wifiConfigurations) {
|
||||
Map<Integer, List<ScanResult>> scanResultsPerNetworkType = results.get(
|
||||
configuration.FQDN);
|
||||
Map<Integer, List<ScanResult>> scanResultsPerNetworkType =
|
||||
results.get(configuration.getKey());
|
||||
if (scanResultsPerNetworkType != null) {
|
||||
configs.add(Pair.create(configuration, scanResultsPerNetworkType));
|
||||
}
|
||||
@@ -1962,9 +1961,11 @@ public class WifiManager {
|
||||
* for connecting to Passpoint networks that are operated by the Passpoint
|
||||
* service provider specified in the configuration.
|
||||
*
|
||||
* Each configuration is uniquely identified by its FQDN (Fully Qualified Domain
|
||||
* Name). In the case when there is an existing configuration with the same
|
||||
* FQDN, the new configuration will replace the existing configuration.
|
||||
* Each configuration is uniquely identified by a unique key which depends on the contents of
|
||||
* the configuration. This allows the caller to install multiple profiles with the same FQDN
|
||||
* (Fully qualified domain name). Therefore, in order to update an existing profile, it is
|
||||
* first required to remove it using {@link WifiManager#removePasspointConfiguration(String)}.
|
||||
* Otherwise, a new profile will be added with both configuration.
|
||||
*
|
||||
* @param config The Passpoint configuration to be added
|
||||
* @throws IllegalArgumentException if configuration is invalid or Passpoint is not enabled on
|
||||
|
||||
@@ -569,6 +569,7 @@ public final class WifiNetworkSuggestion implements Parcelable {
|
||||
private WifiConfiguration buildWifiConfigurationForPasspoint() {
|
||||
WifiConfiguration wifiConfiguration = new WifiConfiguration();
|
||||
wifiConfiguration.FQDN = mPasspointConfiguration.getHomeSp().getFqdn();
|
||||
wifiConfiguration.setPasspointUniqueId(mPasspointConfiguration.getUniqueId());
|
||||
wifiConfiguration.priority = mPriority;
|
||||
wifiConfiguration.meteredOverride =
|
||||
mIsMetered ? WifiConfiguration.METERED_OVERRIDE_METERED
|
||||
@@ -804,7 +805,7 @@ public final class WifiNetworkSuggestion implements Parcelable {
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(wifiConfiguration.SSID, wifiConfiguration.BSSID,
|
||||
wifiConfiguration.allowedKeyManagement, wifiConfiguration.FQDN);
|
||||
wifiConfiguration.allowedKeyManagement, wifiConfiguration.getKey());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -827,7 +828,8 @@ public final class WifiNetworkSuggestion implements Parcelable {
|
||||
&& TextUtils.equals(this.wifiConfiguration.BSSID, lhs.wifiConfiguration.BSSID)
|
||||
&& Objects.equals(this.wifiConfiguration.allowedKeyManagement,
|
||||
lhs.wifiConfiguration.allowedKeyManagement)
|
||||
&& TextUtils.equals(this.wifiConfiguration.FQDN, lhs.wifiConfiguration.FQDN);
|
||||
&& TextUtils.equals(this.wifiConfiguration.getKey(),
|
||||
lhs.wifiConfiguration.getKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -908,6 +908,9 @@ public final class PasspointConfiguration implements Parcelable {
|
||||
throw new IllegalStateException("Credential or HomeSP are not initialized");
|
||||
}
|
||||
|
||||
return mHomeSp.getFqdn();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(String.format("%s_%x%x", mHomeSp.getFqdn(), mHomeSp.hashCode(),
|
||||
mCredential.hashCode()));
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
|
||||
package android.net.wifi.hotspot2.pps;
|
||||
|
||||
import android.os.Parcelable;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
@@ -299,8 +299,10 @@ public final class HomeSp implements Parcelable {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(mFqdn, mFriendlyName, mIconUrl, mHomeNetworkIds, mMatchAllOis,
|
||||
mMatchAnyOis, mOtherHomePartners, mRoamingConsortiumOis);
|
||||
return Objects.hash(mFqdn, mFriendlyName, mIconUrl,
|
||||
mHomeNetworkIds, Arrays.hashCode(mMatchAllOis),
|
||||
Arrays.hashCode(mMatchAnyOis), Arrays.hashCode(mOtherHomePartners),
|
||||
Arrays.hashCode(mRoamingConsortiumOis));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1551,14 +1551,15 @@ public class WifiManagerTest {
|
||||
*/
|
||||
@Test
|
||||
public void testGetAllMatchingWifiConfigs() throws Exception {
|
||||
Map<String, List<ScanResult>> fqdns = new HashMap<>();
|
||||
fqdns.put("www.test.com", new ArrayList<>());
|
||||
when(mWifiService.getAllMatchingFqdnsForScanResults(any(List.class))).thenReturn(fqdns);
|
||||
Map<String, List<ScanResult>> passpointProfiles = new HashMap<>();
|
||||
passpointProfiles.put("www.test.com_987a69bca26", new ArrayList<>());
|
||||
when(mWifiService.getAllMatchingPasspointProfilesForScanResults(
|
||||
any(List.class))).thenReturn(passpointProfiles);
|
||||
InOrder inOrder = inOrder(mWifiService);
|
||||
|
||||
mWifiManager.getAllMatchingWifiConfigs(new ArrayList<>());
|
||||
|
||||
inOrder.verify(mWifiService).getAllMatchingFqdnsForScanResults(any(List.class));
|
||||
inOrder.verify(mWifiService).getAllMatchingPasspointProfilesForScanResults(any(List.class));
|
||||
inOrder.verify(mWifiService).getWifiConfigsForPasspointProfiles(any(List.class));
|
||||
}
|
||||
|
||||
|
||||
@@ -20,8 +20,11 @@ import static android.net.wifi.WifiConfiguration.METERED_OVERRIDE_NONE;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import android.net.wifi.hotspot2.pps.Credential;
|
||||
import android.net.wifi.hotspot2.pps.HomeSp;
|
||||
import android.os.Parcel;
|
||||
|
||||
import androidx.test.filters.SmallTest;
|
||||
@@ -367,16 +370,55 @@ public class PasspointConfigurationTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify that the unique identifier generated is correct.
|
||||
* Verify that the unique identifier generated is identical for two instances
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void validateUniqueId() throws Exception {
|
||||
PasspointConfiguration config = PasspointTestUtils.createConfig();
|
||||
String uniqueId;
|
||||
uniqueId = config.getUniqueId();
|
||||
assertEquals(uniqueId, config.getHomeSp().getFqdn());
|
||||
PasspointConfiguration config1 = PasspointTestUtils.createConfig();
|
||||
PasspointConfiguration config2 = PasspointTestUtils.createConfig();
|
||||
|
||||
assertEquals(config1.getUniqueId(), config2.getUniqueId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify that the unique identifier generated is different for two instances with different
|
||||
* HomeSp node
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void validateUniqueIdDifferentHomeSp() throws Exception {
|
||||
PasspointConfiguration config1 = PasspointTestUtils.createConfig();
|
||||
|
||||
// Modify config2's RCOIs to a different set of values
|
||||
PasspointConfiguration config2 = PasspointTestUtils.createConfig();
|
||||
HomeSp homeSp = config2.getHomeSp();
|
||||
homeSp.setRoamingConsortiumOis(new long[] {0xaa, 0xbb});
|
||||
config2.setHomeSp(homeSp);
|
||||
|
||||
assertNotEquals(config1.getUniqueId(), config2.getUniqueId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify that the unique identifier generated is different for two instances with different
|
||||
* Credential node
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void validateUniqueIdDifferentCredential() throws Exception {
|
||||
PasspointConfiguration config1 = PasspointTestUtils.createConfig();
|
||||
|
||||
// Modify config2's RCOIs to a different set of values
|
||||
PasspointConfiguration config2 = PasspointTestUtils.createConfig();
|
||||
Credential credential = config2.getCredential();
|
||||
credential.setRealm("realm2.example.com");
|
||||
credential.getSimCredential().setImsi("350460*");
|
||||
config2.setCredential(credential);
|
||||
|
||||
assertNotEquals(config1.getUniqueId(), config2.getUniqueId());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user