Fix the bug of losing Wi-Fi certificate when editing

- When the saved certificate is loaded into the UI, the EAP method
spinner will trigger a redundant item selection event to refresh the
certificate to the default value.

- Filter out redundant item selection event of the EAP method spinner.

- Analysis report:
  https://docs.google.com/document/d/1uzyO0NQsT0PVT-ZKbWtDTt4KRXvm3L994MmZTXZ4d5Y/edit?usp=sharing

Bug: 161569880
Test: make RunSettingsRoboTests
ROBOTEST_FILTER=WifiConfigController2Test
Merged-In: I947fb7668ffa7e9ed8c150fe14e6ae9d7a67393c
Change-Id: I00b73b4bfc078aca37396aab4c802a3de64318cf
This commit is contained in:
Weng Su
2020-11-09 06:33:59 +08:00
parent a759432bac
commit 224948fd7e
2 changed files with 93 additions and 1 deletions

View File

@@ -164,6 +164,7 @@ public class WifiConfigController2 implements TextWatcher,
private ScrollView mDialogContainer;
private Spinner mSecuritySpinner;
@VisibleForTesting Spinner mEapMethodSpinner;
private int mLastShownEapMethod;
@VisibleForTesting Spinner mEapSimSpinner; // For EAP-SIM, EAP-AKA and EAP-AKA-PRIME.
private Spinner mEapCaCertSpinner;
private Spinner mEapOcspSpinner;
@@ -1057,6 +1058,7 @@ public class WifiConfigController2 implements TextWatcher,
final int eapMethod = enterpriseConfig.getEapMethod();
final int phase2Method = enterpriseConfig.getPhase2Method();
mEapMethodSpinner.setSelection(eapMethod);
mLastShownEapMethod = eapMethod;
showEapFieldsByMethod(eapMethod);
switch (eapMethod) {
case Eap.PEAP:
@@ -1627,7 +1629,11 @@ public class WifiConfigController2 implements TextWatcher,
mSsidScanButton.setVisibility(View.GONE);
}
} else if (parent == mEapMethodSpinner) {
showSecurityFields(/* refreshEapMethods */ false, /* refreshCertificates */ true);
final int selectedItemPosition = mEapMethodSpinner.getSelectedItemPosition();
if (mLastShownEapMethod != selectedItemPosition) {
mLastShownEapMethod = selectedItemPosition;
showSecurityFields(/* refreshEapMethods */ false, /* refreshCertificates */ true);
}
} else if (parent == mEapCaCertSpinner) {
showSecurityFields(/* refreshEapMethods */ false, /* refreshCertificates */ false);
} else if (parent == mPhase2Spinner