Force MAC randomization to enabled on ACTION_WIFI_ADD_NETWORKS

The ACTION_WIFI_ADD_NETWORKS allows an app to request the user to
confirm addition of WiFi networks. The intent attaches
WifiNetworkSuggestions (used to specify the networks). However, the
calling app may configure MAC randomization to be disabled - using
reflection.

Fix to always override the MAC randomization setting to enabled. This
will override any user configuration to disable randomization - however,
considering this is (now) a new configuration it should safely start
from the default Setting.

Verified using using a test app to force non-randomized (using
reflection) value and confirm that without change randomization is
disabled and that with change it is reset correctly.

Bug: 236825742
Test: manual - use a test app
Change-Id: I3fba958c461d88005fdb5d2c3d1f2fd4ce725b8c
This commit is contained in:
Etan Cohen
2023-03-19 16:20:48 +00:00
parent 0230bb216a
commit d3f7fa6aef

View File

@@ -655,6 +655,10 @@ public class AddAppNetworksFragment extends InstrumentedFragment implements
try {
mWifiManager.addOrUpdatePasspointConfiguration(passpointConfig);
mAnyNetworkSavedSuccess = true;
// (force) enable MAC randomization on new credentials
mWifiManager.setMacRandomizationSettingPasspointEnabled(
passpointConfig.getHomeSp().getFqdn(), true);
} catch (IllegalArgumentException e) {
mResultCodeArrayList.set(mUiToRequestedList.get(index).mIndex,
RESULT_NETWORK_ADD_ERROR);
@@ -669,6 +673,10 @@ public class AddAppNetworksFragment extends InstrumentedFragment implements
final WifiConfiguration wifiConfiguration =
mUiToRequestedList.get(index).mWifiNetworkSuggestion.getWifiConfiguration();
wifiConfiguration.SSID = addQuotationIfNeeded(wifiConfiguration.SSID);
// (force) enable MAC randomization on new credentials
wifiConfiguration.setMacRandomizationSetting(
WifiConfiguration.RANDOMIZATION_PERSISTENT);
mWifiManager.save(wifiConfiguration, mSaveListener);
}
}