[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>
|
||||||
|
|
||||||
<string-array name="wifi_privacy_entries">
|
<string-array name="wifi_privacy_entries">
|
||||||
<item>Use device MAC</item>
|
|
||||||
<item>Use randomized MAC (default)</item>
|
<item>Use randomized MAC (default)</item>
|
||||||
|
<item>Use device MAC</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<string-array name="wifi_hidden_entries">
|
<string-array name="wifi_hidden_entries">
|
||||||
@@ -1121,8 +1121,8 @@
|
|||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<string-array name="wifi_privacy_values" translatable="false">
|
<string-array name="wifi_privacy_values" translatable="false">
|
||||||
<item>0</item>
|
|
||||||
<item>1</item>
|
<item>1</item>
|
||||||
|
<item>0</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<!-- Titles for ui dark mode preference. -->
|
<!-- Titles for ui dark mode preference. -->
|
||||||
|
@@ -61,7 +61,7 @@ public class WifiPrivacyPreferenceController extends BasePreferenceController im
|
|||||||
final DropDownPreference dropDownPreference = (DropDownPreference) preference;
|
final DropDownPreference dropDownPreference = (DropDownPreference) preference;
|
||||||
final int randomizationLevel = getRandomizationValue();
|
final int randomizationLevel = getRandomizationValue();
|
||||||
dropDownPreference.setValue(Integer.toString(randomizationLevel));
|
dropDownPreference.setValue(Integer.toString(randomizationLevel));
|
||||||
updateSummary((DropDownPreference) preference, randomizationLevel);
|
updateSummary(dropDownPreference, randomizationLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -85,7 +85,20 @@ public class WifiPrivacyPreferenceController extends BasePreferenceController im
|
|||||||
return WifiConfiguration.RANDOMIZATION_PERSISTENT;
|
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) {
|
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);
|
mPreferenceController.updateState(mDropDownPreference);
|
||||||
|
|
||||||
|
int prefValue = mPreferenceController.translateMacRandomizedValueToPrefValue(
|
||||||
assertThat(mDropDownPreference.getEntry()).isEqualTo(perferenceString[PRIVACY_TRUSTED]);
|
PRIVACY_TRUSTED);
|
||||||
|
assertThat(mDropDownPreference.getEntry()).isEqualTo(perferenceString[prefValue]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -80,7 +81,9 @@ public class WifiPrivacyPreferenceControllerTest {
|
|||||||
|
|
||||||
mPreferenceController.updateState(mDropDownPreference);
|
mPreferenceController.updateState(mDropDownPreference);
|
||||||
|
|
||||||
assertThat(mDropDownPreference.getEntry()).isEqualTo(perferenceString[PRIVACY_RANDOMIZED]);
|
int prefValue = mPreferenceController.translateMacRandomizedValueToPrefValue(
|
||||||
|
PRIVACY_RANDOMIZED);
|
||||||
|
assertThat(mDropDownPreference.getEntry()).isEqualTo(perferenceString[prefValue]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Reference in New Issue
Block a user