Limit number of fingerprint templates that can be enrolled per device user

This change places an upper limit on the number of fingerprint templates that
can be enrolled per account.  This is done primarily for performance reasons, but
may also be imposed by hardware and Trusted Execution Environment (TEE) reasons.

Fixes bug 20731847

Change-Id: I3975290fa8eb2106467493aab6102015697e012c

 On branch max_fingerprint
This commit is contained in:
Jim Miller
2015-06-15 20:41:02 -07:00
parent bada978ec3
commit 5adada6083
3 changed files with 42 additions and 6 deletions

View File

@@ -179,6 +179,7 @@ public class FingerprintSettings extends SubSettings {
switch (msg.what) {
case MSG_REFRESH_FINGERPRINT_TEMPLATES:
removeFingerprintPreference(msg.arg1);
updateAddPreference();
break;
case MSG_FINGER_AUTH_SUCCESS:
mFingerprintCancel = null;
@@ -330,6 +331,19 @@ public class FingerprintSettings extends SubSettings {
addPreference.setIcon(R.drawable.ic_add_24dp);
root.addPreference(addPreference);
addPreference.setOnPreferenceChangeListener(this);
updateAddPreference();
}
private void updateAddPreference() {
/* Disable preference if too many fingerprints added */
final int max = getContext().getResources().getInteger(
com.android.internal.R.integer.config_fingerprintMaxTemplatesPerUser);
boolean tooMany = mFingerprintManager.getEnrolledFingerprints().size() >= max;
CharSequence maxSummary = tooMany ?
getContext().getString(R.string.fingerprint_add_max, max) : "";
Preference addPreference = findPreference(KEY_FINGERPRINT_ADD);
addPreference.setSummary(maxSummary);
addPreference.setEnabled(!tooMany);
}
private static String genKey(int id) {