From be1a7e114f0378bed4194f9aeb02c49cda2be29b Mon Sep 17 00:00:00 2001 From: Jong Wook Kim Date: Wed, 24 Jan 2018 11:04:08 -0800 Subject: WifiConfigManager: Mask Randomized MAC Address Mask out the Randomized MAC Address from WifiConfiguration object when it is being provided through public WifiManager API's. The randomized MAC address should only be used by the WifiStateMachine when connecting to a network to determine which MAC address to use. Bug: 72508588 Test: Unittest Change-Id: I6f2794a25100dc9b4b53f8a61db116ad6272405f --- .../com/android/server/wifi/WifiConfigManager.java | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'service/java/com/android/server/wifi/WifiConfigManager.java') diff --git a/service/java/com/android/server/wifi/WifiConfigManager.java b/service/java/com/android/server/wifi/WifiConfigManager.java index 1cc0ee709..79dcced11 100644 --- a/service/java/com/android/server/wifi/WifiConfigManager.java +++ b/service/java/com/android/server/wifi/WifiConfigManager.java @@ -428,6 +428,16 @@ public class WifiConfigManager { } } + /** + * Helper method to mask randomized MAC address from the provided WifiConfiguration Object. + * This is needed when the network configurations are being requested via the public + * WifiManager API's. This method puts "0:0:0:0:0:0" as the MAC address. + * @param configuration WifiConfiguration to hide the MAC address + */ + private void maskRandomizedMacAddressInWifiConfiguration(WifiConfiguration configuration) { + configuration.setRandomizedMacAddress(MacAddress.ALL_ZEROS_ADDRESS); + } + /** * Helper method to create a copy of the provided internal WifiConfiguration object to be * passed to external modules. @@ -442,6 +452,7 @@ public class WifiConfigManager { if (maskPasswords) { maskPasswordsInWifiConfiguration(network); } + maskRandomizedMacAddressInWifiConfiguration(network); return network; } @@ -552,6 +563,24 @@ public class WifiConfigManager { return createExternalWifiConfiguration(config, false); } + /** + * Retrieves the configured network corresponding to the provided networkId + * without any masking. + * + * WARNING: Don't use this to pass network configurations except in the wifi stack, when + * there is a need for passwords and randomized MAC address. + * + * @param networkId networkId of the requested network. + * @return Copy of WifiConfiguration object if found, null otherwise. + */ + public WifiConfiguration getConfiguredNetworkWithoutMasking(int networkId) { + WifiConfiguration config = getInternalConfiguredNetwork(networkId); + if (config == null) { + return null; + } + return new WifiConfiguration(config); + } + /** * Helper method to retrieve all the internal WifiConfiguration objects corresponding to all * the networks in our database. -- cgit v1.2.3