[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:
cosmohsieh
2019-01-18 09:22:21 +08:00
parent ad867a1ba3
commit 29140c3a29
3 changed files with 23 additions and 7 deletions

View File

@@ -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]);
}
}