diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2020-04-30 21:38:10 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2020-04-30 21:38:10 +0000 |
commit | be1d76775b438a5316611a77dbf0989e73037cf9 (patch) | |
tree | 0cd8fd1d1c4b68667e0f2df370df41f15fba6fe3 | |
parent | 329152acb062ea374bb5181d9eb8592cfe80ae42 (diff) | |
parent | ebe8480d17af649474b9dd03ce78e76064be23ea (diff) |
Merge "ClientModeImpl: Only randomize MAC address at start if feature enabled" into rvc-dev
-rw-r--r-- | service/java/com/android/server/wifi/ClientModeImpl.java | 4 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java | 10 |
2 files changed, 13 insertions, 1 deletions
diff --git a/service/java/com/android/server/wifi/ClientModeImpl.java b/service/java/com/android/server/wifi/ClientModeImpl.java index 7314bb853..49edc366a 100644 --- a/service/java/com/android/server/wifi/ClientModeImpl.java +++ b/service/java/com/android/server/wifi/ClientModeImpl.java @@ -3585,7 +3585,9 @@ public class ClientModeImpl extends StateMachine { mLastSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID; mLastSimBasedConnectionCarrierName = null; mLastSignalLevel = -1; - mWifiNative.setMacAddress(mInterfaceName, MacAddressUtils.createRandomUnicastAddress()); + if (isConnectedMacRandomizationEnabled()) { + mWifiNative.setMacAddress(mInterfaceName, MacAddressUtils.createRandomUnicastAddress()); + } mWifiInfo.setMacAddress(mWifiNative.getMacAddress(mInterfaceName)); // TODO: b/79504296 This broadcast has been deprecated and should be removed sendSupplicantConnectionChangedBroadcast(true); diff --git a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java index 8f36770e6..3e904af02 100644 --- a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java +++ b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java @@ -3853,6 +3853,16 @@ public class ClientModeImplTest extends WifiBaseTest { } /** + * Verify the MAC address is being randomized at start to prevent leaking the factory MAC. + */ + @Test + public void testNoRandomizeMacAddressOnStartIfMacRandomizationNotEnabled() throws Exception { + mResources.setBoolean(R.bool.config_wifi_connected_mac_randomization_supported, false); + loadComponentsInStaMode(); + verify(mWifiNative, never()).setMacAddress(anyString(), any()); + } + + /** * Verify bugreport will be taken when get IP_REACHABILITY_LOST */ @Test |