From d08f40266aa4177211aeb1f315e96d7c591feef4 Mon Sep 17 00:00:00 2001 From: xshu Date: Thu, 12 Mar 2020 16:52:37 -0700 Subject: 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 --- .../com/android/server/wifi/WifiConfigManager.java | 18 +++++++++++------- .../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 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 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 @@ -2131,6 +2131,27 @@ public class WifiConfigManagerTest extends WifiBaseTest { assertEquals(macAddress, configs.get(0).getRandomizedMacAddress().toString()); } + /** + * 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 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. -- cgit v1.2.3