summaryrefslogtreecommitdiffstats
path: root/tests/wifitests/src/com/android/server
diff options
context:
space:
mode:
authorxshu <xshu@google.com>2019-07-10 18:03:32 -0700
committerxshu <xshu@google.com>2019-07-10 18:03:32 -0700
commit608b03f29d70b6d9055f349dcf194fae0248c9bb (patch)
tree4ac64c71bb4292aa6a7bd8bb64c6571f793a67da /tests/wifitests/src/com/android/server
parentc23fd06553163353e75ed9b45d2556b5969ed6f0 (diff)
downloadandroid_frameworks_opt_net_wifi-608b03f29d70b6d9055f349dcf194fae0248c9bb.tar.gz
android_frameworks_opt_net_wifi-608b03f29d70b6d9055f349dcf194fae0248c9bb.tar.bz2
android_frameworks_opt_net_wifi-608b03f29d70b6d9055f349dcf194fae0248c9bb.zip
Mask out macRandomizationSetting when feature is unsupported
All wifi networks will use factory MAC to connect when the config_wifi_connected_mac_randomization_supported feature flag is set to false. Making macRandomizationSetting always return "false" in the above case. Bug: 137230966 Test: unit tests Test: manual test on a unsupported device - verifying network details page is always showing the factory MAC address. Change-Id: I3ed8599a7123a084bdf20d8f30ba6dcbcea83356
Diffstat (limited to 'tests/wifitests/src/com/android/server')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
index 3b86be887..686b2098d 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
@@ -164,6 +164,7 @@ public class WifiConfigManagerTest {
mResources.setInteger(
R.integer.config_wifi_framework_associated_partial_scan_max_num_active_channels,
TEST_MAX_NUM_ACTIVE_CHANNELS_FOR_PARTIAL_SCAN);
+ mResources.setBoolean(R.bool.config_wifi_connected_mac_randomization_supported, true);
when(mContext.getResources()).thenReturn(mResources);
// Setup UserManager profiles for the default user.
@@ -1940,6 +1941,44 @@ public class WifiConfigManagerTest {
}
/**
+ * Verifies that macRandomizationSetting is not masked out when MAC randomization is supported.
+ */
+ @Test
+ public void testGetConfiguredNetworksNotMaskMacRandomizationSetting() {
+ WifiConfiguration config = WifiConfigurationTestUtil.createOpenNetwork();
+ NetworkUpdateResult result = verifyAddNetworkToWifiConfigManager(config);
+
+ MacAddress testMac = MacAddress.createRandomUnicastAddress();
+ mWifiConfigManager.setNetworkRandomizedMacAddress(result.getNetworkId(), testMac);
+
+ // Verify macRandomizationSetting is not masked out when feature is supported.
+ List<WifiConfiguration> configs = mWifiConfigManager.getSavedNetworks(Process.WIFI_UID);
+ assertEquals(1, configs.size());
+ assertEquals(WifiConfiguration.RANDOMIZATION_PERSISTENT,
+ configs.get(0).macRandomizationSetting);
+ }
+
+ /**
+ * Verifies that macRandomizationSetting is masked out to WifiConfiguration.RANDOMIZATION_NONE
+ * when MAC randomization is not supported on the device.
+ */
+ @Test
+ public void testGetConfiguredNetworksMasksMacRandomizationSetting() {
+ mResources.setBoolean(R.bool.config_wifi_connected_mac_randomization_supported, false);
+ createWifiConfigManager();
+ WifiConfiguration config = WifiConfigurationTestUtil.createOpenNetwork();
+ NetworkUpdateResult result = verifyAddNetworkToWifiConfigManager(config);
+
+ MacAddress testMac = MacAddress.createRandomUnicastAddress();
+ mWifiConfigManager.setNetworkRandomizedMacAddress(result.getNetworkId(), testMac);
+
+ // Verify macRandomizationSetting is masked out when feature is unsupported.
+ List<WifiConfiguration> configs = mWifiConfigManager.getSavedNetworks(Process.WIFI_UID);
+ assertEquals(1, configs.size());
+ assertEquals(WifiConfiguration.RANDOMIZATION_NONE, configs.get(0).macRandomizationSetting);
+ }
+
+ /**
* Verifies that passwords are masked out when we return external configs except when
* explicitly asked for them.
*/