[Wi-Fi] Replace AccessPoint with WifiEntry for WifiDialog2
Bug: 146407136 Test: make RunSettingsRoboTests ROBOTEST_FILTER=com.android.settings.wifi make RunSettingsRoboTests ROBOTEST_FILTER=com.android.settings.wifi.detail2 Change-Id: I65899b24c186e1bd1bb0d00db52c67264f30f3cb
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
package com.android.settings.wifi.details2;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.wifi.WifiConfiguration;
|
||||
import android.net.wifi.WifiManager;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
@@ -26,7 +27,7 @@ import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.wifi.WifiDialog;
|
||||
import com.android.settings.wifi.WifiDialog2;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
import com.android.wifitrackerlib.WifiEntry;
|
||||
|
||||
@@ -35,7 +36,7 @@ import com.android.wifitrackerlib.WifiEntry;
|
||||
* or not
|
||||
*/
|
||||
public class WifiPrivacyPreferenceController2 extends BasePreferenceController implements
|
||||
Preference.OnPreferenceChangeListener, WifiDialog.WifiDialogListener {
|
||||
Preference.OnPreferenceChangeListener, WifiDialog2.WifiDialog2Listener {
|
||||
|
||||
private static final String KEY_WIFI_PRIVACY = "privacy";
|
||||
private WifiManager mWifiManager;
|
||||
@@ -134,18 +135,29 @@ public class WifiPrivacyPreferenceController2 extends BasePreferenceController i
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSubmit(WifiDialog dialog) {
|
||||
// TODO(b/143326832): Create WifiDialog2 and let it work for WifiEntry.
|
||||
//if (dialog.getController() != null) {
|
||||
// final WifiConfiguration newConfig = dialog.getController().getConfig();
|
||||
// if (newConfig == null || mWifiConfiguration == null) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// if (newConfig.macRandomizationSetting != mWifiConfiguration.macRandomizationSetting) {
|
||||
// mWifiConfiguration = newConfig;
|
||||
// onPreferenceChange(mPreference, String.valueOf(newConfig.macRandomizationSetting));
|
||||
// }
|
||||
//}
|
||||
public void onSubmit(WifiDialog2 dialog) {
|
||||
if (dialog.getController() != null) {
|
||||
final WifiConfiguration newConfig = dialog.getController().getConfig();
|
||||
if (newConfig == null || !mWifiEntry.isSaved()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (newConfig.macRandomizationSetting
|
||||
!= mWifiEntry.getWifiConfiguration().macRandomizationSetting) {
|
||||
mWifiEntry.setPrivacy(getWifiEntryPrivacy(newConfig));
|
||||
onPreferenceChange(mPreference, String.valueOf(newConfig.macRandomizationSetting));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int getWifiEntryPrivacy(WifiConfiguration wifiConfiguration) {
|
||||
switch (wifiConfiguration.macRandomizationSetting) {
|
||||
case WifiConfiguration.RANDOMIZATION_NONE:
|
||||
return WifiEntry.PRIVACY_DEVICE_MAC;
|
||||
case WifiConfiguration.RANDOMIZATION_PERSISTENT:
|
||||
return WifiEntry.PRIVACY_RANDOMIZED_MAC;
|
||||
default:
|
||||
return WifiEntry.PRIVACY_UNKNOWN;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user