summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOscar Shu <xshu@google.com>2019-11-27 18:32:05 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2019-11-27 18:32:05 +0000
commit0b1849318b7a5c94c91d9807d8145c72da381ef9 (patch)
tree5592d8dc292bff467b7b7c96105216bbcd27cb7d
parentba1dd3b2309875956359c2b83a61d81d0c9d4b38 (diff)
parent0c6db026e4463abb4030cdf4f7813152f2dd1996 (diff)
Merge "Fix boot regression from KeyStore being slow"
-rw-r--r--service/java/com/android/server/wifi/WifiConfigManager.java13
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java10
2 files changed, 17 insertions, 6 deletions
diff --git a/service/java/com/android/server/wifi/WifiConfigManager.java b/service/java/com/android/server/wifi/WifiConfigManager.java
index d2faa84b6..b33a3572c 100644
--- a/service/java/com/android/server/wifi/WifiConfigManager.java
+++ b/service/java/com/android/server/wifi/WifiConfigManager.java
@@ -243,7 +243,7 @@ public class WifiConfigManager {
private final WifiPermissionsWrapper mWifiPermissionsWrapper;
private final WifiInjector mWifiInjector;
private final MacAddressUtil mMacAddressUtil;
- private final Mac mMac;
+ private Mac mMac;
private final TelephonyUtil mTelephonyUtil;
/**
@@ -420,11 +420,6 @@ public class WifiConfigManager {
Log.e(TAG, "Unable to resolve SystemUI's UID.");
}
mMacAddressUtil = mWifiInjector.getMacAddressUtil();
- mMac = mMacAddressUtil.obtainMacRandHashFunction(Process.WIFI_UID);
- if (mMac == null) {
- Log.wtf(TAG, "Failed to obtain secret for MAC randomization."
- + " All randomized MAC addresses are lost!");
- }
}
/**
@@ -3277,6 +3272,12 @@ public class WifiConfigManager {
* @return true on success or not needed (fresh install), false otherwise.
*/
public boolean loadFromStore() {
+ // Get the hashfunction that is used to generate randomized MACs from the KeyStore
+ mMac = mMacAddressUtil.obtainMacRandHashFunction(Process.WIFI_UID);
+ if (mMac == null) {
+ Log.wtf(TAG, "Failed to obtain secret for MAC randomization."
+ + " All randomized MAC addresses are lost!");
+ }
// If the user unlock comes in before we load from store, which means the user store have
// not been setup yet for the current user. Setup the user store before the read so that
// configurations for the current user will also being loaded.
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
index 147b2a0d8..e47368797 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
@@ -300,6 +300,16 @@ public class WifiConfigManagerTest extends WifiBaseTest {
}
/**
+ * Verifies that the Mac randomization secret hashfunction is obtained after |loadFromStore|.
+ */
+ @Test
+ public void testMacHashIsObtainedAfterLoadFromStore() {
+ verify(mMacAddressUtil, never()).obtainMacRandHashFunction(anyInt());
+ assertTrue(mWifiConfigManager.loadFromStore());
+ verify(mMacAddressUtil).obtainMacRandHashFunction(anyInt());
+ }
+
+ /**
* Verifies the addition of a single network using
* {@link WifiConfigManager#addOrUpdateNetwork(WifiConfiguration, int)}
*/