Add install-cert-from-sdcard in Security settings
Also: * Resume keystore states in SecuritySettings.onResume(). * Use action strings defined in CertTool and Keystore.
This commit is contained in:
@@ -2012,6 +2012,10 @@ found in the list of installed applications.</string>
|
|||||||
<!-- Description of dialog to enable/dislable access to credential storage from an action that requires the credential storage -->
|
<!-- Description of dialog to enable/dislable access to credential storage from an action that requires the credential storage -->
|
||||||
<string name="cstor_access_dialog_hint_from_action">Enter the credential storage password.</string>
|
<string name="cstor_access_dialog_hint_from_action">Enter the credential storage password.</string>
|
||||||
|
|
||||||
|
<!-- Title of preference to install p12 cert from SD card -->
|
||||||
|
<string name="cstor_cert_install_title">Install from SD card</string>
|
||||||
|
<!-- Summary of preference to install p12 cert from SD card -->
|
||||||
|
<string name="cstor_cert_install_summary">Install encrypted certificates from SD card</string>
|
||||||
<!-- Title of preference to set storage password -->
|
<!-- Title of preference to set storage password -->
|
||||||
<string name="cstor_set_passwd_title">Set password</string>
|
<string name="cstor_set_passwd_title">Set password</string>
|
||||||
<!-- Summary of preference to set storage password -->
|
<!-- Summary of preference to set storage password -->
|
||||||
@@ -2052,7 +2056,7 @@ found in the list of installed applications.</string>
|
|||||||
<string name="cstor_passwords_error">Passwords do not match.</string>
|
<string name="cstor_passwords_error">Passwords do not match.</string>
|
||||||
<string name="cstor_passwords_empty_error">You must enter and confirm a password.</string>
|
<string name="cstor_passwords_empty_error">You must enter and confirm a password.</string>
|
||||||
<string name="cstor_password_empty_error">Please enter the password.</string>
|
<string name="cstor_password_empty_error">Please enter the password.</string>
|
||||||
<string name="cstor_password_verification_error">Please enter the password again. The password must have at least 8 characters and must not contain spaces.</string>
|
<string name="cstor_password_verification_error">Please enter the password again. The password must have at least 8 characters.</string>
|
||||||
<string name="cstor_name_empty_error">Please enter a name.</string>
|
<string name="cstor_name_empty_error">Please enter a name.</string>
|
||||||
<string name="cstor_name_char_error">Please enter a name that contains only letters and numbers.</string>
|
<string name="cstor_name_char_error">Please enter a name that contains only letters and numbers.</string>
|
||||||
<string name="cstor_storage_error">Unable to save the certificate. Click OK to retry.</string>
|
<string name="cstor_storage_error">Unable to save the certificate. Click OK to retry.</string>
|
||||||
|
@@ -87,10 +87,6 @@ public class SecuritySettings extends PreferenceActivity implements
|
|||||||
private static final String ASSISTED_GPS = "assisted_gps";
|
private static final String ASSISTED_GPS = "assisted_gps";
|
||||||
|
|
||||||
// Credential storage
|
// 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_TYPE_NAME = "typeName";
|
||||||
private static final String KEY_CSTOR_ITEM = "item";
|
private static final String KEY_CSTOR_ITEM = "item";
|
||||||
private static final String KEY_CSTOR_NAMESPACE = "namespace";
|
private static final String KEY_CSTOR_NAMESPACE = "namespace";
|
||||||
@@ -240,10 +236,10 @@ public class SecuritySettings extends PreferenceActivity implements
|
|||||||
PreferenceCategory credStoreCat = new PreferenceCategory(this);
|
PreferenceCategory credStoreCat = new PreferenceCategory(this);
|
||||||
credStoreCat.setTitle(R.string.cstor_settings_category);
|
credStoreCat.setTitle(R.string.cstor_settings_category);
|
||||||
root.addPreference(credStoreCat);
|
root.addPreference(credStoreCat);
|
||||||
int s = mCstorHelper.getCstorState();
|
credStoreCat.addPreference(mCstorHelper.createAccessCheckBox());
|
||||||
credStoreCat.addPreference(mCstorHelper.createAccessCheckBox(s));
|
credStoreCat.addPreference(mCstorHelper.createCertInstallPreference());
|
||||||
credStoreCat.addPreference(mCstorHelper.createSetPasswordPreference());
|
credStoreCat.addPreference(mCstorHelper.createSetPasswordPreference());
|
||||||
credStoreCat.addPreference(mCstorHelper.createResetPreference(s));
|
credStoreCat.addPreference(mCstorHelper.createResetPreference());
|
||||||
|
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
@@ -269,6 +265,8 @@ public class SecuritySettings extends PreferenceActivity implements
|
|||||||
mShowPassword
|
mShowPassword
|
||||||
.setChecked(Settings.System.getInt(getContentResolver(),
|
.setChecked(Settings.System.getInt(getContentResolver(),
|
||||||
Settings.System.TEXT_SHOW_PASSWORD, 1) != 0);
|
Settings.System.TEXT_SHOW_PASSWORD, 1) != 0);
|
||||||
|
|
||||||
|
mCstorHelper.resumeStates();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -504,10 +502,12 @@ public class SecuritySettings extends PreferenceActivity implements
|
|||||||
if (intent == null) return;
|
if (intent == null) return;
|
||||||
String action = intent.getAction();
|
String action = intent.getAction();
|
||||||
|
|
||||||
if (ACTION_ADD_CREDENTIAL.equals(action)) {
|
if (CertTool.ACTION_ADD_CREDENTIAL.equals(action)) {
|
||||||
mCstorAddCredentialHelper = new CstorAddCredentialHelper(intent);
|
mCstorAddCredentialHelper =
|
||||||
|
new CstorAddCredentialHelper(intent);
|
||||||
showCstorDialog(CSTOR_NAME_CREDENTIAL_DIALOG);
|
showCstorDialog(CSTOR_NAME_CREDENTIAL_DIALOG);
|
||||||
} else if (ACTION_UNLOCK_CREDENTIAL_STORAGE.equals(action)) {
|
} else if (Keystore.ACTION_UNLOCK_CREDENTIAL_STORAGE.equals(
|
||||||
|
action)) {
|
||||||
mSpecialIntent = intent;
|
mSpecialIntent = intent;
|
||||||
showCstorDialog(mCstorHelper.isCstorInitialized()
|
showCstorDialog(mCstorHelper.isCstorInitialized()
|
||||||
? CSTOR_UNLOCK_DIALOG
|
? 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) {
|
private void showCstorDialog(int dialogId) {
|
||||||
mDialogId = dialogId;
|
mDialogId = dialogId;
|
||||||
showDialog(dialogId);
|
showDialog(dialogId);
|
||||||
@@ -732,8 +739,7 @@ public class SecuritySettings extends PreferenceActivity implements
|
|||||||
if (passwd == null) {
|
if (passwd == null) {
|
||||||
showError(R.string.cstor_passwords_empty_error);
|
showError(R.string.cstor_passwords_empty_error);
|
||||||
return false;
|
return false;
|
||||||
} else if ((passwd.length() < CSTOR_MIN_PASSWORD_LENGTH)
|
} else if (passwd.length() < CSTOR_MIN_PASSWORD_LENGTH) {
|
||||||
|| passwd.contains(" ")) {
|
|
||||||
showError(R.string.cstor_password_verification_error);
|
showError(R.string.cstor_password_verification_error);
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} 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) {
|
private TextView showError(int messageId) {
|
||||||
TextView v = (TextView) mView.findViewById(R.id.cstor_error);
|
TextView v = (TextView) mView.findViewById(R.id.cstor_error);
|
||||||
v.setText(messageId);
|
v.setText(messageId);
|
||||||
@@ -838,13 +849,11 @@ public class SecuritySettings extends PreferenceActivity implements
|
|||||||
mResetButton.setEnabled(enabled);
|
mResetButton.setEnabled(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Preference createAccessCheckBox(int state) {
|
private Preference createAccessCheckBox() {
|
||||||
CheckBoxPreference pref = new CheckBoxPreference(
|
CheckBoxPreference pref = new CheckBoxPreference(
|
||||||
SecuritySettings.this);
|
SecuritySettings.this);
|
||||||
pref.setTitle(R.string.cstor_access_title);
|
pref.setTitle(R.string.cstor_access_title);
|
||||||
pref.setSummary(R.string.cstor_access_summary);
|
pref.setSummary(R.string.cstor_access_summary);
|
||||||
pref.setEnabled(state != Keystore.UNINITIALIZED);
|
|
||||||
pref.setChecked(state == Keystore.UNLOCKED);
|
|
||||||
pref.setOnPreferenceChangeListener(
|
pref.setOnPreferenceChangeListener(
|
||||||
new Preference.OnPreferenceChangeListener() {
|
new Preference.OnPreferenceChangeListener() {
|
||||||
public boolean onPreferenceChange(
|
public boolean onPreferenceChange(
|
||||||
@@ -861,6 +870,20 @@ public class SecuritySettings extends PreferenceActivity implements
|
|||||||
return pref;
|
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() {
|
private Preference createSetPasswordPreference() {
|
||||||
Preference pref = new Preference(SecuritySettings.this);
|
Preference pref = new Preference(SecuritySettings.this);
|
||||||
pref.setTitle(R.string.cstor_set_passwd_title);
|
pref.setTitle(R.string.cstor_set_passwd_title);
|
||||||
@@ -877,7 +900,7 @@ public class SecuritySettings extends PreferenceActivity implements
|
|||||||
return pref;
|
return pref;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Preference createResetPreference(int state) {
|
private Preference createResetPreference() {
|
||||||
Preference pref = new Preference(SecuritySettings.this);
|
Preference pref = new Preference(SecuritySettings.this);
|
||||||
pref.setTitle(R.string.cstor_reset_title);
|
pref.setTitle(R.string.cstor_reset_title);
|
||||||
pref.setSummary(R.string.cstor_reset_summary);
|
pref.setSummary(R.string.cstor_reset_summary);
|
||||||
@@ -888,7 +911,6 @@ public class SecuritySettings extends PreferenceActivity implements
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
pref.setEnabled(state != Keystore.UNINITIALIZED);
|
|
||||||
mResetButton = pref;
|
mResetButton = pref;
|
||||||
return pref;
|
return pref;
|
||||||
}
|
}
|
||||||
|
@@ -652,7 +652,7 @@ public class VpnSettings extends PreferenceActivity implements
|
|||||||
if (isKeystoreUnlocked()) return true;
|
if (isKeystoreUnlocked()) return true;
|
||||||
mUnlockAction = action;
|
mUnlockAction = action;
|
||||||
startActivity(
|
startActivity(
|
||||||
new Intent(SecuritySettings.ACTION_UNLOCK_CREDENTIAL_STORAGE));
|
new Intent(Keystore.ACTION_UNLOCK_CREDENTIAL_STORAGE));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -17,7 +17,6 @@
|
|||||||
package com.android.settings.wifi;
|
package com.android.settings.wifi;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.SecuritySettings;
|
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.Context;
|
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.
|
// Unlock the keystore if it is not unlocked yet.
|
||||||
if (Keystore.getInstance().getState() != Keystore.UNLOCKED) {
|
if (Keystore.getInstance().getState() != Keystore.UNLOCKED) {
|
||||||
getContext().startActivity(new Intent(
|
getContext().startActivity(new Intent(
|
||||||
SecuritySettings.ACTION_UNLOCK_CREDENTIAL_STORAGE));
|
Keystore.ACTION_UNLOCK_CREDENTIAL_STORAGE));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
enableEnterpriseFields();
|
enableEnterpriseFields();
|
||||||
|
@@ -18,7 +18,6 @@ package com.android.settings.wifi;
|
|||||||
|
|
||||||
import com.android.settings.ProgressCategory;
|
import com.android.settings.ProgressCategory;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.SecuritySettings;
|
|
||||||
|
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
@@ -376,7 +375,7 @@ public class WifiSettings extends PreferenceActivity implements WifiLayer.Callba
|
|||||||
if (state.isEnterprise() &&
|
if (state.isEnterprise() &&
|
||||||
Keystore.getInstance().getState() != Keystore.UNLOCKED) {
|
Keystore.getInstance().getState() != Keystore.UNLOCKED) {
|
||||||
startActivity(new Intent(
|
startActivity(new Intent(
|
||||||
SecuritySettings.ACTION_UNLOCK_CREDENTIAL_STORAGE));
|
Keystore.ACTION_UNLOCK_CREDENTIAL_STORAGE));
|
||||||
mResumeState = state;
|
mResumeState = state;
|
||||||
mResumeMode = mode;
|
mResumeMode = mode;
|
||||||
return;
|
return;
|
||||||
|
Reference in New Issue
Block a user