am 233991a2: Reduce the number of keystore connections to 1
Merge commit '233991a2420bd870a0f85e8e0c4c1c00eaf4b975'
* commit '233991a2420bd870a0f85e8e0c4c1c00eaf4b975':
Reduce the number of keystore connections to 1
diff --git a/src/com/android/settings/SecuritySettings.java b/src/com/android/settings/SecuritySettings.java
index 6f2439c..e181e6e 100644
--- a/src/com/android/settings/SecuritySettings.java
+++ b/src/com/android/settings/SecuritySettings.java
@@ -236,10 +236,10 @@
PreferenceCategory credStoreCat = new PreferenceCategory(this);
credStoreCat.setTitle(R.string.cstor_settings_category);
root.addPreference(credStoreCat);
- boolean i = mCstorHelper.isCstorInitialized();
- credStoreCat.addPreference(mCstorHelper.createAccessCheckBox(i));
+ int s = mCstorHelper.getCstorState();
+ credStoreCat.addPreference(mCstorHelper.createAccessCheckBox(s));
credStoreCat.addPreference(mCstorHelper.createSetPasswordPreference());
- credStoreCat.addPreference(mCstorHelper.createResetPreference(i));
+ credStoreCat.addPreference(mCstorHelper.createResetPreference(s));
return root;
}
@@ -498,6 +498,10 @@
}
}
+ private int getCstorState() {
+ return mKeystore.getState();
+ }
+
private boolean isCstorUnlocked() {
return (mKeystore.getState() == Keystore.UNLOCKED);
}
@@ -806,27 +810,25 @@
mResetButton.setEnabled(enabled);
}
- private Preference createAccessCheckBox(boolean isInitialized) {
+ private Preference createAccessCheckBox(int state) {
CheckBoxPreference pref = new CheckBoxPreference(
SecuritySettings.this);
pref.setTitle(R.string.cstor_access_title);
pref.setSummary(R.string.cstor_access_summary);
- if (isInitialized) pref.setChecked(isCstorUnlocked());
+ pref.setEnabled(state != Keystore.UNINITIALIZED);
+ pref.setChecked(state == Keystore.UNLOCKED);
pref.setOnPreferenceChangeListener(
new Preference.OnPreferenceChangeListener() {
public boolean onPreferenceChange(
Preference pref, Object value) {
if (((Boolean) value)) {
- showCstorDialog(isCstorInitialized()
- ? CSTOR_UNLOCK_DIALOG
- : CSTOR_INIT_DIALOG);
+ showCstorDialog(CSTOR_UNLOCK_DIALOG);
} else {
lockCstor();
}
return true;
}
});
- pref.setEnabled(isInitialized);
mAccessCheckBox = pref;
return pref;
}
@@ -847,7 +849,7 @@
return pref;
}
- private Preference createResetPreference(boolean isInitialized) {
+ private Preference createResetPreference(int state) {
Preference pref = new Preference(SecuritySettings.this);
pref.setTitle(R.string.cstor_reset_title);
pref.setSummary(R.string.cstor_reset_summary);
@@ -858,7 +860,7 @@
return true;
}
});
- pref.setEnabled(isInitialized);
+ pref.setEnabled(state != Keystore.UNINITIALIZED);
mResetButton = pref;
return pref;
}