Merge "[Wi-Fi] Force users to select a phase2 authentication for PEAP & TTLS" into qt-qpr1-dev am: 594a5c71f5

Change-Id: Ifeeb244d4dddebb4b05b4a7489d0fb28a195c4ad
This commit is contained in:
Automerger Merge Worker
2020-02-28 06:16:40 +00:00
4 changed files with 83 additions and 38 deletions

View File

@@ -113,18 +113,22 @@ public class WifiConfigController implements TextWatcher,
public static final int WIFI_EAP_METHOD_AKA_PRIME = 6;
/* These values come from "wifi_peap_phase2_entries" resource array */
public static final int WIFI_PEAP_PHASE2_NONE = 0;
public static final int WIFI_PEAP_PHASE2_MSCHAPV2 = 1;
public static final int WIFI_PEAP_PHASE2_GTC = 2;
public static final int WIFI_PEAP_PHASE2_SIM = 3;
public static final int WIFI_PEAP_PHASE2_AKA = 4;
public static final int WIFI_PEAP_PHASE2_AKA_PRIME = 5;
public static final int WIFI_PEAP_PHASE2_MSCHAPV2 = 0;
public static final int WIFI_PEAP_PHASE2_GTC = 1;
public static final int WIFI_PEAP_PHASE2_SIM = 2;
public static final int WIFI_PEAP_PHASE2_AKA = 3;
public static final int WIFI_PEAP_PHASE2_AKA_PRIME = 4;
/* These values come from "wifi_ttls_phase2_entries" resource array */
public static final int WIFI_TTLS_PHASE2_PAP = 0;
public static final int WIFI_TTLS_PHASE2_MSCHAP = 1;
public static final int WIFI_TTLS_PHASE2_MSCHAPV2 = 2;
public static final int WIFI_TTLS_PHASE2_GTC = 3;
/* Phase2 methods supported by PEAP are limited */
private ArrayAdapter<String> mPhase2PeapAdapter;
/* Full list of phase2 methods */
private ArrayAdapter<String> mPhase2FullAdapter;
private ArrayAdapter<CharSequence> mPhase2PeapAdapter;
/* Phase2 methods supported by TTLS are limited */
private ArrayAdapter<CharSequence> mPhase2TtlsAdapter;
// e.g. AccessPoint.SECURITY_NONE
@VisibleForTesting
@@ -145,8 +149,8 @@ public class WifiConfigController implements TextWatcher,
private Spinner mEapCaCertSpinner;
private TextView mEapDomainView;
private Spinner mPhase2Spinner;
// Associated with mPhase2Spinner, one of mPhase2FullAdapter or mPhase2PeapAdapter
private ArrayAdapter<String> mPhase2Adapter;
// Associated with mPhase2Spinner, one of mPhase2TtlsAdapter or mPhase2PeapAdapter
private ArrayAdapter<CharSequence> mPhase2Adapter;
private Spinner mEapUserCertSpinner;
private TextView mEapIdentityView;
private TextView mEapAnonymousView;
@@ -221,20 +225,20 @@ public class WifiConfigController implements TextWatcher,
mLevels = res.getStringArray(R.array.wifi_signal);
if (Utils.isWifiOnly(mContext) || !mContext.getResources().getBoolean(
com.android.internal.R.bool.config_eap_sim_based_auth_supported)) {
mPhase2PeapAdapter = new ArrayAdapter<String>(
mPhase2PeapAdapter = new ArrayAdapter<CharSequence>(
mContext, android.R.layout.simple_spinner_item,
res.getStringArray(R.array.wifi_peap_phase2_entries));
} else {
mPhase2PeapAdapter = new ArrayAdapter<String>(
mPhase2PeapAdapter = new ArrayAdapter<CharSequence>(
mContext, android.R.layout.simple_spinner_item,
res.getStringArray(R.array.wifi_peap_phase2_entries_with_sim_auth));
}
mPhase2PeapAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
mPhase2FullAdapter = new ArrayAdapter<String>(
mPhase2TtlsAdapter = new ArrayAdapter<CharSequence>(
mContext, android.R.layout.simple_spinner_item,
res.getStringArray(R.array.wifi_phase2_entries));
mPhase2FullAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
res.getStringArray(R.array.wifi_ttls_phase2_entries));
mPhase2TtlsAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
mUnspecifiedCertString = mContext.getString(R.string.wifi_unspecified);
mMultipleCertSetString = mContext.getString(R.string.wifi_multiple_cert_added);
@@ -662,9 +666,6 @@ public class WifiConfigController implements TextWatcher,
// Map the index from the mPhase2PeapAdapter to the one used
// by the API which has the full list of PEAP methods.
switch(phase2Method) {
case WIFI_PEAP_PHASE2_NONE:
config.enterpriseConfig.setPhase2Method(Phase2.NONE);
break;
case WIFI_PEAP_PHASE2_MSCHAPV2:
config.enterpriseConfig.setPhase2Method(Phase2.MSCHAPV2);
break;
@@ -685,9 +686,27 @@ public class WifiConfigController implements TextWatcher,
break;
}
break;
case Eap.TTLS:
// The default index from mPhase2TtlsAdapter maps to the API
switch(phase2Method) {
case WIFI_TTLS_PHASE2_PAP:
config.enterpriseConfig.setPhase2Method(Phase2.PAP);
break;
case WIFI_TTLS_PHASE2_MSCHAP:
config.enterpriseConfig.setPhase2Method(Phase2.MSCHAP);
break;
case WIFI_TTLS_PHASE2_MSCHAPV2:
config.enterpriseConfig.setPhase2Method(Phase2.MSCHAPV2);
break;
case WIFI_TTLS_PHASE2_GTC:
config.enterpriseConfig.setPhase2Method(Phase2.GTC);
break;
default:
Log.e(TAG, "Unknown phase2 method" + phase2Method);
break;
}
break;
default:
// The default index from mPhase2FullAdapter maps to the API
config.enterpriseConfig.setPhase2Method(phase2Method);
break;
}
@@ -1024,9 +1043,6 @@ public class WifiConfigController implements TextWatcher,
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;
@@ -1047,8 +1063,26 @@ public class WifiConfigController implements TextWatcher,
break;
}
break;
case Eap.TTLS:
switch (phase2Method) {
case Phase2.PAP:
mPhase2Spinner.setSelection(WIFI_TTLS_PHASE2_PAP);
break;
case Phase2.MSCHAP:
mPhase2Spinner.setSelection(WIFI_TTLS_PHASE2_MSCHAP);
break;
case Phase2.MSCHAPV2:
mPhase2Spinner.setSelection(WIFI_TTLS_PHASE2_MSCHAPV2);
break;
case Phase2.GTC:
mPhase2Spinner.setSelection(WIFI_TTLS_PHASE2_GTC);
break;
default:
Log.e(TAG, "Invalid phase 2 method " + phase2Method);
break;
}
break;
default:
mPhase2Spinner.setSelection(phase2Method);
break;
}
if (!TextUtils.isEmpty(enterpriseConfig.getCaPath())) {
@@ -1146,8 +1180,8 @@ public class WifiConfigController implements TextWatcher,
break;
case WIFI_EAP_METHOD_TTLS:
// Reset adapter if needed
if (mPhase2Adapter != mPhase2FullAdapter) {
mPhase2Adapter = mPhase2FullAdapter;
if (mPhase2Adapter != mPhase2TtlsAdapter) {
mPhase2Adapter = mPhase2TtlsAdapter;
mPhase2Spinner.setAdapter(mPhase2Adapter);
}
mView.findViewById(R.id.l_phase2).setVisibility(View.VISIBLE);
@@ -1198,12 +1232,10 @@ public class WifiConfigController implements TextWatcher,
private void setIdentityInvisible() {
mView.findViewById(R.id.l_identity).setVisibility(View.GONE);
mPhase2Spinner.setSelection(Phase2.NONE);
}
private void setPhase2Invisible() {
mView.findViewById(R.id.l_phase2).setVisibility(View.GONE);
mPhase2Spinner.setSelection(Phase2.NONE);
}
private void setCaCertInvisible() {