summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/settings')
-rw-r--r--src/com/android/settings/SecuritySettings.java80
1 files changed, 74 insertions, 6 deletions
diff --git a/src/com/android/settings/SecuritySettings.java b/src/com/android/settings/SecuritySettings.java
index 1348d48..05a655a 100644
--- a/src/com/android/settings/SecuritySettings.java
+++ b/src/com/android/settings/SecuritySettings.java
@@ -66,6 +66,10 @@ public class SecuritySettings extends PreferenceActivity {
private static final String KEY_VISIBLE_PATTERN = "visiblepattern";
private static final String KEY_TACTILE_FEEDBACK_ENABLED = "unlock_tactile_feedback";
+ // Encrypted File Systems constants
+ private static final String PROPERTY_EFS_ENABLED = "persist.security.efs.enabled";
+ private static final String PROPERTY_EFS_TRANSITION = "persist.security.efs.trans";
+
private CheckBoxPreference mVisiblePattern;
private CheckBoxPreference mTactileFeedback;
@@ -80,6 +84,9 @@ public class SecuritySettings extends PreferenceActivity {
// Credential storage
private CredentialStorage mCredentialStorage = new CredentialStorage();
+ // Encrypted file system
+ private CheckBoxPreference mEncryptedFSEnabled;
+
private CheckBoxPreference mNetwork;
private CheckBoxPreference mGps;
private CheckBoxPreference mAssistedGps;
@@ -209,6 +216,11 @@ public class SecuritySettings extends PreferenceActivity {
root.addPreference(credentialsCat);
mCredentialStorage.createPreferences(credentialsCat, CredentialStorage.TYPE_KEYSTORE);
+ // File System Encryption
+ PreferenceCategory encryptedfsCat = new PreferenceCategory(this);
+ encryptedfsCat.setTitle(R.string.encrypted_fs_category);
+ //root.addPreference(encryptedfsCat);
+ mCredentialStorage.createPreferences(encryptedfsCat, CredentialStorage.TYPE_ENCRYPTEDFS);
return root;
}
@@ -302,18 +314,21 @@ public class SecuritySettings extends PreferenceActivity {
private static final int MINIMUM_PASSWORD_LENGTH = 8;
private static final int TYPE_KEYSTORE = 0;
+ private static final int TYPE_ENCRYPTEDFS = 1;
// Dialog identifiers
private static final int DLG_BASE = 0;
private static final int DLG_UNLOCK = DLG_BASE + 1;
private static final int DLG_PASSWORD = DLG_UNLOCK + 1;
private static final int DLG_RESET = DLG_PASSWORD + 1;
+ private static final int DLG_ENABLE_EFS = DLG_RESET + 1;
private KeyStore mKeyStore = KeyStore.getInstance();
private int mState;
private boolean mSubmit = false;
private boolean mExternal = false;
+ private boolean mWillEnableEncryptedFS;
private int mShowingDialog = 0;
// Key Store controls
@@ -322,6 +337,10 @@ public class SecuritySettings extends PreferenceActivity {
private Preference mPasswordButton;
private Preference mResetButton;
+
+ // Encrypted file system controls
+ private CheckBoxPreference mEncryptedFSEnabled;
+
void resume() {
mState = mKeyStore.test();
updatePreferences(mState);
@@ -373,6 +392,10 @@ public class SecuritySettings extends PreferenceActivity {
lock();
}
return true;
+ } else if (preference == mEncryptedFSEnabled) {
+ Boolean bval = (Boolean)value;
+ mWillEnableEncryptedFS = bval.booleanValue();
+ showSwitchEncryptedFSDialog();
}
return true;
}
@@ -391,9 +414,26 @@ public class SecuritySettings extends PreferenceActivity {
}
public void onClick(DialogInterface dialog, int button) {
- mSubmit = (button == DialogInterface.BUTTON_POSITIVE);
- if (button == DialogInterface.BUTTON_NEUTRAL) {
- reset();
+ if (mShowingDialog != DLG_ENABLE_EFS) {
+ mSubmit = (button == DialogInterface.BUTTON_POSITIVE);
+ if (button == DialogInterface.BUTTON_NEUTRAL) {
+ reset();
+ }
+ } else {
+ if (button == DialogInterface.BUTTON_POSITIVE) {
+ Intent intent = new Intent("android.intent.action.MASTER_CLEAR");
+ intent.putExtra("enableEFS", mWillEnableEncryptedFS);
+ sendBroadcast(intent);
+ updatePreferences(mState);
+ } else if (button == DialogInterface.BUTTON_NEGATIVE) {
+ // Cancel action
+ Toast.makeText(SecuritySettings.this, R.string.encrypted_fs_cancel_confirm,
+ Toast.LENGTH_SHORT).show();
+ updatePreferences(mState);
+ } else {
+ // Unknown - should not happen
+ return;
+ }
}
}
@@ -507,16 +547,25 @@ public class SecuritySettings extends PreferenceActivity {
category.addPreference(mResetButton);
break;
+ case TYPE_ENCRYPTEDFS:
+ mEncryptedFSEnabled = new CheckBoxPreference(SecuritySettings.this);
+ mEncryptedFSEnabled.setTitle(R.string.encrypted_fs_enable);
+ mEncryptedFSEnabled.setSummary(R.string.encrypted_fs_enable_summary);
+ mEncryptedFSEnabled.setOnPreferenceChangeListener(this);
+ // category.addPreference(mEncryptedFSEnabled);
+ break;
}
}
private void updatePreferences(int state) {
mAccessCheckBox.setChecked(state == KeyStore.NO_ERROR);
-
- mResetButton.setEnabled(state != KeyStore.UNINITIALIZED);
- mAccessCheckBox.setEnabled(state != KeyStore.UNINITIALIZED);
+ boolean encFSEnabled = SystemProperties.getBoolean(PROPERTY_EFS_ENABLED,
+ false);
+ mResetButton.setEnabled((!encFSEnabled) && (state != KeyStore.UNINITIALIZED));
+ mAccessCheckBox.setEnabled((state != KeyStore.UNINITIALIZED) && (!encFSEnabled));
// Encrypted File system preferences
+ mEncryptedFSEnabled.setChecked(encFSEnabled);
// Show a toast message if the state is changed.
if (mState == state) {
@@ -586,5 +635,24 @@ public class SecuritySettings extends PreferenceActivity {
.setNegativeButton(getString(android.R.string.cancel), this)
.create().show();
}
+
+ private void showSwitchEncryptedFSDialog() {
+ AlertDialog.Builder builder = new AlertDialog.Builder(SecuritySettings.this)
+ .setCancelable(false)
+ .setTitle(R.string.encrypted_fs_alert_dialog_title);
+
+ mShowingDialog = DLG_ENABLE_EFS;
+ if (mWillEnableEncryptedFS) {
+ builder.setMessage(R.string.encrypted_fs_enable_dialog)
+ .setPositiveButton(R.string.encrypted_fs_enable_button, this)
+ .setNegativeButton(R.string.encrypted_fs_cancel_button, this)
+ .create().show();
+ } else {
+ builder.setMessage(R.string.encrypted_fs_disable_dialog)
+ .setPositiveButton(R.string.encrypted_fs_disable_button, this)
+ .setNegativeButton(R.string.encrypted_fs_cancel_button, this)
+ .create().show();
+ }
+ }
}
}