diff --git a/src/com/android/settings/wifi/AccessPointDialog.java b/src/com/android/settings/wifi/AccessPointDialog.java index 7e516cc74bb..c4984cdebdd 100644 --- a/src/com/android/settings/wifi/AccessPointDialog.java +++ b/src/com/android/settings/wifi/AccessPointDialog.java @@ -134,7 +134,7 @@ public class AccessPointDialog extends AlertDialog implements DialogInterface.On private Spinner mSecuritySpinner; private Spinner mWepTypeSpinner; private CertTool mCertTool; - + public AccessPointDialog(Context context, WifiLayer wifiLayer) { super(context); @@ -217,6 +217,14 @@ public class AccessPointDialog extends AlertDialog implements DialogInterface.On setTitle(getContext().getString(titleId)); } + public void enableEnterpriseFields() { + setEnterpriseFieldsVisible(true); + updateCertificateSelection(); + setGenericPasswordVisible(true); + // Both WPA and WPA2 show the same caption, so either is ok + updatePasswordCaption(AccessPointState.WPA); + } + /** Called after flags are set, the dialog's layout/etc should be set up here */ private void onLayout() { final Context context = getContext(); @@ -318,19 +326,26 @@ public class AccessPointDialog extends AlertDialog implements DialogInterface.On if (mMode == MODE_CONFIGURE || (mState.isEnterprise() && !mState.configured)) { setEnterpriseFields(view); - mPhase2Spinner.setSelection(getSelectionIndex( - R.array.wifi_phase2_entries, mState.getPhase2())); - mEapSpinner.setSelection(getSelectionIndex( - R.array.wifi_eap_entries, mState.getEap())); - mClientCertSpinner.setSelection(getSelectionIndex( - getAllUserCertificateKeys(), mState.getEnterpriseField( - AccessPointState.CLIENT_CERT))); - mCaCertSpinner.setSelection(getSelectionIndex( - getAllCaCertificateKeys(), mState.getEnterpriseField( - AccessPointState.CA_CERT))); + updateCertificateSelection(); } } + private void updateCertificateSelection() { + setSpinnerAdapter(mClientCertSpinner, getAllUserCertificateKeys()); + setSpinnerAdapter(mCaCertSpinner, getAllCaCertificateKeys()); + + mPhase2Spinner.setSelection(getSelectionIndex( + R.array.wifi_phase2_entries, mState.getPhase2())); + mEapSpinner.setSelection(getSelectionIndex( + R.array.wifi_eap_entries, mState.getEap())); + mClientCertSpinner.setSelection(getSelectionIndex( + getAllUserCertificateKeys(), mState.getEnterpriseField( + AccessPointState.CLIENT_CERT))); + mCaCertSpinner.setSelection(getSelectionIndex( + getAllCaCertificateKeys(), mState.getEnterpriseField( + AccessPointState.CA_CERT))); + } + private String[] getAllCaCertificateKeys() { return appendEmptyInSelection(mCertTool.getAllCaCertificateKeys()); } @@ -788,13 +803,9 @@ public class AccessPointDialog extends AlertDialog implements DialogInterface.On if (Keystore.getInstance().getState() != Keystore.UNLOCKED) { getContext().startActivity(new Intent( SecuritySettings.ACTION_UNLOCK_CREDENTIAL_STORAGE)); - mSecuritySpinner.setSelection(0); return; } - setEnterpriseFieldsVisible(true); - setGenericPasswordVisible(true); - // Both WPA and WPA2 show the same caption, so either is ok - updatePasswordCaption(AccessPointState.WPA); + enableEnterpriseFields(); break; } } diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java index d283fb361d6..adf4519c38e 100644 --- a/src/com/android/settings/wifi/WifiSettings.java +++ b/src/com/android/settings/wifi/WifiSettings.java @@ -86,6 +86,9 @@ public class WifiSettings extends PreferenceActivity implements WifiLayer.Callba private Preference mAddOtherNetwork; private WeakHashMap mAps; + + private AccessPointState mResumeState = null; + private int mResumeMode; //============================ // Wifi member variables @@ -152,8 +155,22 @@ public class WifiSettings extends PreferenceActivity implements WifiLayer.Callba super.onResume(); mWifiLayer.onResume(); mWifiEnabler.resume(); + // do what we should have after keystore is unlocked. + if (mResumeState != null) { + if (Keystore.getInstance().getState() == Keystore.UNLOCKED) { + showAccessPointDialog(mResumeState, mResumeMode); + } + mResumeMode = -1; + mResumeState = null; + } else { + if (mResumeMode == AccessPointDialog.MODE_CONFIGURE) { + if (Keystore.getInstance().getState() == Keystore.UNLOCKED) { + ((AccessPointDialog) mDialog).enableEnterpriseFields(); + } + } + } } - + @Override protected void onPause() { super.onPause(); @@ -231,6 +248,7 @@ public class WifiSettings extends PreferenceActivity implements WifiLayer.Callba public void onDismiss(DialogInterface dialog) { if (dialog == mDialog) { mDialog = null; + mResumeMode = -1; } } @@ -350,6 +368,7 @@ public class WifiSettings extends PreferenceActivity implements WifiLayer.Callba dialog.setMode(AccessPointDialog.MODE_CONFIGURE); dialog.setTitle(R.string.wifi_add_other_network); dialog.setAutoSecurityAllowed(false); + mResumeMode = AccessPointDialog.MODE_CONFIGURE; showDialog(dialog); } @@ -358,6 +377,8 @@ public class WifiSettings extends PreferenceActivity implements WifiLayer.Callba Keystore.getInstance().getState() != Keystore.UNLOCKED) { startActivity(new Intent( SecuritySettings.ACTION_UNLOCK_CREDENTIAL_STORAGE)); + mResumeState = state; + mResumeMode = mode; return; } AccessPointDialog dialog = new AccessPointDialog(this, mWifiLayer);