summaryrefslogtreecommitdiffstats
path: root/service/java/com/android/server/wifi/WifiConfigManager.java
diff options
context:
space:
mode:
authorJong Wook Kim <jongwook@google.com>2018-01-24 11:04:08 -0800
committerJong Wook Kim <jongwook@google.com>2018-03-09 03:03:53 -0800
commitbe1a7e114f0378bed4194f9aeb02c49cda2be29b (patch)
treeda53ea8a597c4df36ed3ccb3d8077c51f72b07b0 /service/java/com/android/server/wifi/WifiConfigManager.java
parent42f26dd680949e1d418d79f9cb0dc234ffd0d9ea (diff)
downloadandroid_frameworks_opt_net_wifi-be1a7e114f0378bed4194f9aeb02c49cda2be29b.tar.gz
android_frameworks_opt_net_wifi-be1a7e114f0378bed4194f9aeb02c49cda2be29b.tar.bz2
android_frameworks_opt_net_wifi-be1a7e114f0378bed4194f9aeb02c49cda2be29b.zip
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
Diffstat (limited to 'service/java/com/android/server/wifi/WifiConfigManager.java')
-rw-r--r--service/java/com/android/server/wifi/WifiConfigManager.java29
1 files changed, 29 insertions, 0 deletions
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
@@ -429,6 +429,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;
}
@@ -553,6 +564,24 @@ public class WifiConfigManager {
}
/**
+ * 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.
*/