diff options
author | xshu <xshu@google.com> | 2020-03-12 16:52:37 -0700 |
---|---|---|
committer | xshu <xshu@google.com> | 2020-03-12 17:06:17 -0700 |
commit | d08f40266aa4177211aeb1f315e96d7c591feef4 (patch) | |
tree | 5f17f491e5c3d8d1ddf1e91b6c7af55747be7eca | |
parent | 544e531dc8534bbf197c2abe58748c897a0f5a75 (diff) |
Support enhanced MAC randomization Passpoint
Check the whitelist for FQDN if the network is passpoint.
Bug: 151373955
Test: atest com.android.server.wifi
Change-Id: I75cacbfd7ac9d838a112b20740d81731b6d4634e
-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. * |