summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2019-11-22 01:42:21 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2019-11-22 01:42:21 +0000
commit4f0cb572c606455ae8e28275f3cd08e37e5e43ed (patch)
tree8f0965d3c486dd8a7cc5c823f05db2508fc05dbf
parent4b58fd18d566a1955fb2bb54d93a0ea5520001c8 (diff)
parent37a4b6bbd3410ff2225c2af31237ee4e8e11d359 (diff)
Merge "Revert submission"
-rw-r--r--service/java/com/android/server/wifi/ConfigurationMap.java24
-rw-r--r--service/java/com/android/server/wifi/ScanResultMatchInfo.java30
-rw-r--r--service/java/com/android/server/wifi/WifiConfigManager.java75
-rw-r--r--service/java/com/android/server/wifi/WifiNetworkFactory.java9
-rw-r--r--tests/wifitests/src/com/android/server/wifi/ConfigurationMapTest.java51
-rw-r--r--tests/wifitests/src/com/android/server/wifi/ScanResultMatchInfoTest.java2
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java137
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiConfigurationTestUtil.java40
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java46
9 files changed, 87 insertions, 327 deletions
diff --git a/service/java/com/android/server/wifi/ConfigurationMap.java b/service/java/com/android/server/wifi/ConfigurationMap.java
index cda9cf8be..02652a81f 100644
--- a/service/java/com/android/server/wifi/ConfigurationMap.java
+++ b/service/java/com/android/server/wifi/ConfigurationMap.java
@@ -128,30 +128,6 @@ public class ConfigurationMap {
ScanResultMatchInfo.fromScanResult(scanResult));
}
- /**
- * Retrieves a |WifiConfiguration| object with PSK key management, that is matching the provided
- * |scanResult| SSID from the internal map.
- * Used for upgrading WPA2-Personal networks to WPA3-Personal, when AP is in transition mode.
- */
- public WifiConfiguration getPskNetworkByScanResultForCurrentUser(ScanResult scanResult) {
- // Check if WPA2-Personal saved network is available
- ScanResultMatchInfo matchInfo = ScanResultMatchInfo.fromScanResult(scanResult);
- matchInfo.networkType = WifiConfiguration.SECURITY_TYPE_PSK;
- return mScanResultMatchInfoMapForCurrentUser.get(matchInfo);
- }
-
- /**
- * Retrieves a |WifiConfiguration| object with no security, that is matching the provided
- * |scanResult| SSID from the internal map.
- * Used for upgrading Open networks to OWE, when AP is in transition mode.
- */
- public WifiConfiguration getOpenNetworkByScanResultForCurrentUser(ScanResult scanResult) {
- // Check if Open saved network is available
- ScanResultMatchInfo matchInfo = ScanResultMatchInfo.fromScanResult(scanResult);
- matchInfo.networkType = WifiConfiguration.SECURITY_TYPE_OPEN;
- return mScanResultMatchInfoMapForCurrentUser.get(matchInfo);
- }
-
public Collection<WifiConfiguration> valuesForAllUsers() {
return mPerID.values();
}
diff --git a/service/java/com/android/server/wifi/ScanResultMatchInfo.java b/service/java/com/android/server/wifi/ScanResultMatchInfo.java
index 23fee8cff..e62368331 100644
--- a/service/java/com/android/server/wifi/ScanResultMatchInfo.java
+++ b/service/java/com/android/server/wifi/ScanResultMatchInfo.java
@@ -15,6 +15,7 @@
*/
package com.android.server.wifi;
+import android.annotation.NonNull;
import android.net.wifi.ScanResult;
import android.net.wifi.WifiConfiguration;
@@ -46,7 +47,7 @@ public class ScanResultMatchInfo {
/**
* Fetch network type from network configuration.
*/
- public static @WifiConfiguration.SecurityType int getNetworkType(WifiConfiguration config) {
+ private static @WifiConfiguration.SecurityType int getNetworkType(WifiConfiguration config) {
if (WifiConfigurationUtil.isConfigForSaeNetwork(config)) {
return WifiConfiguration.SECURITY_TYPE_SAE;
} else if (WifiConfigurationUtil.isConfigForPskNetwork(config)) {
@@ -78,7 +79,7 @@ public class ScanResultMatchInfo {
/**
* Fetch network type from scan result.
*/
- public static @WifiConfiguration.SecurityType int getNetworkType(ScanResult scanResult) {
+ private static @WifiConfiguration.SecurityType int getNetworkType(ScanResult scanResult) {
if (ScanResultUtil.isScanResultForSaeNetwork(scanResult)) {
return WifiConfiguration.SECURITY_TYPE_SAE;
} else if (ScanResultUtil.isScanResultForPskNetwork(scanResult)) {
@@ -126,6 +127,25 @@ public class ScanResultMatchInfo {
/**
* Checks for equality of network type.
*/
+ public boolean networkTypeEquals(@NonNull ScanResultMatchInfo other) {
+ boolean networkTypeEquals;
+ // Detect <SSID, PSK+SAE> scan result and say it is equal to <SSID, PSK> configuration
+ if (other.pskSaeInTransitionMode && networkType == WifiConfiguration.SECURITY_TYPE_PSK
+ || (pskSaeInTransitionMode
+ && other.networkType == WifiConfiguration.SECURITY_TYPE_PSK)) {
+ networkTypeEquals = true;
+ } else if ((networkType == WifiConfiguration.SECURITY_TYPE_OPEN
+ && other.oweInTransitionMode) || (oweInTransitionMode
+ && other.networkType == WifiConfiguration.SECURITY_TYPE_OPEN)) {
+ // Special case we treat Enhanced Open and Open as equals. This is done to support the
+ // case where a saved network is Open but we found an OWE in transition network.
+ networkTypeEquals = true;
+ } else {
+ networkTypeEquals = networkType == other.networkType;
+ }
+ return networkTypeEquals;
+ }
+
@Override
public boolean equals(Object otherObj) {
if (this == otherObj) {
@@ -134,8 +154,10 @@ public class ScanResultMatchInfo {
return false;
}
ScanResultMatchInfo other = (ScanResultMatchInfo) otherObj;
- return Objects.equals(networkSsid, other.networkSsid)
- && networkType == other.networkType;
+ if (!Objects.equals(networkSsid, other.networkSsid)) {
+ return false;
+ }
+ return networkTypeEquals(other);
}
@Override
diff --git a/service/java/com/android/server/wifi/WifiConfigManager.java b/service/java/com/android/server/wifi/WifiConfigManager.java
index 18b5562b3..2883284f4 100644
--- a/service/java/com/android/server/wifi/WifiConfigManager.java
+++ b/service/java/com/android/server/wifi/WifiConfigManager.java
@@ -1227,7 +1227,6 @@ public class WifiConfigManager {
newInternalConfig.creationTime = newInternalConfig.updateTime =
createDebugTimeStampString(mClock.getWallClockMillis());
initRandomizedMacForInternalConfig(newInternalConfig);
- newInternalConfig.clonedNetworkConfigKey = externalConfig.clonedNetworkConfigKey;
return newInternalConfig;
}
@@ -1516,27 +1515,6 @@ public class WifiConfigManager {
Log.e(TAG, "Failed to remove network " + config.getPrintableSsid());
return false;
}
-
- // Remove any cloned networks
- if (config.clonedNetworkConfigKey != null) {
- WifiConfiguration clonedConfig = getConfiguredNetwork(config.clonedNetworkConfigKey);
-
- if (clonedConfig != null) {
- Log.d(TAG, "Removing cloned network " + clonedConfig.getPrintableSsid());
- if (!removeNetworkInternal(clonedConfig, uid)) {
- Log.e(TAG, "Failed to remove network " + clonedConfig.getPrintableSsid());
- return false;
- }
-
- if (clonedConfig.networkId == mLastSelectedNetworkId) {
- clearLastSelectedNetwork();
- }
- } else {
- Log.w(TAG, "Could not find a cloned network with key "
- + config.clonedNetworkConfigKey);
- }
- }
-
if (networkId == mLastSelectedNetworkId) {
clearLastSelectedNetwork();
}
@@ -2442,24 +2420,6 @@ public class WifiConfigManager {
} catch (IllegalArgumentException e) {
Log.e(TAG, "Failed to lookup network from config map", e);
}
- if (config == null) {
- /**
- * Special case for WPA3-Personal and OWE in transition mode.
- * These networks will be treated as WPA3/OWE with a special flag that indicates
- * transition mode enabled. If we have a matching WPA2/Open saved network, create a new
- * upgraded WPA3/OWE network and use it to connect.
- */
- ScanResultMatchInfo matchInfo = ScanResultMatchInfo.fromScanResult(scanResult);
- if (matchInfo.pskSaeInTransitionMode || matchInfo.oweInTransitionMode) {
- if (handleTransitionNetwork(scanResult, matchInfo.pskSaeInTransitionMode)) {
- try {
- config = mConfiguredNetworks.getByScanResultForCurrentUser(scanResult);
- } catch (IllegalArgumentException e) {
- Log.e(TAG, "Failed to lookup network from config map", e);
- }
- }
- }
- }
if (config != null) {
if (mVerboseLoggingEnabled) {
Log.v(TAG, "getSavedNetworkFromScanDetail Found " + config.configKey()
@@ -2469,41 +2429,6 @@ public class WifiConfigManager {
return config;
}
- private boolean handleTransitionNetwork(ScanResult scanResult, boolean isPskSae) {
- WifiConfiguration config;
-
- if (isPskSae) {
- config = mConfiguredNetworks.getPskNetworkByScanResultForCurrentUser(scanResult);
- } else {
- config = mConfiguredNetworks.getOpenNetworkByScanResultForCurrentUser(scanResult);
- }
-
- if (config != null) {
- // Create a new WPA3-Personal or OWE connection
- WifiConfiguration newConfig = new WifiConfiguration(config);
- newConfig.networkId = WifiConfiguration.INVALID_NETWORK_ID;
- newConfig.clonedNetworkConfigKey = config.configKey();
- if (isPskSae) {
- newConfig.setSecurityParams(WifiConfiguration.SECURITY_TYPE_SAE);
- } else {
- newConfig.setSecurityParams(WifiConfiguration.SECURITY_TYPE_OWE);
- }
- NetworkUpdateResult res = addOrUpdateNetwork(newConfig, config.creatorUid,
- config.creatorName);
-
- if (!res.isSuccess()) {
- Log.e(TAG, "Failed to add new configuration for " + newConfig.SSID);
- return false;
- }
- config.clonedNetworkConfigKey = newConfig.configKey();
- addOrUpdateNetwork(config, config.creatorUid);
- enableNetwork(res.netId, false, config.creatorUid, null);
- return true;
- }
-
- return false;
- }
-
/**
* Retrieves a configured network corresponding to the provided scan detail if one exists and
* caches the provided |scanDetail| into the corresponding scan detail cache entry
diff --git a/service/java/com/android/server/wifi/WifiNetworkFactory.java b/service/java/com/android/server/wifi/WifiNetworkFactory.java
index 8bb87c65c..741cda697 100644
--- a/service/java/com/android/server/wifi/WifiNetworkFactory.java
+++ b/service/java/com/android/server/wifi/WifiNetworkFactory.java
@@ -1101,11 +1101,10 @@ public class WifiNetworkFactory extends NetworkFactory {
if (!bssid.matches(matchBaseAddress, matchMask)) {
return false;
}
- if (ScanResultMatchInfo.getNetworkType(wns.wifiConfiguration)
- != ScanResultMatchInfo.getNetworkType(scanResult)) {
- return false;
- }
- return true;
+ ScanResultMatchInfo fromScanResult = ScanResultMatchInfo.fromScanResult(scanResult);
+ ScanResultMatchInfo fromWifiConfiguration =
+ ScanResultMatchInfo.fromWifiConfiguration(wns.wifiConfiguration);
+ return fromScanResult.networkTypeEquals(fromWifiConfiguration);
}
// Loops through the scan results and finds scan results matching the active network
diff --git a/tests/wifitests/src/com/android/server/wifi/ConfigurationMapTest.java b/tests/wifitests/src/com/android/server/wifi/ConfigurationMapTest.java
index 40cc4b391..0b3cc45e8 100644
--- a/tests/wifitests/src/com/android/server/wifi/ConfigurationMapTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/ConfigurationMapTest.java
@@ -281,7 +281,6 @@ public class ConfigurationMapTest extends WifiBaseTest {
verifyScanResultMatchWithNetwork(WifiConfigurationTestUtil.createPskNetwork());
verifyScanResultMatchWithNetwork(WifiConfigurationTestUtil.createWepNetwork());
verifyScanResultMatchWithNetwork(WifiConfigurationTestUtil.createEapNetwork());
- verifyScanResultMatchWithNetwork(WifiConfigurationTestUtil.createSaeNetwork());
}
/**
@@ -334,54 +333,4 @@ public class ConfigurationMapTest extends WifiBaseTest {
mConfigs.clear();
assertNull(mConfigs.getByScanResultForCurrentUser(scanResult));
}
-
- /**
- * Verifies that {@link ConfigurationMap#getPskNetworkByScanResultForCurrentUser(ScanResult)}
- * can positively match a PSK network for transition mode AP.
- */
- @Test
- public void testFindPskNetworkFromSaeScanResult() {
- final String wpa2Wpa3TransitionSsid = "\"WPA3-Transition\"";
- WifiConfiguration saePskConfig =
- WifiConfigurationTestUtil.createSaeNetwork(wpa2Wpa3TransitionSsid);
- WifiConfiguration pskConfig =
- WifiConfigurationTestUtil.createPskNetwork(wpa2Wpa3TransitionSsid);
- mConfigs.put(saePskConfig);
- mConfigs.put(pskConfig);
-
- ScanDetail scanDetail = WifiConfigurationTestUtil
- .createScanDetailForWpa2Wpa3TransitionModeNetwork(saePskConfig,
- "AA:BB:CC:DD:CC:BB", -40, 2402, 0, 1);
- ScanResult scanResult = scanDetail.getScanResult();
-
- WifiConfiguration retrievedConfig =
- mConfigs.getPskNetworkByScanResultForCurrentUser(scanResult);
- assertNotNull(retrievedConfig);
- assertEquals(pskConfig.configKey(), retrievedConfig.configKey());
- }
-
- /**
- * Verifies that {@link ConfigurationMap#getOpenNetworkByScanResultForCurrentUser(ScanResult)}
- * can positively match a PSK network for transition mode AP.
- */
- @Test
- public void testFindOpenNetworkFromOweScanResult() {
- final String oweTransitionSsid = "\"OWE-Transition\"";
- WifiConfiguration oweOpenConfig =
- WifiConfigurationTestUtil.createOweNetwork(oweTransitionSsid);
- WifiConfiguration openConfig =
- WifiConfigurationTestUtil.createOpenNetwork(oweTransitionSsid);
- mConfigs.put(oweOpenConfig);
- mConfigs.put(openConfig);
-
- ScanDetail scanDetail = WifiConfigurationTestUtil
- .createScanDetailForOweTransitionModeNetwork(oweOpenConfig,
- "AA:BB:CC:DD:CC:BB", -40, 2402, 0, 1);
- ScanResult scanResult = scanDetail.getScanResult();
-
- WifiConfiguration retrievedConfig =
- mConfigs.getOpenNetworkByScanResultForCurrentUser(scanResult);
- assertNotNull(retrievedConfig);
- assertEquals(openConfig.configKey(), retrievedConfig.configKey());
- }
}
diff --git a/tests/wifitests/src/com/android/server/wifi/ScanResultMatchInfoTest.java b/tests/wifitests/src/com/android/server/wifi/ScanResultMatchInfoTest.java
index 4192da68c..1cc7fa83f 100644
--- a/tests/wifitests/src/com/android/server/wifi/ScanResultMatchInfoTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/ScanResultMatchInfoTest.java
@@ -92,7 +92,7 @@ public class ScanResultMatchInfoTest extends WifiBaseTest {
@Test
public void testEqualityRulesForTransitionMode() {
WifiConfiguration wifiConfiguration =
- WifiConfigurationTestUtil.createSaeNetwork("\"Transition is Hard\"");
+ WifiConfigurationTestUtil.createPskNetwork("\"Transition is Hard\"");
ScanDetail scanDetail = createScanDetailForWpa2Wpa3TransitionModeNetwork(wifiConfiguration,
"AA:BB:CC:DD:CC:BB");
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
index 203250e9f..61646f076 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
@@ -190,8 +190,6 @@ public class WifiConfigManagerTest extends WifiBaseTest {
return TEST_NO_PERM_NAME;
} else if (uid == Process.WIFI_UID) {
return TEST_WIFI_NAME;
- } else if (uid == Process.SYSTEM_UID) {
- return TEST_WIFI_NAME;
}
fail("Unexpected UID: " + uid);
return "";
@@ -5617,139 +5615,4 @@ public class WifiConfigManagerTest extends WifiBaseTest {
assertNotEquals(WifiConfiguration.INVALID_NETWORK_ID, networkUpdateResult.getNetworkId());
assertFalse(mWifiConfigManager.isInFlakyRandomizationSsidHotlist(networkId));
}
-
- /**
- * Verifies that when scanning a WPA3 in transition mode AP, and there is a matching WPA2 saved
- * network, {@link WifiConfigManager#getConfiguredNetworkForScanDetailAndCache(ScanDetail)}
- * clones a new WPA3 saved network that will be used to connect to it.
- *
- * The test also verifies that the new network is marked as cloned.
- */
- @Test
- public void testCloningPskNetworkForTransitionMode() {
- final String wpa2Wpa3TransitionSsid = "\"WPA3-Transition\"";
- WifiConfiguration saeNetwork = WifiConfigurationTestUtil
- .createSaeNetwork(wpa2Wpa3TransitionSsid);
- WifiConfiguration pskNetwork = WifiConfigurationTestUtil
- .createPskNetwork(wpa2Wpa3TransitionSsid);
-
- // First add the WPA2 saved network.
- verifyAddNetworkToWifiConfigManager(pskNetwork);
-
- // Now create a dummy scan detail for WPA3-Transition.
- ScanDetail scanDetail = WifiConfigurationTestUtil
- .createScanDetailForWpa2Wpa3TransitionModeNetwork(saeNetwork,
- "AA:BB:CC:DD:CC:BB", -40, 2402, 0, 1);
-
-
- WifiConfiguration retrievedNetwork =
- mWifiConfigManager.getConfiguredNetworkForScanDetailAndCache(scanDetail);
- // Retrieve the network with password data for comparison.
- retrievedNetwork =
- mWifiConfigManager.getConfiguredNetworkWithPassword(retrievedNetwork.networkId);
-
- // Verify cloned network matches the expected WPA3 network
- assertEquals(saeNetwork.SSID, retrievedNetwork.SSID);
- assertEquals(saeNetwork.BSSID, retrievedNetwork.BSSID);
- assertEquals(saeNetwork.preSharedKey, retrievedNetwork.preSharedKey);
- assertEquals(saeNetwork.requirePMF, retrievedNetwork.requirePMF);
- assertEquals(saeNetwork.allowedKeyManagement, retrievedNetwork.allowedKeyManagement);
- assertNotNull(retrievedNetwork.clonedNetworkConfigKey);
- assertEquals(retrievedNetwork.clonedNetworkConfigKey, pskNetwork.configKey());
- }
-
- /**
- * Verifies that when scanning a WPA3 in transition mode AP, and there is a matching WPA2 saved
- * network, {@link WifiConfigManager#getConfiguredNetworkForScanDetailAndCache(ScanDetail)}
- * clones a new WPA3 saved network that will be used to connect to it.
- *
- * The test also verifies that the new network is marked as cloned.
- */
- @Test
- public void testCloningOweNetworkForTransitionMode() {
- final String oweTransitionSsid = "\"OWE-Transition\"";
- WifiConfiguration oweNetwork = WifiConfigurationTestUtil
- .createOweNetwork(oweTransitionSsid);
- WifiConfiguration openNetwork = WifiConfigurationTestUtil
- .createOpenNetwork(oweTransitionSsid);
-
- // First add the Open saved network.
- verifyAddNetworkToWifiConfigManager(openNetwork);
-
- // Now create a dummy scan detail for OWE-Transition.
- ScanDetail scanDetail = WifiConfigurationTestUtil
- .createScanDetailForOweTransitionModeNetwork(oweNetwork,
- "AA:BB:CC:DD:CC:BB", -40, 2402, 0, 1);
-
-
- WifiConfiguration retrievedNetwork =
- mWifiConfigManager.getConfiguredNetworkForScanDetailAndCache(scanDetail);
- // Retrieve the network with password data for comparison.
- retrievedNetwork =
- mWifiConfigManager.getConfiguredNetworkWithPassword(retrievedNetwork.networkId);
-
- // Verify cloned network matches the expected OWE network
- assertEquals(oweNetwork.SSID, retrievedNetwork.SSID);
- assertEquals(oweNetwork.BSSID, retrievedNetwork.BSSID);
- assertEquals(oweNetwork.preSharedKey, retrievedNetwork.preSharedKey);
- assertEquals(oweNetwork.requirePMF, retrievedNetwork.requirePMF);
- assertEquals(oweNetwork.allowedKeyManagement, retrievedNetwork.allowedKeyManagement);
- assertNotNull(retrievedNetwork.clonedNetworkConfigKey);
- assertEquals(retrievedNetwork.clonedNetworkConfigKey, openNetwork.configKey());
- }
-
- /**
- * Verifies that when a cloned network is removed, its original pair is removed as well
- * {@link WifiConfigManager#removeNetwork(int)}
- */
- @Test
- public void testRemoveClonedSaeNetwork() {
- final String wpa2Wpa3TransitionSsid = "\"WPA3-Transition\"";
- WifiConfiguration saeNetwork = WifiConfigurationTestUtil
- .createSaeNetwork(wpa2Wpa3TransitionSsid);
- WifiConfiguration pskNetwork = WifiConfigurationTestUtil
- .createPskNetwork(wpa2Wpa3TransitionSsid);
- ArgumentCaptor<WifiConfiguration> wifiConfigCaptor =
- ArgumentCaptor.forClass(WifiConfiguration.class);
-
- // First add the WPA2 saved network.
- NetworkUpdateResult result = verifyAddNetworkToWifiConfigManager(pskNetwork);
- verify(mWcmListener).onNetworkAdded(wifiConfigCaptor.capture());
- assertEquals(pskNetwork.networkId, wifiConfigCaptor.getValue().networkId);
- reset(mWcmListener);
-
- // Now create a dummy scan detail for WPA3-Transition.
- ScanDetail scanDetail = WifiConfigurationTestUtil
- .createScanDetailForWpa2Wpa3TransitionModeNetwork(saeNetwork,
- "AA:BB:CC:DD:CC:BB", -40, 2402, 0, 1);
-
- WifiConfiguration retrievedNetwork =
- mWifiConfigManager.getConfiguredNetworkForScanDetailAndCache(scanDetail);
- // Retrieve the network with password data for comparison.
- retrievedNetwork =
- mWifiConfigManager.getConfiguredNetworkWithPassword(retrievedNetwork.networkId);
-
- // Verify cloned network matches the expected WPA3 network
- assertEquals(saeNetwork.SSID, retrievedNetwork.SSID);
- assertEquals(saeNetwork.BSSID, retrievedNetwork.BSSID);
- assertEquals(saeNetwork.preSharedKey, retrievedNetwork.preSharedKey);
- assertEquals(saeNetwork.requirePMF, retrievedNetwork.requirePMF);
- assertEquals(saeNetwork.allowedKeyManagement, retrievedNetwork.allowedKeyManagement);
- assertNotNull(retrievedNetwork.clonedNetworkConfigKey);
- assertEquals(retrievedNetwork.clonedNetworkConfigKey, pskNetwork.configKey());
-
- // Ensure that configured network list is not empty.
- assertTrue(mWifiConfigManager.getConfiguredNetworks().size() == 2);
- verify(mWcmListener).onNetworkAdded(wifiConfigCaptor.capture());
- assertEquals(retrievedNetwork.networkId, wifiConfigCaptor.getValue().networkId);
- reset(mWcmListener);
-
- assertTrue(mWifiConfigManager.removeNetwork(retrievedNetwork.networkId, TEST_CREATOR_UID,
- TEST_CREATOR_NAME));
-
- // Ensure that configured network list is empty now.
- assertTrue(mWifiConfigManager.getConfiguredNetworks().isEmpty());
- verify(mWcmListener).onNetworkRemoved(wifiConfigCaptor.capture());
- assertEquals(retrievedNetwork.networkId, wifiConfigCaptor.getValue().networkId);
- }
}
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigurationTestUtil.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigurationTestUtil.java
index ba5f0056a..9e2783e1b 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiConfigurationTestUtil.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigurationTestUtil.java
@@ -248,11 +248,8 @@ public class WifiConfigurationTestUtil {
}
public static WifiConfiguration createOweNetwork(String ssid) {
- WifiConfiguration configuration = generateWifiConfig(TEST_NETWORK_ID, TEST_UID, ssid,
- true, true, null, null, SECURITY_OWE);
-
- configuration.requirePMF = true;
- return configuration;
+ return generateWifiConfig(TEST_NETWORK_ID, TEST_UID, ssid, true, true, null,
+ null, SECURITY_OWE);
}
public static WifiConfiguration createOpenNetwork() {
@@ -277,7 +274,14 @@ public class WifiConfigurationTestUtil {
}
public static WifiConfiguration createSaeNetwork() {
- return createSaeNetwork(createNewSSID());
+ WifiConfiguration configuration =
+ generateWifiConfig(TEST_NETWORK_ID, TEST_UID, createNewSSID(), true, true, null,
+ null, SECURITY_SAE);
+
+ // SAE password uses the same member.
+ configuration.preSharedKey = TEST_PSK;
+ configuration.requirePMF = true;
+ return configuration;
}
public static WifiConfiguration createPskNetwork() {
@@ -300,10 +304,6 @@ public class WifiConfigurationTestUtil {
WifiConfiguration configuration =
generateWifiConfig(TEST_NETWORK_ID, TEST_UID, ssid, true, true, null,
null, SECURITY_SAE);
-
- // SAE password uses the same member.
- configuration.preSharedKey = TEST_PSK;
- configuration.requirePMF = true;
return configuration;
}
@@ -514,15 +514,6 @@ public class WifiConfigurationTestUtil {
}
/**
- * Gets scan result capabilities for a WPA2/WPA3-Transition mode network configuration
- */
- private static String
- getScanResultCapsForOweTransitionNetwork(WifiConfiguration configuration) {
- String caps = "[OWE_TRANSITION-CCMP]";
- return caps;
- }
-
- /**
* Creates a scan detail corresponding to the provided network and given BSSID, etc.
*/
public static ScanDetail createScanDetailForNetwork(
@@ -545,17 +536,6 @@ public class WifiConfigurationTestUtil {
return new ScanDetail(ssid, bssid, caps, level, frequency, tsf, seen);
}
- /**
- * Creates a scan detail corresponding to the provided network and given BSSID, but sets
- * the capabilities to OWE-Transition mode network.
- */
- public static ScanDetail createScanDetailForOweTransitionModeNetwork(
- WifiConfiguration configuration, String bssid, int level, int frequency,
- long tsf, long seen) {
- String caps = getScanResultCapsForOweTransitionNetwork(configuration);
- WifiSsid ssid = WifiSsid.createFromAsciiEncoded(configuration.getPrintableSsid());
- return new ScanDetail(ssid, bssid, caps, level, frequency, tsf, seen);
- }
/**
* Asserts that the 2 WifiConfigurations are equal in the elements saved for both backup/restore
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java
index 76412f2ae..ad886e18e 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java
@@ -751,6 +751,49 @@ public class WifiNetworkFactoryTest extends WifiBaseTest {
}
/**
+ * Verify network specifier matching for a specifier containing a specific SSID match using
+ * 4 WPA_PSK + SAE transition scan results, each with unique SSID.
+ */
+ @Test
+ public void testNetworkSpecifierMatchSuccessUsingLiteralSsidMatchForSaeTransitionScanResult()
+ throws Exception {
+ setupScanData(SCAN_RESULT_TYPE_WPA_PSK_SAE_TRANSITION,
+ TEST_SSID_1, TEST_SSID_2, TEST_SSID_3, TEST_SSID_4);
+
+ // Setup network specifier for open networks.
+ PatternMatcher ssidPatternMatch =
+ new PatternMatcher(TEST_SSID_1, PatternMatcher.PATTERN_LITERAL);
+ Pair<MacAddress, MacAddress> bssidPatternMatch =
+ Pair.create(MacAddress.ALL_ZEROS_ADDRESS, MacAddress.ALL_ZEROS_ADDRESS);
+ WifiConfiguration wifiConfiguration = new WifiConfiguration();
+ wifiConfiguration.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
+ WifiNetworkSpecifier specifier = new WifiNetworkSpecifier(
+ ssidPatternMatch, bssidPatternMatch, wifiConfiguration, TEST_UID_1,
+ TEST_PACKAGE_NAME_1);
+
+ mNetworkRequest.networkCapabilities.setNetworkSpecifier(specifier);
+ mWifiNetworkFactory.needNetworkFor(mNetworkRequest, 0);
+
+ validateUiStartParams(true);
+
+ mWifiNetworkFactory.addCallback(mAppBinder, mNetworkRequestMatchCallback,
+ TEST_CALLBACK_IDENTIFIER);
+
+ verifyPeriodicScans(0, PERIODIC_SCAN_INTERVAL_MS);
+
+ ArgumentCaptor<List<ScanResult>> matchedScanResultsCaptor =
+ ArgumentCaptor.forClass(List.class);
+ verify(mNetworkRequestMatchCallback).onMatch(matchedScanResultsCaptor.capture());
+
+ assertNotNull(matchedScanResultsCaptor.getValue());
+ // We only expect 1 network match in this case.
+ validateScanResults(matchedScanResultsCaptor.getValue(), mTestScanDatas[0].getResults()[0]);
+
+ verify(mWifiMetrics).incrementNetworkRequestApiMatchSizeHistogram(
+ matchedScanResultsCaptor.getValue().size());
+ }
+
+ /**
* Verify network specifier matching for a specifier containing a Prefix SSID match using
* 4 open scan results, each with unique SSID.
*/
@@ -2776,6 +2819,7 @@ public class WifiNetworkFactoryTest extends WifiBaseTest {
private static final int SCAN_RESULT_TYPE_OPEN = 0;
private static final int SCAN_RESULT_TYPE_WPA_PSK = 1;
private static final int SCAN_RESULT_TYPE_WPA_EAP = 2;
+ private static final int SCAN_RESULT_TYPE_WPA_PSK_SAE_TRANSITION = 3;
private String getScanResultCapsForType(int scanResultType) {
switch (scanResultType) {
@@ -2788,6 +2832,8 @@ public class WifiNetworkFactoryTest extends WifiBaseTest {
case SCAN_RESULT_TYPE_WPA_EAP:
return WifiConfigurationTestUtil.getScanResultCapsForNetwork(
WifiConfigurationTestUtil.createEapNetwork());
+ case SCAN_RESULT_TYPE_WPA_PSK_SAE_TRANSITION:
+ return WifiConfigurationTestUtil.getScanResultCapsForWpa2Wpa3TransitionNetwork();
}
fail("Invalid scan result type " + scanResultType);
return "";