summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorxshu <xshu@google.com>2019-11-12 13:46:10 -0800
committerxshu <xshu@google.com>2019-12-09 17:05:24 -0800
commit45448ffb610477fc7ac2406c33276f461288bb91 (patch)
tree49be7200b0672843d5c44cc0ee860146f7d667f1 /service
parentb113e7f7d5b3e3d64f6bcb98de29c1a331008118 (diff)
MAC randomization SSID hotlist support
Reads from DeviceConfig and parses a comma separated of SSIDs. Bug: 144172117 Test: atest FrameworksWifiTests Test: Manually tested on device Change-Id: I53b15e884ecba377277eac81f9e3ca86474f5c13 Merged-In: Ie42ce853810aa5dfd4eef89dff281740dafaf3be (cherry picked from a522b345fa15716a21fd9edcf523cf3c1331dd94)
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/DeviceConfigFacade.java21
-rw-r--r--service/java/com/android/server/wifi/WifiConfigManager.java26
-rw-r--r--service/java/com/android/server/wifi/WifiInjector.java2
3 files changed, 47 insertions, 2 deletions
diff --git a/service/java/com/android/server/wifi/DeviceConfigFacade.java b/service/java/com/android/server/wifi/DeviceConfigFacade.java
index a9889f424..25cc2f72d 100644
--- a/service/java/com/android/server/wifi/DeviceConfigFacade.java
+++ b/service/java/com/android/server/wifi/DeviceConfigFacade.java
@@ -17,7 +17,9 @@
package com.android.server.wifi;
import android.provider.DeviceConfig;
+import android.util.ArraySet;
+import java.util.Set;
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
@@ -105,4 +107,23 @@ public class DeviceConfigFacade {
return DeviceConfig.getInt(NAMESPACE, "data_stall_cca_level_thr",
DEFAULT_DATA_STALL_CCA_LEVEL_THR);
}
+
+ /**
+ * Gets the Set of SSIDs in the flaky SSID hotlist.
+ */
+ public Set<String> getRandomizationFlakySsidHotlist() {
+ String ssidHotlist = DeviceConfig.getString(NAMESPACE,
+ "randomization_flaky_ssid_hotlist", "");
+ Set<String> result = new ArraySet<String>();
+ String[] ssidHotlistArray = ssidHotlist.split(",");
+ for (int i = 0; i < ssidHotlistArray.length; i++) {
+ String cur = ssidHotlistArray[i];
+ if (cur.length() == 0) {
+ continue;
+ }
+ // Make sure the SSIDs are quoted. Server side should not quote ssids.
+ result.add("\"" + cur + "\"");
+ }
+ return result;
+ }
}
diff --git a/service/java/com/android/server/wifi/WifiConfigManager.java b/service/java/com/android/server/wifi/WifiConfigManager.java
index a246a86f7..80b583feb 100644
--- a/service/java/com/android/server/wifi/WifiConfigManager.java
+++ b/service/java/com/android/server/wifi/WifiConfigManager.java
@@ -321,6 +321,7 @@ public class WifiConfigManager {
private final int mMaxNumActiveChannelsForPartialScans;
private final FrameworkFacade mFrameworkFacade;
+ private final DeviceConfigFacade mDeviceConfigFacade;
/**
* Verbose logging flag. Toggled by developer options.
@@ -378,6 +379,7 @@ public class WifiConfigManager {
private boolean mPnoFrequencyCullingEnabled = false;
private boolean mPnoRecencySortingEnabled = false;
+ private Set<String> mRandomizationFlakySsidHotlist;
@@ -395,7 +397,8 @@ public class WifiConfigManager {
NetworkListUserStoreData networkListUserStoreData,
DeletedEphemeralSsidsStoreData deletedEphemeralSsidsStoreData,
RandomizedMacStoreData randomizedMacStoreData,
- FrameworkFacade frameworkFacade, Looper looper) {
+ FrameworkFacade frameworkFacade, Looper looper,
+ DeviceConfigFacade deviceConfigFacade) {
mContext = context;
mClock = clock;
mUserManager = userManager;
@@ -447,6 +450,14 @@ public class WifiConfigManager {
updatePnoRecencySortingSetting();
mConnectedMacRandomzationSupported = mContext.getResources()
.getBoolean(R.bool.config_wifi_connected_mac_randomization_supported);
+ mDeviceConfigFacade = deviceConfigFacade;
+ mDeviceConfigFacade.addOnPropertiesChangedListener(
+ command -> new Handler(looper).post(command),
+ properties -> {
+ mRandomizationFlakySsidHotlist =
+ mDeviceConfigFacade.getRandomizationFlakySsidHotlist();
+ });
+ mRandomizationFlakySsidHotlist = mDeviceConfigFacade.getRandomizationFlakySsidHotlist();
try {
mSystemUiUid = mContext.getPackageManager().getPackageUidAsUser(SYSUI_PACKAGE_NAME,
PackageManager.MATCH_SYSTEM_ONLY, UserHandle.USER_SYSTEM);
@@ -1522,6 +1533,19 @@ public class WifiConfigManager {
}
/**
+ * Check whether a network belong to a known list of networks that may not support randomized
+ * MAC.
+ * @param networkId
+ * @return true if the network is in the hotlist and MAC randomization is enabled.
+ */
+ public boolean isInFlakyRandomizationSsidHotlist(int networkId) {
+ WifiConfiguration config = getConfiguredNetwork(networkId);
+ return config != null
+ && config.macRandomizationSetting == WifiConfiguration.RANDOMIZATION_PERSISTENT
+ && mRandomizationFlakySsidHotlist.contains(config.SSID);
+ }
+
+ /**
* Helper method to mark a network enabled for network selection.
*/
private void setNetworkSelectionEnabled(WifiConfiguration config) {
diff --git a/service/java/com/android/server/wifi/WifiInjector.java b/service/java/com/android/server/wifi/WifiInjector.java
index 83ae89cdc..af8c14764 100644
--- a/service/java/com/android/server/wifi/WifiInjector.java
+++ b/service/java/com/android/server/wifi/WifiInjector.java
@@ -253,7 +253,7 @@ public class WifiInjector {
mWifiPermissionsWrapper, this, new NetworkListSharedStoreData(mContext),
new NetworkListUserStoreData(mContext),
new DeletedEphemeralSsidsStoreData(mClock), new RandomizedMacStoreData(),
- mFrameworkFacade, mWifiCoreHandlerThread.getLooper());
+ mFrameworkFacade, mWifiCoreHandlerThread.getLooper(), mDeviceConfigFacade);
mWifiMetrics.setWifiConfigManager(mWifiConfigManager);
mWifiConnectivityHelper = new WifiConnectivityHelper(mWifiNative);
mConnectivityLocalLog = new LocalLog(ActivityManager.isLowRamDeviceStatic() ? 256 : 512);