[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:
@@ -22,7 +22,6 @@ import android.net.IpConfiguration;
|
||||
import android.net.IpConfiguration.IpAssignment;
|
||||
import android.net.IpConfiguration.ProxySettings;
|
||||
import android.net.LinkAddress;
|
||||
import android.net.NetworkInfo.DetailedState;
|
||||
import android.net.NetworkUtils;
|
||||
import android.net.ProxyInfo;
|
||||
import android.net.StaticIpConfiguration;
|
||||
@@ -33,7 +32,6 @@ import android.net.wifi.WifiConfiguration.KeyMgmt;
|
||||
import android.net.wifi.WifiEnterpriseConfig;
|
||||
import android.net.wifi.WifiEnterpriseConfig.Eap;
|
||||
import android.net.wifi.WifiEnterpriseConfig.Phase2;
|
||||
import android.net.wifi.WifiInfo;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.IBinder;
|
||||
import android.os.UserManager;
|
||||
@@ -76,6 +74,8 @@ import com.android.settings.wifi.dpp.WifiDppUtils;
|
||||
import com.android.settingslib.Utils;
|
||||
import com.android.settingslib.utils.ThreadUtils;
|
||||
import com.android.settingslib.wifi.AccessPoint;
|
||||
import com.android.wifitrackerlib.WifiEntry;
|
||||
import com.android.wifitrackerlib.WifiEntry.ConnectedInfo;
|
||||
|
||||
import java.net.Inet4Address;
|
||||
import java.net.InetAddress;
|
||||
@@ -96,7 +96,7 @@ public class WifiConfigController2 implements TextWatcher,
|
||||
|
||||
private final WifiConfigUiBase2 mConfigUi;
|
||||
private final View mView;
|
||||
private final AccessPoint mAccessPoint;
|
||||
private final WifiEntry mWifiEntry;
|
||||
|
||||
/* This value comes from "wifi_ip_settings" resource array */
|
||||
private static final int DHCP = 0;
|
||||
@@ -138,9 +138,9 @@ public class WifiConfigController2 implements TextWatcher,
|
||||
/* Phase2 methods supported by TTLS are limited */
|
||||
private ArrayAdapter<CharSequence> mPhase2TtlsAdapter;
|
||||
|
||||
// e.g. AccessPoint.SECURITY_NONE
|
||||
// e.g. WifiEntry.SECURITY_NONE
|
||||
@VisibleForTesting
|
||||
int mAccessPointSecurity;
|
||||
int mWifiEntrySecurity;
|
||||
private TextView mPasswordView;
|
||||
private TextView mSaePasswordIdView;
|
||||
private ImageButton mSsidScanButton;
|
||||
@@ -199,41 +199,41 @@ public class WifiConfigController2 implements TextWatcher,
|
||||
|
||||
private final WifiManager mWifiManager;
|
||||
|
||||
public WifiConfigController2(WifiConfigUiBase2 parent, View view, AccessPoint accessPoint,
|
||||
public WifiConfigController2(WifiConfigUiBase2 parent, View view, WifiEntry wifiEntry,
|
||||
int mode) {
|
||||
this (parent, view, accessPoint, mode, true /* requestFocus */);
|
||||
this (parent, view, wifiEntry, mode, true /* requestFocus */);
|
||||
}
|
||||
|
||||
public WifiConfigController2(WifiConfigUiBase2 parent, View view, AccessPoint accessPoint,
|
||||
public WifiConfigController2(WifiConfigUiBase2 parent, View view, WifiEntry wifiEntry,
|
||||
int mode, boolean requestFocus) {
|
||||
mConfigUi = parent;
|
||||
|
||||
mView = view;
|
||||
mAccessPoint = accessPoint;
|
||||
mWifiEntry = wifiEntry;
|
||||
mContext = mConfigUi.getContext();
|
||||
mRequestFocus = requestFocus;
|
||||
|
||||
// Init Wi-Fi manager
|
||||
mWifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
|
||||
initWifiConfigController2(accessPoint, mode);
|
||||
initWifiConfigController2(wifiEntry, mode);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public WifiConfigController2(WifiConfigUiBase2 parent, View view, AccessPoint accessPoint,
|
||||
public WifiConfigController2(WifiConfigUiBase2 parent, View view, WifiEntry wifiEntry,
|
||||
int mode, WifiManager wifiManager) {
|
||||
mConfigUi = parent;
|
||||
|
||||
mView = view;
|
||||
mAccessPoint = accessPoint;
|
||||
mWifiEntry = wifiEntry;
|
||||
mContext = mConfigUi.getContext();
|
||||
mWifiManager = wifiManager;
|
||||
initWifiConfigController2(accessPoint, mode);
|
||||
initWifiConfigController2(wifiEntry, mode);
|
||||
}
|
||||
|
||||
private void initWifiConfigController2(AccessPoint accessPoint, int mode) {
|
||||
private void initWifiConfigController2(WifiEntry wifiEntry, int mode) {
|
||||
|
||||
mAccessPointSecurity = (accessPoint == null) ? AccessPoint.SECURITY_NONE :
|
||||
accessPoint.getSecurity();
|
||||
mWifiEntrySecurity = (wifiEntry == null) ? WifiEntry.SECURITY_NONE :
|
||||
wifiEntry.getSecurity();
|
||||
mMode = mode;
|
||||
|
||||
final Resources res = mContext.getResources();
|
||||
@@ -277,19 +277,19 @@ public class WifiConfigController2 implements TextWatcher,
|
||||
mHiddenSettingsSpinner.getSelectedItemPosition() == NOT_HIDDEN_NETWORK
|
||||
? View.GONE
|
||||
: View.VISIBLE);
|
||||
mSecurityInPosition = new Integer[AccessPoint.SECURITY_MAX_VAL];
|
||||
mSecurityInPosition = new Integer[WifiEntry.SECURITY_MAX_VAL];
|
||||
|
||||
if (mAccessPoint == null) { // new network
|
||||
if (mWifiEntry == null) { // new network
|
||||
configureSecuritySpinner();
|
||||
mConfigUi.setSubmitButton(res.getString(R.string.wifi_save));
|
||||
} else {
|
||||
mConfigUi.setTitle(mAccessPoint.getTitle());
|
||||
mConfigUi.setTitle(mWifiEntry.getTitle());
|
||||
|
||||
ViewGroup group = (ViewGroup) mView.findViewById(R.id.info);
|
||||
|
||||
boolean showAdvancedFields = false;
|
||||
if (mAccessPoint.isSaved()) {
|
||||
WifiConfiguration config = mAccessPoint.getConfig();
|
||||
if (mWifiEntry.isSaved()) {
|
||||
WifiConfiguration config = mWifiEntry.getWifiConfiguration();
|
||||
mMeteredSettingsSpinner.setSelection(config.meteredOverride);
|
||||
mHiddenSettingsSpinner.setSelection(config.hiddenSSID
|
||||
? HIDDEN_NETWORK
|
||||
@@ -339,8 +339,9 @@ public class WifiConfigController2 implements TextWatcher,
|
||||
}
|
||||
}
|
||||
|
||||
if ((!mAccessPoint.isSaved() && !mAccessPoint.isActive()
|
||||
&& !mAccessPoint.isPasspointConfig())
|
||||
if ((!mWifiEntry.isSaved()
|
||||
&& mWifiEntry.getConnectedState() != WifiEntry.CONNECTED_STATE_CONNECTED
|
||||
&& !WifiEntryShell.isPasspoint(mWifiEntry))
|
||||
|| mMode != WifiConfigUiBase2.MODE_VIEW) {
|
||||
showSecurityFields(/* refreshEapMethods */ true, /* refreshCertificates */ true);
|
||||
showIpConfigFields();
|
||||
@@ -359,55 +360,50 @@ public class WifiConfigController2 implements TextWatcher,
|
||||
} else if (mMode == WifiConfigUiBase2.MODE_CONNECT) {
|
||||
mConfigUi.setSubmitButton(res.getString(R.string.wifi_connect));
|
||||
} else {
|
||||
final DetailedState state = mAccessPoint.getDetailedState();
|
||||
final String signalLevel = getSignalString();
|
||||
|
||||
if ((state == null || state == DetailedState.DISCONNECTED) && signalLevel != null) {
|
||||
if (mWifiEntry.getConnectedState() != WifiEntry.CONNECTED_STATE_CONNECTED
|
||||
&& signalLevel != null) {
|
||||
mConfigUi.setSubmitButton(res.getString(R.string.wifi_connect));
|
||||
} else {
|
||||
if (state != null) {
|
||||
boolean isEphemeral = mAccessPoint.isEphemeral();
|
||||
WifiConfiguration config = mAccessPoint.getConfig();
|
||||
String providerFriendlyName = null;
|
||||
if (config != null && config.isPasspoint()) {
|
||||
providerFriendlyName = config.providerFriendlyName;
|
||||
}
|
||||
String suggestionOrSpecifierPackageName = null;
|
||||
if (config != null
|
||||
&& (config.fromWifiNetworkSpecifier
|
||||
|| config.fromWifiNetworkSuggestion)) {
|
||||
suggestionOrSpecifierPackageName = config.creatorName;
|
||||
}
|
||||
String summary = AccessPoint.getSummary(
|
||||
mConfigUi.getContext(), /* ssid */ null, state, isEphemeral,
|
||||
suggestionOrSpecifierPackageName);
|
||||
addRow(group, R.string.wifi_status, summary);
|
||||
}
|
||||
// TODO(b/143326832): Add fine-grained state information.
|
||||
//WifiConfiguration config = mWifiEntry.getWifiConfiguration();
|
||||
//String suggestionOrSpecifierPackageName = null;
|
||||
//if (config != null
|
||||
// && (config.fromWifiNetworkSpecifier
|
||||
// || config.fromWifiNetworkSuggestion)) {
|
||||
// suggestionOrSpecifierPackageName = config.creatorName;
|
||||
//}
|
||||
//String summary = AccessPoint.getSummary(
|
||||
// mConfigUi.getContext(), /* ssid */ null, state, isEphemeral,
|
||||
// suggestionOrSpecifierPackageName);
|
||||
//addRow(group, R.string.wifi_status, summary);
|
||||
|
||||
if (signalLevel != null) {
|
||||
addRow(group, R.string.wifi_signal, signalLevel);
|
||||
}
|
||||
|
||||
WifiInfo info = mAccessPoint.getInfo();
|
||||
if (info != null && info.getTxLinkSpeedMbps() != WifiInfo.LINK_SPEED_UNKNOWN) {
|
||||
addRow(group, R.string.tx_wifi_speed, String.format(
|
||||
res.getString(R.string.tx_link_speed), info.getTxLinkSpeedMbps()));
|
||||
}
|
||||
final ConnectedInfo info = mWifiEntry.getConnectedInfo();
|
||||
// TODO(b/143326832): Replace it with ConnectedInfo#linkSpeedMbps.
|
||||
//if (info != null && info.getTxLinkSpeedMbps() != WifiInfo.LINK_SPEED_UNKNOWN) {
|
||||
// addRow(group, R.string.tx_wifi_speed, String.format(
|
||||
// res.getString(R.string.tx_link_speed), info.getTxLinkSpeedMbps()));
|
||||
//}
|
||||
|
||||
if (info != null && info.getRxLinkSpeedMbps() != WifiInfo.LINK_SPEED_UNKNOWN) {
|
||||
addRow(group, R.string.rx_wifi_speed, String.format(
|
||||
res.getString(R.string.rx_link_speed), info.getRxLinkSpeedMbps()));
|
||||
}
|
||||
//if (info != null && info.getRxLinkSpeedMbps() != WifiInfo.LINK_SPEED_UNKNOWN) {
|
||||
// addRow(group, R.string.rx_wifi_speed, String.format(
|
||||
// res.getString(R.string.rx_link_speed), info.getRxLinkSpeedMbps()));
|
||||
//}
|
||||
|
||||
if (info != null && info.getFrequency() != -1) {
|
||||
final int frequency = info.getFrequency();
|
||||
if (info != null && info.frequencyMhz != WifiEntry.FREQUENCY_UNKNOWN) {
|
||||
final int frequency = info.frequencyMhz;
|
||||
String band = null;
|
||||
|
||||
if (frequency >= AccessPoint.LOWER_FREQ_24GHZ
|
||||
&& frequency < AccessPoint.HIGHER_FREQ_24GHZ) {
|
||||
if (frequency >= WifiEntryShell.LOWER_FREQ_24GHZ
|
||||
&& frequency < WifiEntryShell.HIGHER_FREQ_24GHZ) {
|
||||
band = res.getString(R.string.wifi_band_24ghz);
|
||||
} else if (frequency >= AccessPoint.LOWER_FREQ_5GHZ
|
||||
&& frequency < AccessPoint.HIGHER_FREQ_5GHZ) {
|
||||
} else if (frequency >= WifiEntryShell.LOWER_FREQ_5GHZ
|
||||
&& frequency < WifiEntryShell.HIGHER_FREQ_5GHZ) {
|
||||
band = res.getString(R.string.wifi_band_5ghz);
|
||||
} else {
|
||||
Log.e(TAG, "Unexpected frequency " + frequency);
|
||||
@@ -417,11 +413,13 @@ public class WifiConfigController2 implements TextWatcher,
|
||||
}
|
||||
}
|
||||
|
||||
addRow(group, R.string.wifi_security, mAccessPoint.getSecurityString(false));
|
||||
addRow(group, R.string.wifi_security,
|
||||
WifiEntryShell.getSecurityString(mWifiEntry, false));
|
||||
mView.findViewById(R.id.ip_fields).setVisibility(View.GONE);
|
||||
}
|
||||
if (mAccessPoint.isSaved() || mAccessPoint.isActive()
|
||||
|| mAccessPoint.isPasspointConfig()) {
|
||||
if (mWifiEntry.isSaved()
|
||||
|| mWifiEntry.getConnectedState() == WifiEntry.CONNECTED_STATE_CONNECTED
|
||||
|| WifiEntryShell.isPasspoint(mWifiEntry)) {
|
||||
mConfigUi.setForgetButton(res.getString(R.string.wifi_forget));
|
||||
}
|
||||
}
|
||||
@@ -460,10 +458,10 @@ public class WifiConfigController2 implements TextWatcher,
|
||||
|
||||
@VisibleForTesting
|
||||
String getSignalString() {
|
||||
if (!mAccessPoint.isReachable()) {
|
||||
if (mWifiEntry.getLevel() == WifiEntry.WIFI_LEVEL_UNREACHABLE) {
|
||||
return null;
|
||||
}
|
||||
final int level = mAccessPoint.getLevel();
|
||||
final int level = mWifiEntry.getLevel();
|
||||
|
||||
return (level > -1 && level < mLevels.length) ? mLevels[level] : null;
|
||||
}
|
||||
@@ -510,27 +508,27 @@ public class WifiConfigController2 implements TextWatcher,
|
||||
boolean enabled = false;
|
||||
boolean passwordInvalid = false;
|
||||
if (mPasswordView != null
|
||||
&& ((mAccessPointSecurity == AccessPoint.SECURITY_WEP
|
||||
&& ((mWifiEntrySecurity == WifiEntry.SECURITY_WEP
|
||||
&& mPasswordView.length() == 0)
|
||||
|| (mAccessPointSecurity == AccessPoint.SECURITY_PSK
|
||||
|| (mWifiEntrySecurity == WifiEntry.SECURITY_PSK
|
||||
&& !isValidPsk(mPasswordView.getText().toString()))
|
||||
|| (mAccessPointSecurity == AccessPoint.SECURITY_SAE
|
||||
|| (mWifiEntrySecurity == WifiEntry.SECURITY_SAE
|
||||
&& !isValidSaePassword(mPasswordView.getText().toString())))) {
|
||||
passwordInvalid = true;
|
||||
}
|
||||
if ((mSsidView != null && mSsidView.length() == 0)
|
||||
// If Accesspoint is not saved, apply passwordInvalid check
|
||||
|| ((mAccessPoint == null || !mAccessPoint.isSaved()) && passwordInvalid
|
||||
// If AccessPoint is saved (modifying network) and password is changed, apply
|
||||
// If WifiEntry is not saved, apply passwordInvalid check
|
||||
|| ((mWifiEntry == null || !mWifiEntry.isSaved()) && passwordInvalid
|
||||
// If WifiEntry is saved (modifying network) and password is changed, apply
|
||||
// Invalid password check
|
||||
|| mAccessPoint != null && mAccessPoint.isSaved() && passwordInvalid
|
||||
|| mWifiEntry != null && mWifiEntry.isSaved() && passwordInvalid
|
||||
&& mPasswordView.length() > 0)) {
|
||||
enabled = false;
|
||||
} else {
|
||||
enabled = ipAndProxyFieldsAreValid();
|
||||
}
|
||||
if ((mAccessPointSecurity == AccessPoint.SECURITY_EAP
|
||||
|| mAccessPointSecurity == AccessPoint.SECURITY_EAP_SUITE_B)
|
||||
if ((mWifiEntrySecurity == WifiEntry.SECURITY_EAP
|
||||
|| mWifiEntrySecurity == WifiEntry.SECURITY_EAP_SUITE_B)
|
||||
&& mEapCaCertSpinner != null
|
||||
&& mView.findViewById(R.id.l_ca_cert).getVisibility() != View.GONE) {
|
||||
String caCertSelection = (String) mEapCaCertSpinner.getSelectedItem();
|
||||
@@ -548,8 +546,8 @@ public class WifiConfigController2 implements TextWatcher,
|
||||
enabled = false;
|
||||
}
|
||||
}
|
||||
if ((mAccessPointSecurity == AccessPoint.SECURITY_EAP
|
||||
|| mAccessPointSecurity == AccessPoint.SECURITY_EAP_SUITE_B)
|
||||
if ((mWifiEntrySecurity == WifiEntry.SECURITY_EAP
|
||||
|| mWifiEntrySecurity == WifiEntry.SECURITY_EAP_SUITE_B)
|
||||
&& mEapUserCertSpinner != null
|
||||
&& mView.findViewById(R.id.l_user_cert).getVisibility() != View.GONE
|
||||
&& mEapUserCertSpinner.getSelectedItem().equals(mUnspecifiedCertString)) {
|
||||
@@ -591,7 +589,7 @@ public class WifiConfigController2 implements TextWatcher,
|
||||
}
|
||||
}
|
||||
|
||||
if (mAccessPointSecurity == AccessPoint.SECURITY_EAP_SUITE_B
|
||||
if (mWifiEntrySecurity == WifiEntry.SECURITY_EAP_SUITE_B
|
||||
&& mEapMethodSpinner.getSelectedItemPosition() == WIFI_EAP_METHOD_TLS) {
|
||||
String userCertSelection = (String) mEapUserCertSpinner.getSelectedItem();
|
||||
if (userCertSelection.equals(mUnspecifiedCertString)) {
|
||||
@@ -601,7 +599,7 @@ public class WifiConfigController2 implements TextWatcher,
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@link WifiConfiguration} from mAccessPoint and UI edit result.
|
||||
* @return {@link WifiConfiguration} from mWifiEntry and UI edit result.
|
||||
*/
|
||||
public WifiConfiguration getConfig() {
|
||||
if (mMode == WifiConfigUiBase2.MODE_VIEW) {
|
||||
@@ -610,27 +608,27 @@ public class WifiConfigController2 implements TextWatcher,
|
||||
|
||||
WifiConfiguration config = new WifiConfiguration();
|
||||
|
||||
if (mAccessPoint == null) {
|
||||
if (mWifiEntry == null) {
|
||||
config.SSID = AccessPoint.convertToQuotedString(
|
||||
mSsidView.getText().toString());
|
||||
// If the user adds a network manually, assume that it is hidden.
|
||||
config.hiddenSSID = mHiddenSettingsSpinner.getSelectedItemPosition() == HIDDEN_NETWORK;
|
||||
} else if (!mAccessPoint.isSaved()) {
|
||||
} else if (!mWifiEntry.isSaved()) {
|
||||
config.SSID = AccessPoint.convertToQuotedString(
|
||||
mAccessPoint.getSsidStr());
|
||||
mWifiEntry.getTitle());
|
||||
} else {
|
||||
config.networkId = mAccessPoint.getConfig().networkId;
|
||||
config.hiddenSSID = mAccessPoint.getConfig().hiddenSSID;
|
||||
config.networkId = mWifiEntry.getWifiConfiguration().networkId;
|
||||
config.hiddenSSID = mWifiEntry.getWifiConfiguration().hiddenSSID;
|
||||
}
|
||||
|
||||
config.shared = mSharedCheckBox.isChecked();
|
||||
|
||||
switch (mAccessPointSecurity) {
|
||||
case AccessPoint.SECURITY_NONE:
|
||||
switch (mWifiEntrySecurity) {
|
||||
case WifiEntry.SECURITY_NONE:
|
||||
config.allowedKeyManagement.set(KeyMgmt.NONE);
|
||||
break;
|
||||
|
||||
case AccessPoint.SECURITY_WEP:
|
||||
case WifiEntry.SECURITY_WEP:
|
||||
config.allowedKeyManagement.set(KeyMgmt.NONE);
|
||||
config.allowedAuthAlgorithms.set(AuthAlgorithm.OPEN);
|
||||
config.allowedAuthAlgorithms.set(AuthAlgorithm.SHARED);
|
||||
@@ -647,7 +645,7 @@ public class WifiConfigController2 implements TextWatcher,
|
||||
}
|
||||
break;
|
||||
|
||||
case AccessPoint.SECURITY_PSK:
|
||||
case WifiEntry.SECURITY_PSK:
|
||||
config.allowedKeyManagement.set(KeyMgmt.WPA_PSK);
|
||||
if (mPasswordView.length() != 0) {
|
||||
String password = mPasswordView.getText().toString();
|
||||
@@ -659,11 +657,11 @@ public class WifiConfigController2 implements TextWatcher,
|
||||
}
|
||||
break;
|
||||
|
||||
case AccessPoint.SECURITY_EAP:
|
||||
case AccessPoint.SECURITY_EAP_SUITE_B:
|
||||
case WifiEntry.SECURITY_EAP:
|
||||
case WifiEntry.SECURITY_EAP_SUITE_B:
|
||||
config.allowedKeyManagement.set(KeyMgmt.WPA_EAP);
|
||||
config.allowedKeyManagement.set(KeyMgmt.IEEE8021X);
|
||||
if (mAccessPointSecurity == AccessPoint.SECURITY_EAP_SUITE_B) {
|
||||
if (mWifiEntrySecurity == WifiEntry.SECURITY_EAP_SUITE_B) {
|
||||
config.allowedKeyManagement.set(KeyMgmt.SUITE_B_192);
|
||||
config.requirePMF = true;
|
||||
config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.GCMP_256);
|
||||
@@ -736,14 +734,13 @@ public class WifiConfigController2 implements TextWatcher,
|
||||
} else if (caCert.equals(mUseSystemCertsString)) {
|
||||
config.enterpriseConfig.setCaPath(SYSTEM_CA_STORE_PATH);
|
||||
} else if (caCert.equals(mMultipleCertSetString)) {
|
||||
if (mAccessPoint != null) {
|
||||
if (!mAccessPoint.isSaved()) {
|
||||
if (mWifiEntry != null) {
|
||||
if (!mWifiEntry.isSaved()) {
|
||||
Log.e(TAG, "Multiple certs can only be set "
|
||||
+ "when editing saved network");
|
||||
}
|
||||
config.enterpriseConfig.setCaCertificateAliases(
|
||||
mAccessPoint
|
||||
.getConfig()
|
||||
mWifiEntry.getWifiConfiguration()
|
||||
.enterpriseConfig
|
||||
.getCaCertificateAliases());
|
||||
}
|
||||
@@ -803,7 +800,7 @@ public class WifiConfigController2 implements TextWatcher,
|
||||
config.enterpriseConfig.setPassword(mPasswordView.getText().toString());
|
||||
}
|
||||
break;
|
||||
case AccessPoint.SECURITY_SAE:
|
||||
case WifiEntry.SECURITY_SAE:
|
||||
config.allowedKeyManagement.set(KeyMgmt.SAE);
|
||||
config.requirePMF = true;
|
||||
if (mPasswordView.length() != 0) {
|
||||
@@ -817,7 +814,7 @@ public class WifiConfigController2 implements TextWatcher,
|
||||
}
|
||||
break;
|
||||
|
||||
case AccessPoint.SECURITY_OWE:
|
||||
case WifiEntry.SECURITY_OWE:
|
||||
config.allowedKeyManagement.set(KeyMgmt.OWE);
|
||||
config.requirePMF = true;
|
||||
break;
|
||||
@@ -981,8 +978,8 @@ public class WifiConfigController2 implements TextWatcher,
|
||||
}
|
||||
|
||||
private void showSecurityFields(boolean refreshEapMethods, boolean refreshCertificates) {
|
||||
if (mAccessPointSecurity == AccessPoint.SECURITY_NONE
|
||||
|| mAccessPointSecurity == AccessPoint.SECURITY_OWE) {
|
||||
if (mWifiEntrySecurity == WifiEntry.SECURITY_NONE
|
||||
|| mWifiEntrySecurity == WifiEntry.SECURITY_OWE) {
|
||||
mView.findViewById(R.id.security_fields).setVisibility(View.GONE);
|
||||
return;
|
||||
}
|
||||
@@ -996,7 +993,7 @@ public class WifiConfigController2 implements TextWatcher,
|
||||
((CheckBox) mView.findViewById(R.id.show_password))
|
||||
.setOnCheckedChangeListener(this);
|
||||
|
||||
if (mAccessPoint != null && mAccessPoint.isSaved()) {
|
||||
if (mWifiEntry != null && mWifiEntry.isSaved()) {
|
||||
mPasswordView.setHint(R.string.wifi_unchanged);
|
||||
}
|
||||
}
|
||||
@@ -1007,19 +1004,19 @@ public class WifiConfigController2 implements TextWatcher,
|
||||
mSaePasswordIdView.setOnKeyListener(this);
|
||||
}
|
||||
|
||||
if (mAccessPointSecurity == AccessPoint.SECURITY_SAE) {
|
||||
if (mWifiEntrySecurity == WifiEntry.SECURITY_SAE) {
|
||||
mView.findViewById(R.id.sae_password_id_layout).setVisibility(View.VISIBLE);
|
||||
if (mAccessPoint != null && mAccessPoint.isSaved()) {
|
||||
if (!TextUtils.isEmpty(mAccessPoint.getConfig().saePasswordId)) {
|
||||
mSaePasswordIdView.setText(mAccessPoint.getConfig().saePasswordId);
|
||||
if (mWifiEntry != null && mWifiEntry.isSaved()) {
|
||||
if (!TextUtils.isEmpty(mWifiEntry.getWifiConfiguration().saePasswordId)) {
|
||||
mSaePasswordIdView.setText(mWifiEntry.getWifiConfiguration().saePasswordId);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
setSaePasswordIdInvisible();
|
||||
}
|
||||
|
||||
if (mAccessPointSecurity != AccessPoint.SECURITY_EAP
|
||||
&& mAccessPointSecurity != AccessPoint.SECURITY_EAP_SUITE_B) {
|
||||
if (mWifiEntrySecurity != WifiEntry.SECURITY_EAP
|
||||
&& mWifiEntrySecurity != WifiEntry.SECURITY_EAP_SUITE_B) {
|
||||
mView.findViewById(R.id.eap).setVisibility(View.GONE);
|
||||
return;
|
||||
}
|
||||
@@ -1046,7 +1043,7 @@ public class WifiConfigController2 implements TextWatcher,
|
||||
|
||||
if (refreshEapMethods) {
|
||||
ArrayAdapter<CharSequence> eapMethodSpinnerAdapter;
|
||||
if (mAccessPointSecurity == AccessPoint.SECURITY_EAP_SUITE_B) {
|
||||
if (mWifiEntrySecurity == WifiEntry.SECURITY_EAP_SUITE_B) {
|
||||
eapMethodSpinnerAdapter = getSpinnerAdapter(R.array.wifi_eap_method);
|
||||
mEapMethodSpinner.setAdapter(eapMethodSpinnerAdapter);
|
||||
// WAP3-Enterprise 192-bit only allows EAP method TLS
|
||||
@@ -1086,8 +1083,9 @@ public class WifiConfigController2 implements TextWatcher,
|
||||
}
|
||||
|
||||
// Modifying an existing network
|
||||
if (initiateEnterpriseNetworkUi && mAccessPoint != null && mAccessPoint.isSaved()) {
|
||||
WifiEnterpriseConfig enterpriseConfig = mAccessPoint.getConfig().enterpriseConfig;
|
||||
if (initiateEnterpriseNetworkUi && mWifiEntry != null && mWifiEntry.isSaved()) {
|
||||
WifiEnterpriseConfig enterpriseConfig = mWifiEntry.getWifiConfiguration()
|
||||
.enterpriseConfig;
|
||||
int eapMethod = enterpriseConfig.getEapMethod();
|
||||
int phase2Method = enterpriseConfig.getPhase2Method();
|
||||
mEapMethodSpinner.setSelection(eapMethod);
|
||||
@@ -1340,8 +1338,8 @@ public class WifiConfigController2 implements TextWatcher,
|
||||
|
||||
mView.findViewById(R.id.ip_fields).setVisibility(View.VISIBLE);
|
||||
|
||||
if (mAccessPoint != null && mAccessPoint.isSaved()) {
|
||||
config = mAccessPoint.getConfig();
|
||||
if (mWifiEntry != null && mWifiEntry.isSaved()) {
|
||||
config = mWifiEntry.getWifiConfiguration();
|
||||
}
|
||||
|
||||
if (mIpSettingsSpinner.getSelectedItemPosition() == STATIC_IP) {
|
||||
@@ -1392,8 +1390,8 @@ public class WifiConfigController2 implements TextWatcher,
|
||||
|
||||
mView.findViewById(R.id.proxy_settings_fields).setVisibility(View.VISIBLE);
|
||||
|
||||
if (mAccessPoint != null && mAccessPoint.isSaved()) {
|
||||
config = mAccessPoint.getConfig();
|
||||
if (mWifiEntry != null && mWifiEntry.isSaved()) {
|
||||
config = mWifiEntry.getWifiConfiguration();
|
||||
}
|
||||
|
||||
if (mProxySettingsSpinner.getSelectedItemPosition() == PROXY_STATIC) {
|
||||
@@ -1471,7 +1469,7 @@ public class WifiConfigController2 implements TextWatcher,
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "can't get the certificate list from KeyStore");
|
||||
}
|
||||
if (mAccessPointSecurity != AccessPoint.SECURITY_EAP_SUITE_B) {
|
||||
if (mWifiEntrySecurity != WifiEntry.SECURITY_EAP_SUITE_B) {
|
||||
certs.add(noCertificateString);
|
||||
}
|
||||
|
||||
@@ -1574,10 +1572,10 @@ public class WifiConfigController2 implements TextWatcher,
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
if (parent == mSecuritySpinner) {
|
||||
// Convert menu position to actual Wi-Fi security type
|
||||
mAccessPointSecurity = mSecurityInPosition[position];
|
||||
mWifiEntrySecurity = mSecurityInPosition[position];
|
||||
showSecurityFields(/* refreshEapMethods */ true, /* refreshCertificates */ true);
|
||||
|
||||
if (WifiDppUtils.isSupportEnrolleeQrCodeScanner(mContext, mAccessPointSecurity)) {
|
||||
if (WifiDppUtils.isSupportEnrolleeQrCodeScanner(mContext, mWifiEntrySecurity)) {
|
||||
mSsidScanButton.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
mSsidScanButton.setVisibility(View.GONE);
|
||||
@@ -1624,8 +1622,8 @@ public class WifiConfigController2 implements TextWatcher,
|
||||
: InputType.TYPE_TEXT_VARIATION_PASSWORD));
|
||||
}
|
||||
|
||||
public AccessPoint getAccessPoint() {
|
||||
return mAccessPoint;
|
||||
public WifiEntry getWifiEntry() {
|
||||
return mWifiEntry;
|
||||
}
|
||||
|
||||
private void configureSecuritySpinner() {
|
||||
@@ -1644,24 +1642,24 @@ public class WifiConfigController2 implements TextWatcher,
|
||||
|
||||
// Populate the Wi-Fi security spinner with the various supported key management types
|
||||
spinnerAdapter.add(mContext.getString(R.string.wifi_security_none));
|
||||
mSecurityInPosition[idx++] = AccessPoint.SECURITY_NONE;
|
||||
mSecurityInPosition[idx++] = WifiEntry.SECURITY_NONE;
|
||||
if (mWifiManager.isEnhancedOpenSupported()) {
|
||||
spinnerAdapter.add(mContext.getString(R.string.wifi_security_owe));
|
||||
mSecurityInPosition[idx++] = AccessPoint.SECURITY_OWE;
|
||||
mSecurityInPosition[idx++] = WifiEntry.SECURITY_OWE;
|
||||
}
|
||||
spinnerAdapter.add(mContext.getString(R.string.wifi_security_wep));
|
||||
mSecurityInPosition[idx++] = AccessPoint.SECURITY_WEP;
|
||||
mSecurityInPosition[idx++] = WifiEntry.SECURITY_WEP;
|
||||
spinnerAdapter.add(mContext.getString(R.string.wifi_security_wpa_wpa2));
|
||||
mSecurityInPosition[idx++] = AccessPoint.SECURITY_PSK;
|
||||
mSecurityInPosition[idx++] = WifiEntry.SECURITY_PSK;
|
||||
if (mWifiManager.isWpa3SaeSupported()) {
|
||||
spinnerAdapter.add(mContext.getString(R.string.wifi_security_sae));
|
||||
mSecurityInPosition[idx++] = AccessPoint.SECURITY_SAE;
|
||||
mSecurityInPosition[idx++] = WifiEntry.SECURITY_SAE;
|
||||
}
|
||||
spinnerAdapter.add(mContext.getString(R.string.wifi_security_eap));
|
||||
mSecurityInPosition[idx++] = AccessPoint.SECURITY_EAP;
|
||||
mSecurityInPosition[idx++] = WifiEntry.SECURITY_EAP;
|
||||
if (mWifiManager.isWpa3SuiteBSupported()) {
|
||||
spinnerAdapter.add(mContext.getString(R.string.wifi_security_eap_suiteb));
|
||||
mSecurityInPosition[idx++] = AccessPoint.SECURITY_EAP_SUITE_B;
|
||||
mSecurityInPosition[idx++] = WifiEntry.SECURITY_EAP_SUITE_B;
|
||||
}
|
||||
|
||||
spinnerAdapter.notifyDataSetChanged();
|
||||
|
@@ -30,7 +30,7 @@ import androidx.appcompat.app.AlertDialog;
|
||||
import com.android.settings.R;
|
||||
import com.android.settingslib.RestrictedLockUtils;
|
||||
import com.android.settingslib.RestrictedLockUtilsInternal;
|
||||
import com.android.settingslib.wifi.AccessPoint;
|
||||
import com.android.wifitrackerlib.WifiEntry;
|
||||
|
||||
/**
|
||||
* Dialog for users to edit a Wi-Fi network.
|
||||
@@ -66,7 +66,7 @@ public class WifiDialog2 extends AlertDialog implements WifiConfigUiBase2,
|
||||
|
||||
private final int mMode;
|
||||
private final WifiDialog2Listener mListener;
|
||||
private final AccessPoint mAccessPoint;
|
||||
private final WifiEntry mWifiEntry;
|
||||
|
||||
private View mView;
|
||||
private WifiConfigController2 mController;
|
||||
@@ -77,8 +77,8 @@ public class WifiDialog2 extends AlertDialog implements WifiConfigUiBase2,
|
||||
* view.
|
||||
*/
|
||||
public static WifiDialog2 createModal(Context context, WifiDialog2Listener listener,
|
||||
AccessPoint accessPoint, int mode) {
|
||||
return new WifiDialog2(context, listener, accessPoint, mode, 0 /* style */,
|
||||
WifiEntry wifiEntry, int mode) {
|
||||
return new WifiDialog2(context, listener, wifiEntry, mode, 0 /* style */,
|
||||
mode == WifiConfigUiBase2.MODE_VIEW /* hideSubmitButton */);
|
||||
}
|
||||
|
||||
@@ -87,17 +87,17 @@ public class WifiDialog2 extends AlertDialog implements WifiConfigUiBase2,
|
||||
* view.
|
||||
*/
|
||||
public static WifiDialog2 createModal(Context context, WifiDialog2Listener listener,
|
||||
AccessPoint accessPoint, int mode, @StyleRes int style) {
|
||||
return new WifiDialog2(context, listener, accessPoint, mode, style,
|
||||
WifiEntry wifiEntry, int mode, @StyleRes int style) {
|
||||
return new WifiDialog2(context, listener, wifiEntry, mode, style,
|
||||
mode == WifiConfigUiBase2.MODE_VIEW /* hideSubmitButton */);
|
||||
}
|
||||
|
||||
/* package */ WifiDialog2(Context context, WifiDialog2Listener listener,
|
||||
AccessPoint accessPoint, int mode, @StyleRes int style, boolean hideSubmitButton) {
|
||||
/* package */ WifiDialog2(Context context, WifiDialog2Listener listener, WifiEntry wifiEntry,
|
||||
int mode, @StyleRes int style, boolean hideSubmitButton) {
|
||||
super(context, style);
|
||||
mMode = mode;
|
||||
mListener = listener;
|
||||
mAccessPoint = accessPoint;
|
||||
mWifiEntry = wifiEntry;
|
||||
mHideSubmitButton = hideSubmitButton;
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ public class WifiDialog2 extends AlertDialog implements WifiConfigUiBase2,
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
mView = getLayoutInflater().inflate(R.layout.wifi_dialog, /* root */ null);
|
||||
setView(mView);
|
||||
mController = new WifiConfigController2(this, mView, mAccessPoint, mMode);
|
||||
mController = new WifiConfigController2(this, mView, mWifiEntry, mMode);
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
if (mHideSubmitButton) {
|
||||
@@ -121,7 +121,7 @@ public class WifiDialog2 extends AlertDialog implements WifiConfigUiBase2,
|
||||
mController.enableSubmitIfAppropriate();
|
||||
}
|
||||
|
||||
if (mAccessPoint == null) {
|
||||
if (mWifiEntry == null) {
|
||||
mController.hideForgetButton();
|
||||
}
|
||||
}
|
||||
@@ -168,7 +168,8 @@ public class WifiDialog2 extends AlertDialog implements WifiConfigUiBase2,
|
||||
mListener.onSubmit(this);
|
||||
break;
|
||||
case BUTTON_FORGET:
|
||||
if (WifiUtils.isNetworkLockedDown(getContext(), mAccessPoint.getConfig())) {
|
||||
if (WifiUtils.isNetworkLockedDown(getContext(),
|
||||
mWifiEntry.getWifiConfiguration())) {
|
||||
RestrictedLockUtils.sendShowAdminSupportDetailsIntent(getContext(),
|
||||
RestrictedLockUtilsInternal.getDeviceOwner(getContext()));
|
||||
return;
|
||||
|
@@ -16,8 +16,6 @@
|
||||
|
||||
package com.android.settings.wifi;
|
||||
|
||||
import android.net.NetworkInfo.DetailedState;
|
||||
|
||||
import com.android.wifitrackerlib.WifiEntry;
|
||||
|
||||
/**
|
||||
@@ -64,13 +62,6 @@ public class WifiEntryShell {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mapping of the corresponding {@link WifiDetailPreferenceController} method
|
||||
*/
|
||||
public static boolean canModifyNetwork(WifiEntry wifiEntry) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mapping of the corresponding {@link AccessPoint} method
|
||||
*/
|
||||
@@ -78,13 +69,6 @@ public class WifiEntryShell {
|
||||
return "None";
|
||||
}
|
||||
|
||||
/**
|
||||
* Mapping of the corresponding {@link AccessPoint} method
|
||||
*/
|
||||
public static DetailedState getDetailedState(WifiEntry wifiEntry) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Passpoint methods
|
||||
|
||||
/**
|
||||
|
@@ -61,9 +61,10 @@ import com.android.settings.core.FeatureFlags;
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settings.datausage.WifiDataUsageSummaryPreferenceController;
|
||||
import com.android.settings.widget.EntityHeaderController;
|
||||
import com.android.settings.wifi.WifiDialog;
|
||||
import com.android.settings.wifi.WifiDialog.WifiDialogListener;
|
||||
import com.android.settings.wifi.WifiDialog2;
|
||||
import com.android.settings.wifi.WifiDialog2.WifiDialog2Listener;
|
||||
import com.android.settings.wifi.WifiEntryShell;
|
||||
import com.android.settings.wifi.WifiUtils;
|
||||
import com.android.settings.wifi.dpp.WifiDppUtils;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||
@@ -93,7 +94,7 @@ import java.util.stream.Collectors;
|
||||
* {@link WifiNetworkDetailsFragment}.
|
||||
*/
|
||||
public class WifiDetailPreferenceController2 extends AbstractPreferenceController
|
||||
implements PreferenceControllerMixin, WifiDialogListener, LifecycleObserver, OnPause,
|
||||
implements PreferenceControllerMixin, WifiDialog2Listener, LifecycleObserver, OnPause,
|
||||
OnResume, WifiEntryCallback {
|
||||
|
||||
private static final String TAG = "WifiDetailsPrefCtrl2";
|
||||
@@ -670,7 +671,8 @@ public class WifiDetailPreferenceController2 extends AbstractPreferenceControlle
|
||||
* Returns whether the network represented by this preference can be modified.
|
||||
*/
|
||||
public boolean canModifyNetwork() {
|
||||
return WifiEntryShell.canModifyNetwork(mWifiEntry);
|
||||
return mWifiEntry.isSaved()
|
||||
&& !WifiUtils.isNetworkLockedDown(mContext, mWifiEntry.getWifiConfiguration());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -762,7 +764,7 @@ public class WifiDetailPreferenceController2 extends AbstractPreferenceControlle
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSubmit(WifiDialog dialog) {
|
||||
public void onSubmit(WifiDialog2 dialog) {
|
||||
if (dialog.getController() != null) {
|
||||
mWifiManager.save(dialog.getController().getConfig(), new WifiManager.ActionListener() {
|
||||
@Override
|
||||
|
@@ -18,6 +18,7 @@ package com.android.settings.wifi.details2;
|
||||
|
||||
import android.app.backup.BackupManager;
|
||||
import android.content.Context;
|
||||
import android.net.wifi.WifiConfiguration;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.preference.DropDownPreference;
|
||||
@@ -25,7 +26,7 @@ import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
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;
|
||||
|
||||
@@ -33,7 +34,7 @@ import com.android.wifitrackerlib.WifiEntry;
|
||||
* {@link AbstractPreferenceController} that controls whether the wifi network is metered or not
|
||||
*/
|
||||
public class WifiMeteredPreferenceController2 extends BasePreferenceController implements
|
||||
Preference.OnPreferenceChangeListener, WifiDialog.WifiDialogListener {
|
||||
Preference.OnPreferenceChangeListener, WifiDialog2.WifiDialog2Listener {
|
||||
|
||||
private static final String KEY_WIFI_METERED = "metered";
|
||||
private WifiEntry mWifiEntry;
|
||||
@@ -89,18 +90,30 @@ public class WifiMeteredPreferenceController2 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.meteredOverride != mWifiConfiguration.meteredOverride) {
|
||||
// mWifiConfiguration = newConfig;
|
||||
// onPreferenceChange(mPreference, String.valueOf(newConfig.meteredOverride));
|
||||
// }
|
||||
//}
|
||||
public void onSubmit(WifiDialog2 dialog) {
|
||||
if (dialog.getController() != null) {
|
||||
final WifiConfiguration newConfig = dialog.getController().getConfig();
|
||||
if (newConfig == null || !mWifiEntry.isSaved()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (newConfig.meteredOverride != mWifiEntry.getWifiConfiguration().meteredOverride) {
|
||||
mWifiEntry.setMeteredChoice(getWifiEntryMeteredChoice(newConfig));
|
||||
onPreferenceChange(mPreference, String.valueOf(newConfig.meteredOverride));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int getWifiEntryMeteredChoice(WifiConfiguration wifiConfiguration) {
|
||||
switch (wifiConfiguration.meteredOverride) {
|
||||
case WifiConfiguration.METERED_OVERRIDE_NONE:
|
||||
return WifiEntry.METERED_CHOICE_AUTO;
|
||||
case WifiConfiguration.METERED_OVERRIDE_METERED:
|
||||
return WifiEntry.METERED_CHOICE_METERED;
|
||||
case WifiConfiguration.METERED_OVERRIDE_NOT_METERED:
|
||||
return WifiEntry.METERED_CHOICE_UNMETERED;
|
||||
default:
|
||||
return WifiEntry.METERED_CHOICE_UNKNOWN;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -35,7 +35,8 @@ import android.view.MenuItem;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.wifi.WifiDialog;
|
||||
import com.android.settings.wifi.WifiConfigUiBase2;
|
||||
import com.android.settings.wifi.WifiDialog2;
|
||||
import com.android.settingslib.RestrictedLockUtils;
|
||||
import com.android.settingslib.RestrictedLockUtilsInternal;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
@@ -54,7 +55,7 @@ import java.util.List;
|
||||
* in order to properly render this page.
|
||||
*/
|
||||
public class WifiNetworkDetailsFragment2 extends DashboardFragment implements
|
||||
WifiDialog.WifiDialogListener {
|
||||
WifiDialog2.WifiDialog2Listener {
|
||||
|
||||
private static final String TAG = "WifiNetworkDetailsFrg2";
|
||||
|
||||
@@ -69,7 +70,7 @@ public class WifiNetworkDetailsFragment2 extends DashboardFragment implements
|
||||
private NetworkDetailsTracker mNetworkDetailsTracker;
|
||||
private HandlerThread mWorkerThread;
|
||||
private WifiDetailPreferenceController2 mWifiDetailPreferenceController2;
|
||||
private List<WifiDialog.WifiDialogListener> mWifiDialogListeners = new ArrayList<>();
|
||||
private List<WifiDialog2.WifiDialog2Listener> mWifiDialogListeners = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
@@ -106,10 +107,10 @@ public class WifiNetworkDetailsFragment2 extends DashboardFragment implements
|
||||
if (getActivity() == null || mWifiDetailPreferenceController2 == null) {
|
||||
return null;
|
||||
}
|
||||
// TODO(b/143326832): Replace it with WifiEntry.
|
||||
return null;
|
||||
//return WifiDialog.createModal(getActivity(), this, mAccessPoint,
|
||||
// WifiConfigUiBase.MODE_MODIFY);
|
||||
|
||||
final WifiEntry wifiEntry = mNetworkDetailsTracker.getWifiEntry();
|
||||
return WifiDialog2.createModal(getActivity(), this, wifiEntry,
|
||||
WifiConfigUiBase2.MODE_MODIFY);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -177,8 +178,8 @@ public class WifiNetworkDetailsFragment2 extends DashboardFragment implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSubmit(WifiDialog dialog) {
|
||||
for (WifiDialog.WifiDialogListener listener : mWifiDialogListeners) {
|
||||
public void onSubmit(WifiDialog2 dialog) {
|
||||
for (WifiDialog2.WifiDialog2Listener listener : mWifiDialogListeners) {
|
||||
listener.onSubmit(dialog);
|
||||
}
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -43,7 +43,7 @@ import android.widget.TextView;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.testutils.shadow.ShadowConnectivityManager;
|
||||
import com.android.settings.wifi.details.WifiPrivacyPreferenceController;
|
||||
import com.android.settingslib.wifi.AccessPoint;
|
||||
import com.android.wifitrackerlib.WifiEntry;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -65,7 +65,7 @@ public class WifiConfigController2Test {
|
||||
@Mock
|
||||
private Context mContext;
|
||||
@Mock
|
||||
private AccessPoint mAccessPoint;
|
||||
private WifiEntry mWifiEntry;
|
||||
@Mock
|
||||
private KeyStore mKeyStore;
|
||||
private View mView;
|
||||
@@ -89,19 +89,19 @@ public class WifiConfigController2Test {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mContext = RuntimeEnvironment.application;
|
||||
when(mConfigUiBase.getContext()).thenReturn(mContext);
|
||||
when(mAccessPoint.getSecurity()).thenReturn(AccessPoint.SECURITY_PSK);
|
||||
when(mWifiEntry.getSecurity()).thenReturn(WifiEntry.SECURITY_PSK);
|
||||
mView = LayoutInflater.from(mContext).inflate(R.layout.wifi_dialog, null);
|
||||
final Spinner ipSettingsSpinner = mView.findViewById(R.id.ip_settings);
|
||||
mHiddenSettingsSpinner = mView.findViewById(R.id.hidden_settings);
|
||||
ipSettingsSpinner.setSelection(DHCP);
|
||||
|
||||
mController = new TestWifiConfigController2(mConfigUiBase, mView, mAccessPoint,
|
||||
mController = new TestWifiConfigController2(mConfigUiBase, mView, mWifiEntry,
|
||||
WifiConfigUiBase2.MODE_CONNECT);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ssidExceeds32Bytes_shouldShowSsidTooLongWarning() {
|
||||
mController = new TestWifiConfigController2(mConfigUiBase, mView, null /* accessPoint */,
|
||||
mController = new TestWifiConfigController2(mConfigUiBase, mView, null /* wifiEntry */,
|
||||
WifiConfigUiBase2.MODE_CONNECT);
|
||||
final TextView ssid = mView.findViewById(R.id.ssid);
|
||||
assertThat(ssid).isNotNull();
|
||||
@@ -114,7 +114,7 @@ public class WifiConfigController2Test {
|
||||
|
||||
@Test
|
||||
public void ssidShorterThan32Bytes_shouldNotShowSsidTooLongWarning() {
|
||||
mController = new TestWifiConfigController2(mConfigUiBase, mView, null /* accessPoint */,
|
||||
mController = new TestWifiConfigController2(mConfigUiBase, mView, null /* wifiEntry */,
|
||||
WifiConfigUiBase2.MODE_CONNECT);
|
||||
|
||||
final TextView ssid = mView.findViewById(R.id.ssid);
|
||||
@@ -177,12 +177,12 @@ public class WifiConfigController2Test {
|
||||
final TextView password = mView.findViewById(R.id.password);
|
||||
assertThat(password).isNotNull();
|
||||
password.setText("");
|
||||
when(mAccessPoint.isSaved()).thenReturn(true);
|
||||
when(mWifiEntry.isSaved()).thenReturn(true);
|
||||
assertThat(mController.isSubmittable()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSubmittable_nullAccessPoint_noException() {
|
||||
public void isSubmittable_nullWifiEntry_noException() {
|
||||
mController = new TestWifiConfigController2(mConfigUiBase, mView, null,
|
||||
WifiConfigUiBase2.MODE_CONNECT);
|
||||
mController.isSubmittable();
|
||||
@@ -197,11 +197,11 @@ public class WifiConfigController2Test {
|
||||
final Spinner securitySpinner = mView.findViewById(R.id.security);
|
||||
assertThat(password).isNotNull();
|
||||
assertThat(securitySpinner).isNotNull();
|
||||
when(mAccessPoint.isSaved()).thenReturn(true);
|
||||
when(mWifiEntry.isSaved()).thenReturn(true);
|
||||
|
||||
// Change it from EAP to PSK
|
||||
mController.onItemSelected(securitySpinner, null, AccessPoint.SECURITY_EAP, 0);
|
||||
mController.onItemSelected(securitySpinner, null, AccessPoint.SECURITY_PSK, 0);
|
||||
mController.onItemSelected(securitySpinner, null, WifiEntry.SECURITY_EAP, 0);
|
||||
mController.onItemSelected(securitySpinner, null, WifiEntry.SECURITY_PSK, 0);
|
||||
password.setText(GOOD_PSK);
|
||||
ssid.setText(GOOD_SSID);
|
||||
|
||||
@@ -210,8 +210,8 @@ public class WifiConfigController2Test {
|
||||
|
||||
@Test
|
||||
public void isSubmittable_EapWithAkaMethod_shouldReturnTrue() {
|
||||
when(mAccessPoint.isSaved()).thenReturn(true);
|
||||
mController.mAccessPointSecurity = AccessPoint.SECURITY_EAP;
|
||||
when(mWifiEntry.isSaved()).thenReturn(true);
|
||||
mController.mWifiEntrySecurity = WifiEntry.SECURITY_EAP;
|
||||
mView.findViewById(R.id.l_ca_cert).setVisibility(View.GONE);
|
||||
|
||||
assertThat(mController.isSubmittable()).isTrue();
|
||||
@@ -219,7 +219,7 @@ public class WifiConfigController2Test {
|
||||
|
||||
@Test
|
||||
public void getSignalString_notReachable_shouldHaveNoSignalString() {
|
||||
when(mAccessPoint.isReachable()).thenReturn(false);
|
||||
when(mWifiEntry.getLevel()).thenReturn(WifiEntry.WIFI_LEVEL_UNREACHABLE);
|
||||
|
||||
assertThat(mController.getSignalString()).isNull();
|
||||
}
|
||||
@@ -227,11 +227,11 @@ public class WifiConfigController2Test {
|
||||
@Test
|
||||
public void loadCertificates_keyStoreListFail_shouldNotCrash() {
|
||||
// Set up
|
||||
when(mAccessPoint.getSecurity()).thenReturn(AccessPoint.SECURITY_EAP);
|
||||
when(mWifiEntry.getSecurity()).thenReturn(WifiEntry.SECURITY_EAP);
|
||||
when(mKeyStore.list(anyString()))
|
||||
.thenThrow(new ServiceSpecificException(-1, "permission error"));
|
||||
|
||||
mController = new TestWifiConfigController2(mConfigUiBase, mView, mAccessPoint,
|
||||
mController = new TestWifiConfigController2(mConfigUiBase, mView, mWifiEntry,
|
||||
WifiConfigUiBase2.MODE_CONNECT);
|
||||
|
||||
// Verify that the EAP method menu is visible.
|
||||
@@ -241,10 +241,10 @@ public class WifiConfigController2Test {
|
||||
|
||||
@Test
|
||||
public void ssidGetFocus_addNewNetwork_shouldReturnTrue() {
|
||||
mController = new TestWifiConfigController2(mConfigUiBase, mView, null /* accessPoint */,
|
||||
mController = new TestWifiConfigController2(mConfigUiBase, mView, null /* wifiEntry */,
|
||||
WifiConfigUiBase2.MODE_CONNECT);
|
||||
final TextView ssid = mView.findViewById(R.id.ssid);
|
||||
// Verify ssid text get focus when add new network (accesspoint is null)
|
||||
// Verify ssid text get focus when add new network (wifiEntry is null)
|
||||
assertThat(ssid.isFocused()).isTrue();
|
||||
}
|
||||
|
||||
@@ -270,7 +270,7 @@ public class WifiConfigController2Test {
|
||||
View hiddenField = mView.findViewById(R.id.hidden_settings_field);
|
||||
assertThat(hiddenField.getVisibility()).isEqualTo(View.GONE);
|
||||
|
||||
mController = new TestWifiConfigController2(mConfigUiBase, mView, null /* accessPoint */,
|
||||
mController = new TestWifiConfigController2(mConfigUiBase, mView, null /* wifiEntry */,
|
||||
WifiConfigUiBase2.MODE_CONNECT);
|
||||
assertThat(hiddenField.getVisibility()).isEqualTo(View.VISIBLE);
|
||||
}
|
||||
@@ -302,7 +302,7 @@ public class WifiConfigController2Test {
|
||||
when(wifiManager.isWpa3SuiteBSupported()).thenReturn(suitebVisible);
|
||||
when(wifiManager.isEnhancedOpenSupported()).thenReturn(oweVisible);
|
||||
|
||||
mController = new TestWifiConfigController2(mConfigUiBase, mView, null /* accessPoint */,
|
||||
mController = new TestWifiConfigController2(mConfigUiBase, mView, null /* wifiEntry */,
|
||||
WifiConfigUiBase2.MODE_MODIFY, wifiManager);
|
||||
|
||||
final Spinner securitySpinner = mView.findViewById(R.id.security);
|
||||
@@ -346,14 +346,14 @@ public class WifiConfigController2Test {
|
||||
public class TestWifiConfigController2 extends WifiConfigController2 {
|
||||
|
||||
private TestWifiConfigController2(
|
||||
WifiConfigUiBase2 parent, View view, AccessPoint accessPoint, int mode) {
|
||||
super(parent, view, accessPoint, mode);
|
||||
WifiConfigUiBase2 parent, View view, WifiEntry wifiEntry, int mode) {
|
||||
super(parent, view, wifiEntry, mode);
|
||||
}
|
||||
|
||||
private TestWifiConfigController2(
|
||||
WifiConfigUiBase2 parent, View view, AccessPoint accessPoint, int mode,
|
||||
WifiConfigUiBase2 parent, View view, WifiEntry wifiEntry, int mode,
|
||||
WifiManager wifiManager) {
|
||||
super(parent, view, accessPoint, mode, wifiManager);
|
||||
super(parent, view, wifiEntry, mode, wifiManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -389,11 +389,11 @@ public class WifiConfigController2Test {
|
||||
}
|
||||
|
||||
private void checkSavedMacRandomizedValue(int macRandomizedValue) {
|
||||
when(mAccessPoint.isSaved()).thenReturn(true);
|
||||
when(mWifiEntry.isSaved()).thenReturn(true);
|
||||
final WifiConfiguration mockWifiConfig = mock(WifiConfiguration.class);
|
||||
when(mAccessPoint.getConfig()).thenReturn(mockWifiConfig);
|
||||
when(mWifiEntry.getWifiConfiguration()).thenReturn(mockWifiConfig);
|
||||
mockWifiConfig.macRandomizationSetting = macRandomizedValue;
|
||||
mController = new TestWifiConfigController2(mConfigUiBase, mView, mAccessPoint,
|
||||
mController = new TestWifiConfigController2(mConfigUiBase, mView, mWifiEntry,
|
||||
WifiConfigUiBase2.MODE_CONNECT);
|
||||
|
||||
final Spinner privacySetting = mView.findViewById(R.id.privacy_settings);
|
||||
@@ -467,7 +467,7 @@ public class WifiConfigController2Test {
|
||||
public void selectSecurity_wpa3Eap192bit_eapMethodTls() {
|
||||
final WifiManager wifiManager = mock(WifiManager.class);
|
||||
when(wifiManager.isWpa3SuiteBSupported()).thenReturn(true);
|
||||
mController = new TestWifiConfigController2(mConfigUiBase, mView, null /* accessPoint */,
|
||||
mController = new TestWifiConfigController2(mConfigUiBase, mView, null /* wifiEntry */,
|
||||
WifiConfigUiBase2.MODE_MODIFY, wifiManager);
|
||||
final Spinner securitySpinner = mView.findViewById(R.id.security);
|
||||
final Spinner eapMethodSpinner = mView.findViewById(R.id.method);
|
||||
@@ -475,7 +475,7 @@ public class WifiConfigController2Test {
|
||||
final int securityCount = mController.mSecurityInPosition.length;
|
||||
for (int i = 0; i < securityCount; i++) {
|
||||
if (mController.mSecurityInPosition[i] != null
|
||||
&& mController.mSecurityInPosition[i] == AccessPoint.SECURITY_EAP_SUITE_B) {
|
||||
&& mController.mSecurityInPosition[i] == WifiEntry.SECURITY_EAP_SUITE_B) {
|
||||
wpa3Eap192bitPosition = i;
|
||||
}
|
||||
}
|
||||
@@ -501,15 +501,15 @@ public class WifiConfigController2Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void selectEapMethod_savedAccessPoint_shouldGetCorrectPosition() {
|
||||
when(mAccessPoint.isSaved()).thenReturn(true);
|
||||
when(mAccessPoint.getSecurity()).thenReturn(AccessPoint.SECURITY_EAP);
|
||||
public void selectEapMethod_savedWifiEntry_shouldGetCorrectPosition() {
|
||||
when(mWifiEntry.isSaved()).thenReturn(true);
|
||||
when(mWifiEntry.getSecurity()).thenReturn(WifiEntry.SECURITY_EAP);
|
||||
final WifiConfiguration mockWifiConfig = mock(WifiConfiguration.class);
|
||||
final WifiEnterpriseConfig mockWifiEnterpriseConfig = mock(WifiEnterpriseConfig.class);
|
||||
when(mockWifiEnterpriseConfig.getEapMethod()).thenReturn(Eap.PEAP);
|
||||
mockWifiConfig.enterpriseConfig = mockWifiEnterpriseConfig;
|
||||
when(mAccessPoint.getConfig()).thenReturn(mockWifiConfig);
|
||||
mController = new TestWifiConfigController2(mConfigUiBase, mView, mAccessPoint,
|
||||
when(mWifiEntry.getWifiConfiguration()).thenReturn(mockWifiConfig);
|
||||
mController = new TestWifiConfigController2(mConfigUiBase, mView, mWifiEntry,
|
||||
WifiConfigUiBase2.MODE_MODIFY);
|
||||
final Spinner eapMethodSpinner = mView.findViewById(R.id.method);
|
||||
final Spinner phase2Spinner = mView.findViewById(R.id.phase2);
|
||||
|
@@ -23,7 +23,7 @@ import android.content.Context;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.testutils.shadow.ShadowEntityHeaderController;
|
||||
import com.android.settings.wifi.WifiDialog2.WifiDialog2Listener;
|
||||
import com.android.settingslib.wifi.AccessPoint;
|
||||
import com.android.wifitrackerlib.WifiEntry;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -37,7 +37,7 @@ import org.robolectric.annotation.Config;
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@Config(shadows = ShadowEntityHeaderController.class)
|
||||
public class WifiDialog2Test {
|
||||
@Mock private AccessPoint mMockAccessPoint;
|
||||
@Mock private WifiEntry mMockWifiEntry;
|
||||
|
||||
private Context mContext = RuntimeEnvironment.application;
|
||||
|
||||
@@ -51,9 +51,9 @@ public class WifiDialog2Test {
|
||||
@Test
|
||||
public void createModal_usesDefaultTheme() {
|
||||
WifiDialog2 modal = WifiDialog2
|
||||
.createModal(mContext, mListener, mMockAccessPoint, WifiConfigUiBase2.MODE_CONNECT);
|
||||
.createModal(mContext, mListener, mMockWifiEntry, WifiConfigUiBase2.MODE_CONNECT);
|
||||
|
||||
WifiDialog2 wifiDialog2 = new WifiDialog2(mContext, mListener, mMockAccessPoint,
|
||||
WifiDialog2 wifiDialog2 = new WifiDialog2(mContext, mListener, mMockWifiEntry,
|
||||
WifiConfigUiBase2.MODE_CONNECT, 0 /* style */, false /* hideSubmitButton */);
|
||||
assertThat(modal.getContext().getThemeResId())
|
||||
.isEqualTo(wifiDialog2.getContext().getThemeResId());
|
||||
@@ -61,10 +61,10 @@ public class WifiDialog2Test {
|
||||
|
||||
@Test
|
||||
public void createModal_whenSetTheme_shouldBeCustomizedTheme() {
|
||||
WifiDialog2 modal = WifiDialog2.createModal(mContext, mListener, mMockAccessPoint,
|
||||
WifiDialog2 modal = WifiDialog2.createModal(mContext, mListener, mMockWifiEntry,
|
||||
WifiConfigUiBase2.MODE_CONNECT, R.style.SuwAlertDialogThemeCompat_Light);
|
||||
|
||||
WifiDialog2 wifiDialog2 = new WifiDialog2(mContext, mListener, mMockAccessPoint,
|
||||
WifiDialog2 wifiDialog2 = new WifiDialog2(mContext, mListener, mMockWifiEntry,
|
||||
WifiConfigUiBase2.MODE_CONNECT, R.style.SuwAlertDialogThemeCompat_Light,
|
||||
false /* hideSubmitButton */);
|
||||
assertThat(modal.getContext().getThemeResId())
|
||||
|
Reference in New Issue
Block a user