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