summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointNetworkDetailsTracker.java12
-rw-r--r--libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointWifiEntry.java12
-rw-r--r--libs/WifiTrackerLib/src/com/android/wifitrackerlib/SavedNetworkTracker.java8
-rw-r--r--libs/WifiTrackerLib/src/com/android/wifitrackerlib/WifiPickerTracker.java16
-rw-r--r--libs/WifiTrackerLib/tests/src/com/android/wifitrackerlib/PasspointWifiEntryTest.java2
-rw-r--r--libs/WifiTrackerLib/tests/src/com/android/wifitrackerlib/SavedNetworkTrackerTest.java2
-rw-r--r--libs/WifiTrackerLib/tests/src/com/android/wifitrackerlib/WifiPickerTrackerTest.java14
7 files changed, 39 insertions, 27 deletions
diff --git a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointNetworkDetailsTracker.java b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointNetworkDetailsTracker.java
index bdfacca9e..5cee304f1 100644
--- a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointNetworkDetailsTracker.java
+++ b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointNetworkDetailsTracker.java
@@ -18,7 +18,7 @@ package com.android.wifitrackerlib;
import static androidx.core.util.Preconditions.checkNotNull;
-import static com.android.wifitrackerlib.PasspointWifiEntry.fqdnToPasspointWifiEntryKey;
+import static com.android.wifitrackerlib.PasspointWifiEntry.uniqueIdToPasspointWifiEntryKey;
import static com.android.wifitrackerlib.WifiEntry.CONNECTED_STATE_CONNECTED;
import android.content.Context;
@@ -70,10 +70,12 @@ class PasspointNetworkDetailsTracker extends NetworkDetailsTracker {
PasspointConfiguration passpointConfig = mWifiManager.getPasspointConfigurations().stream()
.filter(config -> TextUtils.equals(
- fqdnToPasspointWifiEntryKey(config.getHomeSp().getFqdn()), key))
+ uniqueIdToPasspointWifiEntryKey(config.getUniqueId()), key))
.findAny().get();
- checkNotNull(passpointConfig, "Cannot find PasspointConfiguration with matching FQDN!");
+ checkNotNull(passpointConfig,
+ "Cannot find PasspointConfiguration with matching unique identifier: "
+ + passpointConfig.getUniqueId());
mChosenEntry = new PasspointWifiEntry(mContext, mMainHandler, passpointConfig,
mWifiManager, false /* forSavedNetworksPage */);
@@ -139,7 +141,7 @@ class PasspointNetworkDetailsTracker extends NetworkDetailsTracker {
mWifiManager.getAllMatchingWifiConfigs(scanResults);
for (Pair<WifiConfiguration, Map<Integer, List<ScanResult>>> pair : matchingWifiConfigs) {
final WifiConfiguration wifiConfig = pair.first;
- final String key = fqdnToPasspointWifiEntryKey(wifiConfig.FQDN);
+ final String key = uniqueIdToPasspointWifiEntryKey(wifiConfig.getKey());
if (TextUtils.equals(key, mChosenEntry.getKey())) {
mChosenEntry.updateScanResultInfo(wifiConfig,
@@ -179,7 +181,7 @@ class PasspointNetworkDetailsTracker extends NetworkDetailsTracker {
private void conditionallyUpdateConfig() {
mWifiManager.getPasspointConfigurations().stream()
.filter(config -> TextUtils.equals(
- fqdnToPasspointWifiEntryKey(config.getHomeSp().getFqdn()),
+ uniqueIdToPasspointWifiEntryKey(config.getUniqueId()),
mChosenEntry.getKey()))
.findAny().ifPresent(config -> mChosenEntry.updatePasspointConfig(config));
}
diff --git a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointWifiEntry.java b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointWifiEntry.java
index db773ea64..6d03f1726 100644
--- a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointWifiEntry.java
+++ b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointWifiEntry.java
@@ -30,7 +30,6 @@ import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.net.wifi.hotspot2.PasspointConfiguration;
-import android.net.wifi.hotspot2.pps.HomeSp;
import android.os.Handler;
import android.text.TextUtils;
@@ -84,9 +83,8 @@ public class PasspointWifiEntry extends WifiEntry {
mContext = context;
mPasspointConfig = passpointConfig;
- final HomeSp homeSp = passpointConfig.getHomeSp();
- mKey = fqdnToPasspointWifiEntryKey(homeSp.getFqdn());
- mFriendlyName = homeSp.getFriendlyName();
+ mKey = uniqueIdToPasspointWifiEntryKey(passpointConfig.getUniqueId());
+ mFriendlyName = passpointConfig.getHomeSp().getFriendlyName();
mSecurity = SECURITY_NONE; //TODO: Should this always be Enterprise?
mSubscriptionExpirationTimeInMillis =
passpointConfig.getSubscriptionExpirationTimeInMillis();
@@ -387,9 +385,9 @@ public class PasspointWifiEntry extends WifiEntry {
}
@NonNull
- static String fqdnToPasspointWifiEntryKey(@NonNull String fqdn) {
- checkNotNull(fqdn, "Cannot create key with null fqdn!");
- return KEY_PREFIX + fqdn;
+ static String uniqueIdToPasspointWifiEntryKey(@NonNull String uniqueId) {
+ checkNotNull(uniqueId, "Cannot create key with null unique id!");
+ return KEY_PREFIX + uniqueId;
}
@Override
diff --git a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/SavedNetworkTracker.java b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/SavedNetworkTracker.java
index 7bab36a0a..f6016677f 100644
--- a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/SavedNetworkTracker.java
+++ b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/SavedNetworkTracker.java
@@ -18,7 +18,7 @@ package com.android.wifitrackerlib;
import static androidx.core.util.Preconditions.checkNotNull;
-import static com.android.wifitrackerlib.PasspointWifiEntry.fqdnToPasspointWifiEntryKey;
+import static com.android.wifitrackerlib.PasspointWifiEntry.uniqueIdToPasspointWifiEntryKey;
import static com.android.wifitrackerlib.StandardWifiEntry.wifiConfigToStandardWifiEntryKey;
import static com.android.wifitrackerlib.Utils.mapScanResultsToKey;
@@ -221,8 +221,8 @@ public class SavedNetworkTracker extends BaseWifiTracker {
mWifiManager.getAllMatchingWifiConfigs(scanResults);
for (Pair<WifiConfiguration, Map<Integer, List<ScanResult>>> pair : matchingWifiConfigs) {
final WifiConfiguration wifiConfig = pair.first;
- final String key = fqdnToPasspointWifiEntryKey(wifiConfig.FQDN);
- // Skip in case we don't have a PasspointWifiEntry for the returned fqdn
+ final String key = uniqueIdToPasspointWifiEntryKey(wifiConfig.getKey());
+ // Skip in case we don't have a PasspointWifiEntry for the returned unique identifier.
if (!mPasspointWifiEntryCache.containsKey(key)) {
continue;
}
@@ -325,7 +325,7 @@ public class SavedNetworkTracker extends BaseWifiTracker {
final Map<String, PasspointConfiguration> passpointConfigsByKey =
configs.stream().collect(toMap(
- (config) -> fqdnToPasspointWifiEntryKey(config.getHomeSp().getFqdn()),
+ (config) -> uniqueIdToPasspointWifiEntryKey(config.getUniqueId()),
Function.identity()));
// Iterate through current entries and update each entry's config or remove if no config
diff --git a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/WifiPickerTracker.java b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/WifiPickerTracker.java
index 13ea43d2a..21d3f2c27 100644
--- a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/WifiPickerTracker.java
+++ b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/WifiPickerTracker.java
@@ -19,7 +19,7 @@ package com.android.wifitrackerlib;
import static androidx.core.util.Preconditions.checkNotNull;
import static com.android.wifitrackerlib.OsuWifiEntry.osuProviderToOsuWifiEntryKey;
-import static com.android.wifitrackerlib.PasspointWifiEntry.fqdnToPasspointWifiEntryKey;
+import static com.android.wifitrackerlib.PasspointWifiEntry.uniqueIdToPasspointWifiEntryKey;
import static com.android.wifitrackerlib.StandardWifiEntry.wifiConfigToStandardWifiEntryKey;
import static com.android.wifitrackerlib.Utils.mapScanResultsToKey;
import static com.android.wifitrackerlib.WifiEntry.CONNECTED_STATE_CONNECTED;
@@ -333,8 +333,8 @@ public class WifiPickerTracker extends BaseWifiTracker {
pair.second.get(WifiManager.PASSPOINT_HOME_NETWORK);
final List<ScanResult> roamingScans =
pair.second.get(WifiManager.PASSPOINT_ROAMING_NETWORK);
- final String key = fqdnToPasspointWifiEntryKey(wifiConfig.FQDN);
- // Skip in case we don't have a Passpoint configuration for the returned fqdn
+ final String key = uniqueIdToPasspointWifiEntryKey(wifiConfig.getKey());
+ // Skip in case we don't have a Passpoint configuration for the returned unique key
if (!mPasspointConfigCache.containsKey(key)) {
continue;
}
@@ -455,8 +455,8 @@ public class WifiPickerTracker extends BaseWifiTracker {
mPasspointConfigCache.clear();
mPasspointConfigCache.putAll(configs.stream().collect(
- toMap((config) -> fqdnToPasspointWifiEntryKey(
- config.getHomeSp().getFqdn()), Function.identity())));
+ toMap((config) -> uniqueIdToPasspointWifiEntryKey(
+ config.getUniqueId()), Function.identity())));
// Iterate through current entries and update each entry's config or remove if no config
// matches the entry anymore.
@@ -530,12 +530,16 @@ public class WifiPickerTracker extends BaseWifiTracker {
return;
}
+ // TODO(b/148556276): This logic will match the fqdn of the connected passpoint network to
+ // the first PasspointConfiguration found. This may or may not represent the actual
+ // connection, so we will need to use WifiInfo.getPasspointUniqueId() once it is ready to be
+ // a public API.
final String connectedFqdn = wifiInfo.getPasspointFqdn();
mPasspointConfigCache.values().stream()
.filter(config ->
config.getHomeSp().getFqdn() == connectedFqdn
&& !mPasspointWifiEntryCache.containsKey(
- fqdnToPasspointWifiEntryKey(connectedFqdn)))
+ uniqueIdToPasspointWifiEntryKey(config.getUniqueId())))
.findAny().ifPresent(config -> {
final PasspointWifiEntry connectedEntry =
new PasspointWifiEntry(mContext, mMainHandler, config, mWifiManager,
diff --git a/libs/WifiTrackerLib/tests/src/com/android/wifitrackerlib/PasspointWifiEntryTest.java b/libs/WifiTrackerLib/tests/src/com/android/wifitrackerlib/PasspointWifiEntryTest.java
index 0a1870e58..0759f5e42 100644
--- a/libs/WifiTrackerLib/tests/src/com/android/wifitrackerlib/PasspointWifiEntryTest.java
+++ b/libs/WifiTrackerLib/tests/src/com/android/wifitrackerlib/PasspointWifiEntryTest.java
@@ -25,6 +25,7 @@ import android.content.Context;
import android.content.res.Resources;
import android.net.wifi.WifiManager;
import android.net.wifi.hotspot2.PasspointConfiguration;
+import android.net.wifi.hotspot2.pps.Credential;
import android.net.wifi.hotspot2.pps.HomeSp;
import android.os.Handler;
import android.os.test.TestLooper;
@@ -83,6 +84,7 @@ public class PasspointWifiEntryTest {
HomeSp homeSp = new HomeSp();
homeSp.setFqdn("fqdn");
passpointConfiguration.setHomeSp(homeSp);
+ passpointConfiguration.setCredential(new Credential());
return passpointConfiguration;
}
diff --git a/libs/WifiTrackerLib/tests/src/com/android/wifitrackerlib/SavedNetworkTrackerTest.java b/libs/WifiTrackerLib/tests/src/com/android/wifitrackerlib/SavedNetworkTrackerTest.java
index ae4d671ba..f78900df0 100644
--- a/libs/WifiTrackerLib/tests/src/com/android/wifitrackerlib/SavedNetworkTrackerTest.java
+++ b/libs/WifiTrackerLib/tests/src/com/android/wifitrackerlib/SavedNetworkTrackerTest.java
@@ -34,6 +34,7 @@ import android.net.NetworkScoreManager;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiManager;
import android.net.wifi.hotspot2.PasspointConfiguration;
+import android.net.wifi.hotspot2.pps.Credential;
import android.net.wifi.hotspot2.pps.HomeSp;
import android.os.Handler;
import android.os.test.TestLooper;
@@ -321,6 +322,7 @@ public class SavedNetworkTrackerTest {
homeSp.setFqdn("fqdn");
homeSp.setFriendlyName("friendlyName");
passpointConfig.setHomeSp(homeSp);
+ passpointConfig.setCredential(new Credential());
when(mMockWifiManager.getPasspointConfigurations())
.thenReturn(Collections.singletonList(passpointConfig));
diff --git a/libs/WifiTrackerLib/tests/src/com/android/wifitrackerlib/WifiPickerTrackerTest.java b/libs/WifiTrackerLib/tests/src/com/android/wifitrackerlib/WifiPickerTrackerTest.java
index 4f572d562..7de9a9e3a 100644
--- a/libs/WifiTrackerLib/tests/src/com/android/wifitrackerlib/WifiPickerTrackerTest.java
+++ b/libs/WifiTrackerLib/tests/src/com/android/wifitrackerlib/WifiPickerTrackerTest.java
@@ -22,6 +22,7 @@ import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.atLeastOnce;
+import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -36,6 +37,7 @@ import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.net.wifi.hotspot2.PasspointConfiguration;
+import android.net.wifi.hotspot2.pps.Credential;
import android.net.wifi.hotspot2.pps.HomeSp;
import android.os.Handler;
import android.os.test.TestLooper;
@@ -510,6 +512,7 @@ public class WifiPickerTrackerTest {
homeSp.setFqdn("fqdn");
homeSp.setFriendlyName("friendlyName");
passpointConfig.setHomeSp(homeSp);
+ passpointConfig.setCredential(new Credential());
when(mMockWifiManager.getPasspointConfigurations())
.thenReturn(Collections.singletonList(passpointConfig));
wifiPickerTracker.onStart();
@@ -517,8 +520,8 @@ public class WifiPickerTrackerTest {
any(), any(), any());
mTestLooper.dispatchAll();
- final WifiConfiguration wifiConfig = new WifiConfiguration();
- wifiConfig.FQDN = "fqdn";
+ final WifiConfiguration wifiConfig = spy(new WifiConfiguration());
+ when(wifiConfig.getKey()).thenReturn(passpointConfig.getUniqueId());
final Map<Integer, List<ScanResult>> mapping = new HashMap<>();
mapping.put(WifiManager.PASSPOINT_HOME_NETWORK, Collections.singletonList(
buildScanResult("ssid", "bssid", START_MILLIS)));
@@ -537,13 +540,14 @@ public class WifiPickerTrackerTest {
final String fqdn = "fqdn";
final String friendlyName = "friendlyName";
final WifiPickerTracker wifiPickerTracker = createTestWifiPickerTracker();
- final PasspointConfiguration config = new PasspointConfiguration();
+ final PasspointConfiguration passpointConfig = new PasspointConfiguration();
final HomeSp homeSp = new HomeSp();
homeSp.setFqdn(fqdn);
homeSp.setFriendlyName(friendlyName);
- config.setHomeSp(homeSp);
+ passpointConfig.setHomeSp(homeSp);
+ passpointConfig.setCredential(new Credential());
when(mMockWifiManager.getPasspointConfigurations())
- .thenReturn(Collections.singletonList(config));
+ .thenReturn(Collections.singletonList(passpointConfig));
when(mMockWifiInfo.isPasspointAp()).thenReturn(true);
when(mMockWifiInfo.getPasspointFqdn()).thenReturn(fqdn);
when(mMockWifiInfo.getRssi()).thenReturn(-50);