diff options
-rw-r--r-- | service/java/com/android/server/wifi/WifiConfigManager.java | 18 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java | 21 |
2 files changed, 32 insertions, 7 deletions
diff --git a/service/java/com/android/server/wifi/WifiConfigManager.java b/service/java/com/android/server/wifi/WifiConfigManager.java index fdc950a74..222747ae1 100644 --- a/service/java/com/android/server/wifi/WifiConfigManager.java +++ b/service/java/com/android/server/wifi/WifiConfigManager.java @@ -404,7 +404,7 @@ public class WifiConfigManager { /** * Determine if the framework should perform "aggressive" MAC randomization when connecting - * to the SSID in the input WifiConfiguration. + * to the SSID or FQDN in the input WifiConfiguration. * @param config * @return */ @@ -416,20 +416,24 @@ public class WifiConfigManager { if (config.getIpConfiguration().getIpAssignment() == IpConfiguration.IpAssignment.STATIC) { return false; } - return isSsidOptInForAggressiveRandomization(config.SSID); + if (config.isPasspoint()) { + return isNetworkOptInForAggressiveRandomization(config.FQDN); + } else { + return isNetworkOptInForAggressiveRandomization(config.SSID); + } } - private boolean isSsidOptInForAggressiveRandomization(String ssid) { + private boolean isNetworkOptInForAggressiveRandomization(String ssidOrFqdn) { Set<String> perDeviceSsidBlocklist = new ArraySet<>(mContext.getResources().getStringArray( R.array.config_wifi_aggressive_randomization_ssid_blocklist)); - if (mDeviceConfigFacade.getAggressiveMacRandomizationSsidBlocklist().contains(ssid) - || perDeviceSsidBlocklist.contains(ssid)) { + if (mDeviceConfigFacade.getAggressiveMacRandomizationSsidBlocklist().contains(ssidOrFqdn) + || perDeviceSsidBlocklist.contains(ssidOrFqdn)) { return false; } Set<String> perDeviceSsidAllowlist = new ArraySet<>(mContext.getResources().getStringArray( R.array.config_wifi_aggressive_randomization_ssid_allowlist)); - return mDeviceConfigFacade.getAggressiveMacRandomizationSsidAllowlist().contains(ssid) - || perDeviceSsidAllowlist.contains(ssid); + return mDeviceConfigFacade.getAggressiveMacRandomizationSsidAllowlist().contains(ssidOrFqdn) + || perDeviceSsidAllowlist.contains(ssidOrFqdn); } @VisibleForTesting diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java index 88bf786e6..20aefe958 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java @@ -2132,6 +2132,27 @@ public class WifiConfigManagerTest extends WifiBaseTest { } /** + * Verify that the aggressive randomization whitelist works for passpoints. (by checking FQDN) + */ + @Test + public void testShouldUseAggressiveRandomizationPasspoint() { + WifiConfiguration c = WifiConfigurationTestUtil.createPasspointNetwork(); + // Adds SSID to the whitelist. + Set<String> ssidList = new HashSet<>(); + ssidList.add(c.SSID); + when(mDeviceConfigFacade.getAggressiveMacRandomizationSsidAllowlist()) + .thenReturn(ssidList); + + // Verify that if for passpoint networks we don't check for the SSID to be in the whitelist + assertFalse(mWifiConfigManager.shouldUseAggressiveRandomization(c)); + + // instead we check for the FQDN + ssidList.clear(); + ssidList.add(c.FQDN); + assertTrue(mWifiConfigManager.shouldUseAggressiveRandomization(c)); + } + + /** * Verifies that getRandomizedMacAndUpdateIfNeeded updates the randomized MAC address and * |randomizedMacExpirationTimeMs| correctly. * |