DO NOT MERGE - qt-qpr1-dev-plus-aosp-without-vendor@5915889 into stage-aosp-master
Bug: 142003500 Change-Id: Ibae6b218a616a93cfda05dd77a5ea6f3a2dc4cea
This commit is contained in:
@@ -340,6 +340,7 @@ public class NetworkRequestDialogFragment extends InstrumentedDialogFragment imp
|
||||
// Throws error dialog.
|
||||
final NetworkRequestErrorDialogFragment fragment = NetworkRequestErrorDialogFragment
|
||||
.newInstance();
|
||||
fragment.setRejectCallback(mUserSelectionCallback);
|
||||
final Bundle bundle = new Bundle();
|
||||
bundle.putSerializable(NetworkRequestErrorDialogFragment.DIALOG_TYPE, type);
|
||||
fragment.setArguments(bundle);
|
||||
|
||||
@@ -20,8 +20,10 @@ import android.app.Dialog;
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.net.wifi.WifiManager.NetworkRequestUserSelectionCallback;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
|
||||
import com.android.settings.R;
|
||||
@@ -36,6 +38,8 @@ public class NetworkRequestErrorDialogFragment extends InstrumentedDialogFragmen
|
||||
public static final String DIALOG_TYPE = "DIALOG_ERROR_TYPE";
|
||||
|
||||
public enum ERROR_DIALOG_TYPE {TIME_OUT, ABORT}
|
||||
@Nullable
|
||||
private NetworkRequestUserSelectionCallback mRejectCallback;
|
||||
|
||||
public static NetworkRequestErrorDialogFragment newInstance() {
|
||||
return new NetworkRequestErrorDialogFragment();
|
||||
@@ -49,7 +53,7 @@ public class NetworkRequestErrorDialogFragment extends InstrumentedDialogFragmen
|
||||
public void onCancel(@NonNull DialogInterface dialog) {
|
||||
super.onCancel(dialog);
|
||||
// Wants to finish the activity when user clicks back key or outside of the dialog.
|
||||
getActivity().finish();
|
||||
rejectNetworkRequestAndFinish();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -65,10 +69,12 @@ public class NetworkRequestErrorDialogFragment extends InstrumentedDialogFragmen
|
||||
builder.setMessage(R.string.network_connection_timeout_dialog_message)
|
||||
.setPositiveButton(R.string.network_connection_timeout_dialog_ok,
|
||||
(dialog, which) -> startScanningDialog())
|
||||
.setNegativeButton(R.string.cancel, (dialog, which) -> getActivity().finish());
|
||||
.setNegativeButton(R.string.cancel,
|
||||
(dialog, which) -> rejectNetworkRequestAndFinish());
|
||||
} else {
|
||||
builder.setMessage(R.string.network_connection_errorstate_dialog_message)
|
||||
.setPositiveButton(R.string.okay, (dialog, which) -> getActivity().finish());
|
||||
.setPositiveButton(R.string.okay,
|
||||
(dialog, which) -> rejectNetworkRequestAndFinish());
|
||||
}
|
||||
return builder.create();
|
||||
}
|
||||
@@ -78,9 +84,23 @@ public class NetworkRequestErrorDialogFragment extends InstrumentedDialogFragmen
|
||||
return SettingsEnums.WIFI_SCANNING_NEEDED_DIALOG;
|
||||
}
|
||||
|
||||
// Sets the callback for fragment to reject this request.
|
||||
public void setRejectCallback(NetworkRequestUserSelectionCallback rejectCallback) {
|
||||
mRejectCallback = rejectCallback;
|
||||
}
|
||||
|
||||
protected void startScanningDialog() {
|
||||
final NetworkRequestDialogFragment fragment = NetworkRequestDialogFragment.newInstance();
|
||||
fragment.show(getActivity().getSupportFragmentManager(),
|
||||
NetworkRequestErrorDialogFragment.class.getSimpleName());
|
||||
}
|
||||
|
||||
private void rejectNetworkRequestAndFinish() {
|
||||
if (getActivity() != null) {
|
||||
if (mRejectCallback != null) {
|
||||
mRejectCallback.reject();
|
||||
}
|
||||
getActivity().finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,7 +179,9 @@ public class WifiConfigController implements TextWatcher,
|
||||
private TextView mSsidView;
|
||||
|
||||
private Context mContext;
|
||||
private Integer mSecurityInPosition[];
|
||||
|
||||
@VisibleForTesting
|
||||
Integer mSecurityInPosition[];
|
||||
|
||||
private final WifiManager mWifiManager;
|
||||
|
||||
@@ -325,7 +327,7 @@ public class WifiConfigController implements TextWatcher,
|
||||
if ((!mAccessPoint.isSaved() && !mAccessPoint.isActive()
|
||||
&& !mAccessPoint.isPasspointConfig())
|
||||
|| mMode != WifiConfigUiBase.MODE_VIEW) {
|
||||
showSecurityFields();
|
||||
showSecurityFields(true /* refreshEapMethods */, true /* refreshCertificates */);
|
||||
showIpConfigFields();
|
||||
showProxyFields();
|
||||
final CheckBox advancedTogglebox =
|
||||
@@ -956,7 +958,7 @@ public class WifiConfigController implements TextWatcher,
|
||||
return 0;
|
||||
}
|
||||
|
||||
private void showSecurityFields() {
|
||||
private void showSecurityFields(boolean refreshEapMethods, boolean refreshCertificates) {
|
||||
if (mAccessPointSecurity == AccessPoint.SECURITY_NONE ||
|
||||
mAccessPointSecurity == AccessPoint.SECURITY_OWE ||
|
||||
mAccessPointSecurity == AccessPoint.SECURITY_OWE_TRANSITION) {
|
||||
@@ -985,19 +987,11 @@ public class WifiConfigController implements TextWatcher,
|
||||
}
|
||||
mView.findViewById(R.id.eap).setVisibility(View.VISIBLE);
|
||||
|
||||
boolean initiateEnterpriseNetworkUi = false;
|
||||
if (mEapMethodSpinner == null) {
|
||||
initiateEnterpriseNetworkUi = true;
|
||||
mEapMethodSpinner = (Spinner) mView.findViewById(R.id.method);
|
||||
mEapMethodSpinner.setOnItemSelectedListener(this);
|
||||
if (Utils.isWifiOnly(mContext) || !mContext.getResources().getBoolean(
|
||||
com.android.internal.R.bool.config_eap_sim_based_auth_supported)) {
|
||||
String[] eapMethods = mContext.getResources().getStringArray(
|
||||
R.array.eap_method_without_sim_auth);
|
||||
ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<String>(mContext,
|
||||
android.R.layout.simple_spinner_item, eapMethods);
|
||||
spinnerAdapter.setDropDownViewResource(
|
||||
android.R.layout.simple_spinner_dropdown_item);
|
||||
mEapMethodSpinner.setAdapter(spinnerAdapter);
|
||||
}
|
||||
mPhase2Spinner = (Spinner) mView.findViewById(R.id.phase2);
|
||||
mPhase2Spinner.setOnItemSelectedListener(this);
|
||||
mEapCaCertSpinner = (Spinner) mView.findViewById(R.id.ca_cert);
|
||||
@@ -1008,11 +1002,36 @@ public class WifiConfigController implements TextWatcher,
|
||||
mEapUserCertSpinner.setOnItemSelectedListener(this);
|
||||
mEapIdentityView = (TextView) mView.findViewById(R.id.identity);
|
||||
mEapAnonymousView = (TextView) mView.findViewById(R.id.anonymous);
|
||||
}
|
||||
|
||||
if (mAccessPoint != null && mAccessPoint.isCarrierAp()) {
|
||||
mEapMethodSpinner.setSelection(mAccessPoint.getCarrierApEapType());
|
||||
if (refreshEapMethods) {
|
||||
ArrayAdapter<CharSequence> eapMethodSpinnerAdapter;
|
||||
if (mAccessPointSecurity == AccessPoint.SECURITY_EAP_SUITE_B) {
|
||||
eapMethodSpinnerAdapter = getSpinnerAdapter(R.array.wifi_eap_method);
|
||||
mEapMethodSpinner.setAdapter(eapMethodSpinnerAdapter);
|
||||
// WAP3-Enterprise 192-bit only allows EAP method TLS
|
||||
mEapMethodSpinner.setSelection(Eap.TLS);
|
||||
mEapMethodSpinner.setEnabled(false);
|
||||
} else if (Utils.isWifiOnly(mContext) || !mContext.getResources().getBoolean(
|
||||
com.android.internal.R.bool.config_eap_sim_based_auth_supported)) {
|
||||
eapMethodSpinnerAdapter = getSpinnerAdapter(
|
||||
R.array.eap_method_without_sim_auth);
|
||||
mEapMethodSpinner.setAdapter(eapMethodSpinnerAdapter);
|
||||
mEapMethodSpinner.setEnabled(true);
|
||||
} else {
|
||||
eapMethodSpinnerAdapter = getSpinnerAdapter(R.array.wifi_eap_method);
|
||||
mEapMethodSpinner.setAdapter(eapMethodSpinnerAdapter);
|
||||
mEapMethodSpinner.setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
if (mAccessPointSecurity != AccessPoint.SECURITY_EAP_SUITE_B
|
||||
&& mAccessPoint != null
|
||||
&& mAccessPoint.isCarrierAp()) {
|
||||
mEapMethodSpinner.setSelection(mAccessPoint.getCarrierApEapType());
|
||||
}
|
||||
|
||||
if (refreshCertificates) {
|
||||
loadCertificates(
|
||||
mEapCaCertSpinner,
|
||||
Credentials.CA_CERTIFICATE,
|
||||
@@ -1025,76 +1044,73 @@ public class WifiConfigController implements TextWatcher,
|
||||
mDoNotProvideEapUserCertString,
|
||||
false,
|
||||
false);
|
||||
}
|
||||
|
||||
// Modifying an existing network
|
||||
if (mAccessPoint != null && mAccessPoint.isSaved()) {
|
||||
WifiEnterpriseConfig enterpriseConfig = mAccessPoint.getConfig().enterpriseConfig;
|
||||
int eapMethod = enterpriseConfig.getEapMethod();
|
||||
int phase2Method = enterpriseConfig.getPhase2Method();
|
||||
mEapMethodSpinner.setSelection(eapMethod);
|
||||
showEapFieldsByMethod(eapMethod);
|
||||
switch (eapMethod) {
|
||||
case Eap.PEAP:
|
||||
switch (phase2Method) {
|
||||
case Phase2.NONE:
|
||||
mPhase2Spinner.setSelection(WIFI_PEAP_PHASE2_NONE);
|
||||
break;
|
||||
case Phase2.MSCHAPV2:
|
||||
mPhase2Spinner.setSelection(WIFI_PEAP_PHASE2_MSCHAPV2);
|
||||
break;
|
||||
case Phase2.GTC:
|
||||
mPhase2Spinner.setSelection(WIFI_PEAP_PHASE2_GTC);
|
||||
break;
|
||||
case Phase2.SIM:
|
||||
mPhase2Spinner.setSelection(WIFI_PEAP_PHASE2_SIM);
|
||||
break;
|
||||
case Phase2.AKA:
|
||||
mPhase2Spinner.setSelection(WIFI_PEAP_PHASE2_AKA);
|
||||
break;
|
||||
case Phase2.AKA_PRIME:
|
||||
mPhase2Spinner.setSelection(WIFI_PEAP_PHASE2_AKA_PRIME);
|
||||
break;
|
||||
default:
|
||||
Log.e(TAG, "Invalid phase 2 method " + phase2Method);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
mPhase2Spinner.setSelection(phase2Method);
|
||||
break;
|
||||
}
|
||||
if (!TextUtils.isEmpty(enterpriseConfig.getCaPath())) {
|
||||
setSelection(mEapCaCertSpinner, mUseSystemCertsString);
|
||||
} else {
|
||||
String[] caCerts = enterpriseConfig.getCaCertificateAliases();
|
||||
if (caCerts == null) {
|
||||
setSelection(mEapCaCertSpinner, mDoNotValidateEapServerString);
|
||||
} else if (caCerts.length == 1) {
|
||||
setSelection(mEapCaCertSpinner, caCerts[0]);
|
||||
} else {
|
||||
// Reload the cert spinner with an extra "multiple certificates added" item.
|
||||
loadCertificates(
|
||||
mEapCaCertSpinner,
|
||||
Credentials.CA_CERTIFICATE,
|
||||
mDoNotValidateEapServerString,
|
||||
true,
|
||||
true);
|
||||
setSelection(mEapCaCertSpinner, mMultipleCertSetString);
|
||||
// Modifying an existing network
|
||||
if (initiateEnterpriseNetworkUi && mAccessPoint != null && mAccessPoint.isSaved()) {
|
||||
final WifiEnterpriseConfig enterpriseConfig = mAccessPoint.getConfig().enterpriseConfig;
|
||||
final int eapMethod = enterpriseConfig.getEapMethod();
|
||||
final int phase2Method = enterpriseConfig.getPhase2Method();
|
||||
mEapMethodSpinner.setSelection(eapMethod);
|
||||
showEapFieldsByMethod(eapMethod);
|
||||
switch (eapMethod) {
|
||||
case Eap.PEAP:
|
||||
switch (phase2Method) {
|
||||
case Phase2.NONE:
|
||||
mPhase2Spinner.setSelection(WIFI_PEAP_PHASE2_NONE);
|
||||
break;
|
||||
case Phase2.MSCHAPV2:
|
||||
mPhase2Spinner.setSelection(WIFI_PEAP_PHASE2_MSCHAPV2);
|
||||
break;
|
||||
case Phase2.GTC:
|
||||
mPhase2Spinner.setSelection(WIFI_PEAP_PHASE2_GTC);
|
||||
break;
|
||||
case Phase2.SIM:
|
||||
mPhase2Spinner.setSelection(WIFI_PEAP_PHASE2_SIM);
|
||||
break;
|
||||
case Phase2.AKA:
|
||||
mPhase2Spinner.setSelection(WIFI_PEAP_PHASE2_AKA);
|
||||
break;
|
||||
case Phase2.AKA_PRIME:
|
||||
mPhase2Spinner.setSelection(WIFI_PEAP_PHASE2_AKA_PRIME);
|
||||
break;
|
||||
default:
|
||||
Log.e(TAG, "Invalid phase 2 method " + phase2Method);
|
||||
break;
|
||||
}
|
||||
}
|
||||
mEapDomainView.setText(enterpriseConfig.getDomainSuffixMatch());
|
||||
String userCert = enterpriseConfig.getClientCertificateAlias();
|
||||
if (TextUtils.isEmpty(userCert)) {
|
||||
setSelection(mEapUserCertSpinner, mDoNotProvideEapUserCertString);
|
||||
} else {
|
||||
setSelection(mEapUserCertSpinner, userCert);
|
||||
}
|
||||
mEapIdentityView.setText(enterpriseConfig.getIdentity());
|
||||
mEapAnonymousView.setText(enterpriseConfig.getAnonymousIdentity());
|
||||
} else {
|
||||
mPhase2Spinner = (Spinner) mView.findViewById(R.id.phase2);
|
||||
showEapFieldsByMethod(mEapMethodSpinner.getSelectedItemPosition());
|
||||
break;
|
||||
default:
|
||||
mPhase2Spinner.setSelection(phase2Method);
|
||||
break;
|
||||
}
|
||||
if (!TextUtils.isEmpty(enterpriseConfig.getCaPath())) {
|
||||
setSelection(mEapCaCertSpinner, mUseSystemCertsString);
|
||||
} else {
|
||||
final String[] caCerts = enterpriseConfig.getCaCertificateAliases();
|
||||
if (caCerts == null) {
|
||||
setSelection(mEapCaCertSpinner, mDoNotValidateEapServerString);
|
||||
} else if (caCerts.length == 1) {
|
||||
setSelection(mEapCaCertSpinner, caCerts[0]);
|
||||
} else {
|
||||
// Reload the cert spinner with an extra "multiple certificates added" item.
|
||||
loadCertificates(
|
||||
mEapCaCertSpinner,
|
||||
Credentials.CA_CERTIFICATE,
|
||||
mDoNotValidateEapServerString,
|
||||
true,
|
||||
true);
|
||||
setSelection(mEapCaCertSpinner, mMultipleCertSetString);
|
||||
}
|
||||
}
|
||||
mEapDomainView.setText(enterpriseConfig.getDomainSuffixMatch());
|
||||
final String userCert = enterpriseConfig.getClientCertificateAlias();
|
||||
if (TextUtils.isEmpty(userCert)) {
|
||||
setSelection(mEapUserCertSpinner, mDoNotProvideEapUserCertString);
|
||||
} else {
|
||||
setSelection(mEapUserCertSpinner, userCert);
|
||||
}
|
||||
mEapIdentityView.setText(enterpriseConfig.getIdentity());
|
||||
mEapAnonymousView.setText(enterpriseConfig.getAnonymousIdentity());
|
||||
} else {
|
||||
showEapFieldsByMethod(mEapMethodSpinner.getSelectedItemPosition());
|
||||
}
|
||||
@@ -1389,7 +1405,18 @@ public class WifiConfigController implements TextWatcher,
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "can't get the certificate list from KeyStore");
|
||||
}
|
||||
certs.add(noCertificateString);
|
||||
|
||||
if (mAccessPointSecurity != AccessPoint.SECURITY_EAP_SUITE_B) {
|
||||
certs.add(noCertificateString);
|
||||
}
|
||||
|
||||
// If there are only mUnspecifiedCertString and one item to select, only shows the item
|
||||
if (certs.size() == 2) {
|
||||
certs.remove(mUnspecifiedCertString);
|
||||
spinner.setEnabled(false);
|
||||
} else {
|
||||
spinner.setEnabled(true);
|
||||
}
|
||||
|
||||
final ArrayAdapter<String> adapter = new ArrayAdapter<String>(
|
||||
context, android.R.layout.simple_spinner_item,
|
||||
@@ -1486,15 +1513,17 @@ public class WifiConfigController implements TextWatcher,
|
||||
if (parent == mSecuritySpinner) {
|
||||
// Convert menu position to actual Wi-Fi security type
|
||||
mAccessPointSecurity = mSecurityInPosition[position];
|
||||
showSecurityFields();
|
||||
showSecurityFields(true /* refreshEapMethods */, true /* refreshCertificates */);
|
||||
|
||||
if (WifiDppUtils.isSupportEnrolleeQrCodeScanner(mContext, mAccessPointSecurity)) {
|
||||
mSsidScanButton.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
mSsidScanButton.setVisibility(View.GONE);
|
||||
}
|
||||
} else if (parent == mEapMethodSpinner || parent == mEapCaCertSpinner) {
|
||||
showSecurityFields();
|
||||
} else if (parent == mEapMethodSpinner) {
|
||||
showSecurityFields(false /* refreshEapMethods */, true /* refreshCertificates */);
|
||||
} else if (parent == mEapCaCertSpinner) {
|
||||
showSecurityFields(false /* refreshEapMethods */, false /* refreshCertificates */);
|
||||
} else if (parent == mPhase2Spinner
|
||||
&& mEapMethodSpinner.getSelectedItemPosition() == WIFI_EAP_METHOD_PEAP) {
|
||||
showPeapFields();
|
||||
@@ -1585,4 +1614,15 @@ public class WifiConfigController implements TextWatcher,
|
||||
((CheckBox) mView.findViewById(R.id.wifi_advanced_togglebox))
|
||||
.setOnCheckedChangeListener(this);
|
||||
}
|
||||
|
||||
private ArrayAdapter<CharSequence> getSpinnerAdapter(
|
||||
int contentStringArrayResId) {
|
||||
final String[] eapMethods = mContext.getResources().getStringArray(
|
||||
contentStringArrayResId);
|
||||
final ArrayAdapter<CharSequence> spinnerAdapter = new ArrayAdapter<>(mContext,
|
||||
android.R.layout.simple_spinner_item, eapMethods);
|
||||
spinnerAdapter.setDropDownViewResource(
|
||||
android.R.layout.simple_spinner_dropdown_item);
|
||||
return spinnerAdapter;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -390,7 +390,7 @@ public class WifiDppConfiguratorActivity extends InstrumentedActivity implements
|
||||
WifiDppUtils.getSecurityString(wifiConfiguration),
|
||||
wifiConfiguration.getPrintableSsid(),
|
||||
wifiConfiguration.preSharedKey,
|
||||
/* hiddenSsid */ false,
|
||||
wifiConfiguration.hiddenSSID,
|
||||
wifiConfiguration.networkId,
|
||||
/* isHotspot */ false);
|
||||
}
|
||||
|
||||
@@ -172,22 +172,25 @@ public class WifiDppQrCodeScannerFragment extends WifiDppQrCodeBaseFragment impl
|
||||
|
||||
// Adds all Wi-Fi networks in QR code to the set of configured networks and
|
||||
// connects to it if it's reachable.
|
||||
boolean hasReachableWifiNetwork = false;
|
||||
boolean hasHiddenOrReachableWifiNetwork = false;
|
||||
for (WifiConfiguration qrCodeWifiConfiguration : qrCodeWifiConfigurations) {
|
||||
final int id = wifiManager.addNetwork(qrCodeWifiConfiguration);
|
||||
if (id == -1) {
|
||||
continue;
|
||||
}
|
||||
wifiManager.enableNetwork(id, /* attemptConnect */ false);
|
||||
if (isReachableWifiNetwork(qrCodeWifiConfiguration)) {
|
||||
hasReachableWifiNetwork = true;
|
||||
// WifiTracker only contains a hidden SSID Wi-Fi network if it's saved.
|
||||
// We can't check if a hidden SSID Wi-Fi network is reachable in advance.
|
||||
if (qrCodeWifiConfiguration.hiddenSSID ||
|
||||
isReachableWifiNetwork(qrCodeWifiConfiguration)) {
|
||||
hasHiddenOrReachableWifiNetwork = true;
|
||||
mEnrolleeWifiConfiguration = qrCodeWifiConfiguration;
|
||||
wifiManager.connect(id,
|
||||
/* listener */ WifiDppQrCodeScannerFragment.this);
|
||||
}
|
||||
}
|
||||
|
||||
if (hasReachableWifiNetwork == false) {
|
||||
if (!hasHiddenOrReachableWifiNetwork) {
|
||||
showErrorMessageAndRestartCamera(
|
||||
R.string.wifi_dpp_check_connection_try_again);
|
||||
return;
|
||||
|
||||
@@ -296,6 +296,7 @@ public class WifiDppUtils {
|
||||
if (!TextUtils.isEmpty(preSharedKey)) {
|
||||
intent.putExtra(EXTRA_WIFI_PRE_SHARED_KEY, preSharedKey);
|
||||
}
|
||||
intent.putExtra(EXTRA_WIFI_HIDDEN_SSID, wifiConfiguration.hiddenSSID);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -220,7 +220,7 @@ public class WifiNetworkListFragment extends SettingsPreferenceFragment implemen
|
||||
}
|
||||
final WifiNetworkConfig networkConfig = WifiNetworkConfig.getValidConfigOrNull(
|
||||
selectedAccessPoint.getSecurityString(/* concise */ true),
|
||||
wifiConfig.getPrintableSsid(), wifiConfig.preSharedKey, /* hiddenSsid */ false,
|
||||
wifiConfig.getPrintableSsid(), wifiConfig.preSharedKey, wifiConfig.hiddenSSID,
|
||||
wifiConfig.networkId, /* isHotspot */ false);
|
||||
if (mOnChooseNetworkListener != null) {
|
||||
mOnChooseNetworkListener.onChooseNetwork(networkConfig);
|
||||
|
||||
Reference in New Issue
Block a user