[Mac Randomization] Change order of Privacy setting
For better UX, making the default option 'Use randomized MAC (default)' as the first option item. Bug: 123160090 Test: make RunSettingsRoboTests -j32 ROBOTEST_FILTER=com.android.settings.wifi.details Change-Id: I264756778dd8cafea620a0fcb5f57df91c049259
This commit is contained in:
@@ -1105,8 +1105,8 @@
|
||||
</string-array>
|
||||
|
||||
<string-array name="wifi_privacy_entries">
|
||||
<item>Use device MAC</item>
|
||||
<item>Use randomized MAC (default)</item>
|
||||
<item>Use device MAC</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="wifi_hidden_entries">
|
||||
@@ -1121,8 +1121,8 @@
|
||||
</string-array>
|
||||
|
||||
<string-array name="wifi_privacy_values" translatable="false">
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
<item>0</item>
|
||||
</string-array>
|
||||
|
||||
<!-- Titles for ui dark mode preference. -->
|
||||
|
@@ -61,7 +61,7 @@ public class WifiPrivacyPreferenceController extends BasePreferenceController im
|
||||
final DropDownPreference dropDownPreference = (DropDownPreference) preference;
|
||||
final int randomizationLevel = getRandomizationValue();
|
||||
dropDownPreference.setValue(Integer.toString(randomizationLevel));
|
||||
updateSummary((DropDownPreference) preference, randomizationLevel);
|
||||
updateSummary(dropDownPreference, randomizationLevel);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -85,7 +85,20 @@ public class WifiPrivacyPreferenceController extends BasePreferenceController im
|
||||
return WifiConfiguration.RANDOMIZATION_PERSISTENT;
|
||||
}
|
||||
|
||||
private final int PREF_RANDOMIZATION_PERSISTENT = 0;
|
||||
private final int PREF_RANDOMIZATION_NONE = 1;
|
||||
@VisibleForTesting
|
||||
protected int translateMacRandomizedValueToPrefValue(int macRandomized) {
|
||||
if (macRandomized == WifiConfiguration.RANDOMIZATION_PERSISTENT) {
|
||||
return PREF_RANDOMIZATION_PERSISTENT;
|
||||
} else {
|
||||
return PREF_RANDOMIZATION_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
private void updateSummary(DropDownPreference preference, int macRandomized) {
|
||||
preference.setSummary(preference.getEntries()[macRandomized]);
|
||||
// Translates value here to set RANDOMIZATION_PERSISTENT as first item in UI for better UX.
|
||||
final int prefMacRandomized = translateMacRandomizedValueToPrefValue(macRandomized);
|
||||
preference.setSummary(preference.getEntries()[prefMacRandomized]);
|
||||
}
|
||||
}
|
||||
|
@@ -70,8 +70,9 @@ public class WifiPrivacyPreferenceControllerTest {
|
||||
|
||||
mPreferenceController.updateState(mDropDownPreference);
|
||||
|
||||
|
||||
assertThat(mDropDownPreference.getEntry()).isEqualTo(perferenceString[PRIVACY_TRUSTED]);
|
||||
int prefValue = mPreferenceController.translateMacRandomizedValueToPrefValue(
|
||||
PRIVACY_TRUSTED);
|
||||
assertThat(mDropDownPreference.getEntry()).isEqualTo(perferenceString[prefValue]);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -80,7 +81,9 @@ public class WifiPrivacyPreferenceControllerTest {
|
||||
|
||||
mPreferenceController.updateState(mDropDownPreference);
|
||||
|
||||
assertThat(mDropDownPreference.getEntry()).isEqualTo(perferenceString[PRIVACY_RANDOMIZED]);
|
||||
int prefValue = mPreferenceController.translateMacRandomizedValueToPrefValue(
|
||||
PRIVACY_RANDOMIZED);
|
||||
assertThat(mDropDownPreference.getEntry()).isEqualTo(perferenceString[prefValue]);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Reference in New Issue
Block a user