Merge "[Mac Randomization] Fix MAC randomization option does not work when ephemeral newtork"
This commit is contained in:
committed by
Android (Google) Code Review
commit
70e97d29ef
@@ -2102,6 +2102,8 @@
|
|||||||
<string name="wifi_ip_settings">IP settings</string>
|
<string name="wifi_ip_settings">IP settings</string>
|
||||||
<!-- Label for the spinner to show Wifi MAC randomization [CHAR LIMIT=25] -->
|
<!-- Label for the spinner to show Wifi MAC randomization [CHAR LIMIT=25] -->
|
||||||
<string name="wifi_privacy_settings">Privacy</string>
|
<string name="wifi_privacy_settings">Privacy</string>
|
||||||
|
<!-- Summary for Wifi MAC randomization option when it is ephemeral network [CHAR LIMIT=25] -->
|
||||||
|
<string name="wifi_privacy_settings_ephemeral_summary">Randomized MAC</string>
|
||||||
<!-- Title for the fragment to add a device into the wifi network [CHAR LIMIT=50] -->
|
<!-- Title for the fragment to add a device into the wifi network [CHAR LIMIT=50] -->
|
||||||
<string name="wifi_dpp_add_device_to_network">Add a device</string>
|
<string name="wifi_dpp_add_device_to_network">Add a device</string>
|
||||||
<!-- Hint for the user to center another device's QR code in the below camera window [CHAR LIMIT=120] -->
|
<!-- Hint for the user to center another device's QR code in the below camera window [CHAR LIMIT=120] -->
|
||||||
|
@@ -141,6 +141,7 @@ public class WifiNetworkDetailsFragment extends DashboardFragment {
|
|||||||
WifiPrivacyPreferenceController preferenceController = new WifiPrivacyPreferenceController(
|
WifiPrivacyPreferenceController preferenceController = new WifiPrivacyPreferenceController(
|
||||||
context);
|
context);
|
||||||
preferenceController.setWifiConfiguration(mAccessPoint.getConfig());
|
preferenceController.setWifiConfiguration(mAccessPoint.getConfig());
|
||||||
|
preferenceController.setIsEphemeral(mAccessPoint.isEphemeral());
|
||||||
controllers.add(preferenceController);
|
controllers.add(preferenceController);
|
||||||
|
|
||||||
return controllers;
|
return controllers;
|
||||||
|
@@ -25,6 +25,7 @@ import androidx.annotation.VisibleForTesting;
|
|||||||
import androidx.preference.DropDownPreference;
|
import androidx.preference.DropDownPreference;
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
import com.android.settings.core.BasePreferenceController;
|
import com.android.settings.core.BasePreferenceController;
|
||||||
import com.android.settings.core.FeatureFlags;
|
import com.android.settings.core.FeatureFlags;
|
||||||
import com.android.settingslib.core.AbstractPreferenceController;
|
import com.android.settingslib.core.AbstractPreferenceController;
|
||||||
@@ -39,6 +40,7 @@ public class WifiPrivacyPreferenceController extends BasePreferenceController im
|
|||||||
private static final String KEY_WIFI_PRIVACY = "privacy";
|
private static final String KEY_WIFI_PRIVACY = "privacy";
|
||||||
private WifiConfiguration mWifiConfiguration;
|
private WifiConfiguration mWifiConfiguration;
|
||||||
private WifiManager mWifiManager;
|
private WifiManager mWifiManager;
|
||||||
|
private boolean mIsEphemeral = false;
|
||||||
|
|
||||||
public WifiPrivacyPreferenceController(Context context) {
|
public WifiPrivacyPreferenceController(Context context) {
|
||||||
super(context, KEY_WIFI_PRIVACY);
|
super(context, KEY_WIFI_PRIVACY);
|
||||||
@@ -50,6 +52,10 @@ public class WifiPrivacyPreferenceController extends BasePreferenceController im
|
|||||||
mWifiConfiguration = wifiConfiguration;
|
mWifiConfiguration = wifiConfiguration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setIsEphemeral(boolean isEphemeral) {
|
||||||
|
mIsEphemeral = isEphemeral;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAvailabilityStatus() {
|
public int getAvailabilityStatus() {
|
||||||
return FeatureFlagUtils.isEnabled(mContext, FeatureFlags.WIFI_MAC_RANDOMIZATION)
|
return FeatureFlagUtils.isEnabled(mContext, FeatureFlags.WIFI_MAC_RANDOMIZATION)
|
||||||
@@ -62,6 +68,12 @@ public class WifiPrivacyPreferenceController extends BasePreferenceController im
|
|||||||
final int randomizationLevel = getRandomizationValue();
|
final int randomizationLevel = getRandomizationValue();
|
||||||
dropDownPreference.setValue(Integer.toString(randomizationLevel));
|
dropDownPreference.setValue(Integer.toString(randomizationLevel));
|
||||||
updateSummary(dropDownPreference, randomizationLevel);
|
updateSummary(dropDownPreference, randomizationLevel);
|
||||||
|
|
||||||
|
// Makes preference not selectable, when this is a ephemeral network.
|
||||||
|
if (mIsEphemeral) {
|
||||||
|
preference.setSelectable(false);
|
||||||
|
dropDownPreference.setSummary(R.string.wifi_privacy_settings_ephemeral_summary);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -93,4 +93,20 @@ public class WifiPrivacyPreferenceControllerTest {
|
|||||||
mPreferenceController.getRandomizationValue();
|
mPreferenceController.getRandomizationValue();
|
||||||
mPreferenceController.onPreferenceChange(mDropDownPreference, "1");
|
mPreferenceController.onPreferenceChange(mDropDownPreference, "1");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdateState_isNotEphemeralNetwork_shouldBeSelectable() {
|
||||||
|
mPreferenceController.setIsEphemeral(false);
|
||||||
|
mPreferenceController.updateState(mDropDownPreference);
|
||||||
|
|
||||||
|
assertThat(mDropDownPreference.isSelectable()).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdateState_isEphemeralNetwork_shouldNotSelectable() {
|
||||||
|
mPreferenceController.setIsEphemeral(true);
|
||||||
|
mPreferenceController.updateState(mDropDownPreference);
|
||||||
|
|
||||||
|
assertThat(mDropDownPreference.isSelectable()).isFalse();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user