diff --git a/res/values/strings.xml b/res/values/strings.xml index 06057e70265..847e879d70b 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -2012,6 +2012,10 @@ found in the list of installed applications. Enter the credential storage password. + + Install from SD card + + Install encrypted certificates from SD card Set password @@ -2052,7 +2056,7 @@ found in the list of installed applications. Passwords do not match. You must enter and confirm a password. Please enter the password. - Please enter the password again. The password must have at least 8 characters and must not contain spaces. + Please enter the password again. The password must have at least 8 characters. Please enter a name. Please enter a name that contains only letters and numbers. Unable to save the certificate. Click OK to retry. diff --git a/src/com/android/settings/SecuritySettings.java b/src/com/android/settings/SecuritySettings.java index 677432c9e2d..f3c53cea381 100644 --- a/src/com/android/settings/SecuritySettings.java +++ b/src/com/android/settings/SecuritySettings.java @@ -87,10 +87,6 @@ public class SecuritySettings extends PreferenceActivity implements private static final String ASSISTED_GPS = "assisted_gps"; // Credential storage - public static final String ACTION_ADD_CREDENTIAL = - "android.security.ADD_CREDENTIAL"; - public static final String ACTION_UNLOCK_CREDENTIAL_STORAGE = - "android.security.UNLOCK_CREDENTIAL_STORAGE"; private static final String KEY_CSTOR_TYPE_NAME = "typeName"; private static final String KEY_CSTOR_ITEM = "item"; private static final String KEY_CSTOR_NAMESPACE = "namespace"; @@ -240,10 +236,10 @@ public class SecuritySettings extends PreferenceActivity implements PreferenceCategory credStoreCat = new PreferenceCategory(this); credStoreCat.setTitle(R.string.cstor_settings_category); root.addPreference(credStoreCat); - int s = mCstorHelper.getCstorState(); - credStoreCat.addPreference(mCstorHelper.createAccessCheckBox(s)); + credStoreCat.addPreference(mCstorHelper.createAccessCheckBox()); + credStoreCat.addPreference(mCstorHelper.createCertInstallPreference()); credStoreCat.addPreference(mCstorHelper.createSetPasswordPreference()); - credStoreCat.addPreference(mCstorHelper.createResetPreference(s)); + credStoreCat.addPreference(mCstorHelper.createResetPreference()); return root; } @@ -269,6 +265,8 @@ public class SecuritySettings extends PreferenceActivity implements mShowPassword .setChecked(Settings.System.getInt(getContentResolver(), Settings.System.TEXT_SHOW_PASSWORD, 1) != 0); + + mCstorHelper.resumeStates(); } @Override @@ -504,10 +502,12 @@ public class SecuritySettings extends PreferenceActivity implements if (intent == null) return; String action = intent.getAction(); - if (ACTION_ADD_CREDENTIAL.equals(action)) { - mCstorAddCredentialHelper = new CstorAddCredentialHelper(intent); + if (CertTool.ACTION_ADD_CREDENTIAL.equals(action)) { + mCstorAddCredentialHelper = + new CstorAddCredentialHelper(intent); showCstorDialog(CSTOR_NAME_CREDENTIAL_DIALOG); - } else if (ACTION_UNLOCK_CREDENTIAL_STORAGE.equals(action)) { + } else if (Keystore.ACTION_UNLOCK_CREDENTIAL_STORAGE.equals( + action)) { mSpecialIntent = intent; showCstorDialog(mCstorHelper.isCstorInitialized() ? CSTOR_UNLOCK_DIALOG @@ -515,6 +515,13 @@ public class SecuritySettings extends PreferenceActivity implements } } + void resumeStates() { + int state = mCstorHelper.getCstorState(); + mAccessCheckBox.setEnabled(state != Keystore.UNINITIALIZED); + mAccessCheckBox.setChecked(state == Keystore.UNLOCKED); + mResetButton.setEnabled(state != Keystore.UNINITIALIZED); + } + private void showCstorDialog(int dialogId) { mDialogId = dialogId; showDialog(dialogId); @@ -732,8 +739,7 @@ public class SecuritySettings extends PreferenceActivity implements if (passwd == null) { showError(R.string.cstor_passwords_empty_error); return false; - } else if ((passwd.length() < CSTOR_MIN_PASSWORD_LENGTH) - || passwd.contains(" ")) { + } else if (passwd.length() < CSTOR_MIN_PASSWORD_LENGTH) { showError(R.string.cstor_password_verification_error); return false; } else { @@ -803,6 +809,11 @@ public class SecuritySettings extends PreferenceActivity implements } } + private void installCertFromSdCard() { + // TODO: uncomment this when the feature is ready + //startActivity(new Intent(CertTool.ACTION_INSTALL_CERT_FROM_SDCARD)); + } + private TextView showError(int messageId) { TextView v = (TextView) mView.findViewById(R.id.cstor_error); v.setText(messageId); @@ -838,13 +849,11 @@ public class SecuritySettings extends PreferenceActivity implements mResetButton.setEnabled(enabled); } - private Preference createAccessCheckBox(int state) { + private Preference createAccessCheckBox() { CheckBoxPreference pref = new CheckBoxPreference( SecuritySettings.this); pref.setTitle(R.string.cstor_access_title); pref.setSummary(R.string.cstor_access_summary); - pref.setEnabled(state != Keystore.UNINITIALIZED); - pref.setChecked(state == Keystore.UNLOCKED); pref.setOnPreferenceChangeListener( new Preference.OnPreferenceChangeListener() { public boolean onPreferenceChange( @@ -861,6 +870,20 @@ public class SecuritySettings extends PreferenceActivity implements return pref; } + private Preference createCertInstallPreference() { + Preference pref = new Preference(SecuritySettings.this); + pref.setTitle(R.string.cstor_cert_install_title); + pref.setSummary(R.string.cstor_cert_install_summary); + pref.setOnPreferenceClickListener( + new Preference.OnPreferenceClickListener() { + public boolean onPreferenceClick(Preference pref) { + installCertFromSdCard(); + return true; + } + }); + return pref; + } + private Preference createSetPasswordPreference() { Preference pref = new Preference(SecuritySettings.this); pref.setTitle(R.string.cstor_set_passwd_title); @@ -877,7 +900,7 @@ public class SecuritySettings extends PreferenceActivity implements return pref; } - private Preference createResetPreference(int state) { + private Preference createResetPreference() { Preference pref = new Preference(SecuritySettings.this); pref.setTitle(R.string.cstor_reset_title); pref.setSummary(R.string.cstor_reset_summary); @@ -888,7 +911,6 @@ public class SecuritySettings extends PreferenceActivity implements return true; } }); - pref.setEnabled(state != Keystore.UNINITIALIZED); mResetButton = pref; return pref; } diff --git a/src/com/android/settings/vpn/VpnSettings.java b/src/com/android/settings/vpn/VpnSettings.java index 61b270184c5..eea0aca5c96 100644 --- a/src/com/android/settings/vpn/VpnSettings.java +++ b/src/com/android/settings/vpn/VpnSettings.java @@ -652,7 +652,7 @@ public class VpnSettings extends PreferenceActivity implements if (isKeystoreUnlocked()) return true; mUnlockAction = action; startActivity( - new Intent(SecuritySettings.ACTION_UNLOCK_CREDENTIAL_STORAGE)); + new Intent(Keystore.ACTION_UNLOCK_CREDENTIAL_STORAGE)); return false; } diff --git a/src/com/android/settings/wifi/AccessPointDialog.java b/src/com/android/settings/wifi/AccessPointDialog.java index c4984cdebdd..ce7ce9293d9 100644 --- a/src/com/android/settings/wifi/AccessPointDialog.java +++ b/src/com/android/settings/wifi/AccessPointDialog.java @@ -17,7 +17,6 @@ package com.android.settings.wifi; import com.android.settings.R; -import com.android.settings.SecuritySettings; import android.app.AlertDialog; import android.content.Context; @@ -802,7 +801,7 @@ public class AccessPointDialog extends AlertDialog implements DialogInterface.On // Unlock the keystore if it is not unlocked yet. if (Keystore.getInstance().getState() != Keystore.UNLOCKED) { getContext().startActivity(new Intent( - SecuritySettings.ACTION_UNLOCK_CREDENTIAL_STORAGE)); + Keystore.ACTION_UNLOCK_CREDENTIAL_STORAGE)); return; } enableEnterpriseFields(); diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java index adf4519c38e..4aa5dc35191 100644 --- a/src/com/android/settings/wifi/WifiSettings.java +++ b/src/com/android/settings/wifi/WifiSettings.java @@ -18,7 +18,6 @@ package com.android.settings.wifi; import com.android.settings.ProgressCategory; import com.android.settings.R; -import com.android.settings.SecuritySettings; import android.app.Dialog; import android.content.DialogInterface; @@ -376,7 +375,7 @@ public class WifiSettings extends PreferenceActivity implements WifiLayer.Callba if (state.isEnterprise() && Keystore.getInstance().getState() != Keystore.UNLOCKED) { startActivity(new Intent( - SecuritySettings.ACTION_UNLOCK_CREDENTIAL_STORAGE)); + Keystore.ACTION_UNLOCK_CREDENTIAL_STORAGE)); mResumeState = state; mResumeMode = mode; return;