summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Plass <mplass@google.com>2020-05-11 15:59:06 -0700
committerMichael Plass <mplass@google.com>2020-05-11 15:59:06 -0700
commitb491ffe759fd5500b7d24a253d7dbf9e41a6e871 (patch)
tree1bea9f7e7722efe7fbbca869ca85596948ca47f0
parenta86c9944ed5ee4a4c3637cf7aab229d6230aac77 (diff)
Avoid changing wifi mac address when device does not support randomization
Devices without a vendor hal do not provide a way for the wifi framework to get the factory mac address, so switching from a random mac to the configured mac requires a reboot. So if mac randomization has not been enabled in the device config, don't attempt to change the mac. Bug: 146507767 Test: atest ClientModeImplTest Change-Id: I53212dc05813001d0ccabeeb4cd491dec06929a4
-rw-r--r--service/java/com/android/server/wifi/ClientModeImpl.java12
-rw-r--r--tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java4
2 files changed, 9 insertions, 7 deletions
diff --git a/service/java/com/android/server/wifi/ClientModeImpl.java b/service/java/com/android/server/wifi/ClientModeImpl.java
index b1a7d3e8b..879b98d13 100644
--- a/service/java/com/android/server/wifi/ClientModeImpl.java
+++ b/service/java/com/android/server/wifi/ClientModeImpl.java
@@ -6375,12 +6375,12 @@ public class ClientModeImpl extends StateMachine {
config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_SAE);
}
- if (config.macRandomizationSetting
- == WifiConfiguration.RANDOMIZATION_PERSISTENT
- && isConnectedMacRandomizationEnabled()) {
- configureRandomizedMacAddress(config);
- } else {
- setCurrentMacToFactoryMac(config);
+ if (isConnectedMacRandomizationEnabled()) {
+ if (config.macRandomizationSetting == WifiConfiguration.RANDOMIZATION_PERSISTENT) {
+ configureRandomizedMacAddress(config);
+ } else {
+ setCurrentMacToFactoryMac(config);
+ }
}
if (config.enterpriseConfig != null
diff --git a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
index 0371a51f6..727922e83 100644
--- a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
@@ -2648,7 +2648,7 @@ public class ClientModeImplTest extends WifiBaseTest {
* 3. macRandomizationSetting of the WifiConfiguration is RANDOMIZATION_PERSISTENT and
* 4. randomized MAC for the network to connect to is different from the current MAC.
*
- * The factory MAC address is used for the connection.
+ * The factory MAC address is used for the connection, and no attempt is made to change it.
*/
@Test
public void testConnectedMacRandomizationNotSupported() throws Exception {
@@ -2660,6 +2660,8 @@ public class ClientModeImplTest extends WifiBaseTest {
connect();
assertEquals(TEST_GLOBAL_MAC_ADDRESS.toString(), mCmi.getWifiInfo().getMacAddress());
+ verify(mWifiNative, never()).setMacAddress(any(), any());
+ verify(mWifiNative, never()).getFactoryMacAddress(any());
}
/**