diff options
author | Quang Luong <qal@google.com> | 2020-08-03 20:59:01 -0700 |
---|---|---|
committer | Quang Luong <qal@google.com> | 2020-08-11 17:15:29 +0000 |
commit | 356f4a66d6e2d7cb974ba917083846d702b39f7b (patch) | |
tree | 10e1abf50cb361ac4122580b2bb0b698b1498376 /service | |
parent | 058fc1de39ed8c11473bf9d60aac92dbf21106c0 (diff) |
Populate randomized mac address for passpoint wifi configs
Calculate the randomized mac address for passpoint wifi configs before
returning them in getWifiConfigsForPasspointProfiles. If enhanced mac
randomization is enabled for a config, then populate it with
DEFAULT_MAC_ADDRESS, which displays in Settings as "Not available".
Bug: 160028657
Test: atest PasspointManagerTest, visual verification that randomized
mac address appears in Network Details page for Passpoint networks, and
appears as "Not available" if enhanced mac randomization is enabled.
Change-Id: Icf90940b3c7212f302964db68fc126a012ef36d3
(cherry picked from commit d7ecbaef528e7e3677a400334b9e9a6e5bfb65fd)
Merged-In: Icf90940b3c7212f302964db68fc126a012ef36d3
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/WifiInjector.java | 3 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/hotspot2/PasspointManager.java | 17 |
2 files changed, 18 insertions, 2 deletions
diff --git a/service/java/com/android/server/wifi/WifiInjector.java b/service/java/com/android/server/wifi/WifiInjector.java index b18dd6a29..993debba5 100644 --- a/service/java/com/android/server/wifi/WifiInjector.java +++ b/service/java/com/android/server/wifi/WifiInjector.java @@ -304,7 +304,8 @@ public class WifiInjector { mWifiCarrierInfoManager, mWifiKeyStore, mLruConnectionTracker); mPasspointManager = new PasspointManager(mContext, this, wifiHandler, mWifiNative, mWifiKeyStore, mClock, new PasspointObjectFactory(), - mWifiConfigManager, mWifiConfigStore, mWifiMetrics, mWifiCarrierInfoManager); + mWifiConfigManager, mWifiConfigStore, mWifiMetrics, mWifiCarrierInfoManager, + mMacAddressUtil); PasspointNetworkNominateHelper nominateHelper = new PasspointNetworkNominateHelper(mPasspointManager, mWifiConfigManager, mConnectivityLocalLog); diff --git a/service/java/com/android/server/wifi/hotspot2/PasspointManager.java b/service/java/com/android/server/wifi/hotspot2/PasspointManager.java index 25553b8fe..9cb4254c0 100644 --- a/service/java/com/android/server/wifi/hotspot2/PasspointManager.java +++ b/service/java/com/android/server/wifi/hotspot2/PasspointManager.java @@ -18,12 +18,14 @@ package com.android.server.wifi.hotspot2; import static android.app.AppOpsManager.OPSTR_CHANGE_WIFI_STATE; import static android.net.wifi.WifiConfiguration.MeteredOverride; +import static android.net.wifi.WifiInfo.DEFAULT_MAC_ADDRESS; import static java.security.cert.PKIXReason.NO_TRUST_ANCHOR; import android.annotation.NonNull; import android.app.AppOpsManager; import android.content.Context; +import android.net.MacAddress; import android.net.wifi.ScanResult; import android.net.wifi.WifiConfiguration; import android.net.wifi.WifiEnterpriseConfig; @@ -40,6 +42,7 @@ import android.util.Log; import android.util.Pair; import com.android.server.wifi.Clock; +import com.android.server.wifi.MacAddressUtil; import com.android.server.wifi.NetworkUpdateResult; import com.android.server.wifi.WifiCarrierInfoManager; import com.android.server.wifi.WifiConfigManager; @@ -118,6 +121,7 @@ public class PasspointManager { private final PasspointProvisioner mPasspointProvisioner; private final AppOpsManager mAppOps; private final WifiCarrierInfoManager mWifiCarrierInfoManager; + private final MacAddressUtil mMacAddressUtil; /** * Map of package name of an app to the app ops changed listener for the app. @@ -304,7 +308,8 @@ public class PasspointManager { PasspointObjectFactory objectFactory, WifiConfigManager wifiConfigManager, WifiConfigStore wifiConfigStore, WifiMetrics wifiMetrics, - WifiCarrierInfoManager wifiCarrierInfoManager) { + WifiCarrierInfoManager wifiCarrierInfoManager, + MacAddressUtil macAddressUtil) { mPasspointEventHandler = objectFactory.makePasspointEventHandler(wifiNative, new CallbackHandler(context)); mWifiInjector = wifiInjector; @@ -326,6 +331,7 @@ public class PasspointManager { this, wifiMetrics); mAppOps = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE); sPasspointManager = this; + mMacAddressUtil = macAddressUtil; } /** @@ -1096,6 +1102,15 @@ public class PasspointManager { continue; } WifiConfiguration config = provider.getWifiConfig(); + if (mWifiConfigManager.shouldUseAggressiveRandomization(config)) { + config.setRandomizedMacAddress(MacAddress.fromString(DEFAULT_MAC_ADDRESS)); + } else { + MacAddress result = mMacAddressUtil.calculatePersistentMac(config.getKey(), + mMacAddressUtil.obtainMacRandHashFunction(Process.WIFI_UID)); + if (result != null) { + config.setRandomizedMacAddress(result); + } + } // If the Passpoint configuration is from a suggestion, check if the app shares this // suggestion with the user. if (provider.isFromSuggestion() |