Modify the privacy controller to be selectable in the next updateState()

Listen WifiEntry#onUpdated() to update preference states will be modify
in next CLs.

Bug: 170148009
Test: make RunSettingsRoboTests ROBOTEST_FILTER=WifiPrivacyPreferenceController2Test
Change-Id: I5acf096970431a0b093dd7e0968f30c1959e3b7f
This commit is contained in:
Weng Su
2020-10-18 16:21:20 +08:00
parent 031b364e40
commit f71149911b
4 changed files with 86 additions and 5 deletions

View File

@@ -69,12 +69,12 @@ public class WifiPrivacyPreferenceController2 extends BasePreferenceController i
public void updateState(Preference preference) {
final DropDownPreference dropDownPreference = (DropDownPreference) preference;
final int randomizationLevel = getRandomizationValue();
final boolean isSelectable = mWifiEntry.canSetPrivacy();
preference.setSelectable(isSelectable);
dropDownPreference.setValue(Integer.toString(randomizationLevel));
updateSummary(dropDownPreference, randomizationLevel);
// Makes preference not selectable, when this is a ephemeral network.
if (!mWifiEntry.canSetPrivacy()) {
preference.setSelectable(false);
if (isSelectable) {
updateSummary(dropDownPreference, randomizationLevel);
} else {
dropDownPreference.setSummary(R.string.wifi_privacy_settings_ephemeral_summary);
}
}