Skip to content
Snippets Groups Projects
Commit 7172f7a9 authored by Wenhui Yang's avatar Wenhui Yang Committed by Automerger Merge Worker
Browse files

Merge "FRR follow-up: address comments in AuthenticationStatsPersister" into...

Merge "FRR follow-up: address comments in AuthenticationStatsPersister" into udc-qpr-dev am: 83cfc036

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/24516053



Change-Id: I042e75ab1603691d9d24a049c1ecd7b3b823d79f
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 32a0493b 83cfc036
No related branches found
No related tags found
No related merge requests found
......@@ -21,6 +21,7 @@ import android.content.Context;
import android.content.SharedPreferences;
import android.hardware.biometrics.BiometricsProtoEnums;
import android.os.Environment;
import android.os.UserHandle;
import android.util.Slog;
import org.json.JSONException;
......@@ -72,14 +73,16 @@ public class AuthenticationStatsPersister {
JSONObject frrStatsJson = new JSONObject(frrStats);
if (modality == BiometricsProtoEnums.MODALITY_FACE) {
authenticationStatsList.add(new AuthenticationStats(
getIntValue(frrStatsJson, USER_ID, -1 /* defaultValue */),
getIntValue(frrStatsJson, USER_ID,
UserHandle.USER_NULL /* defaultValue */),
getIntValue(frrStatsJson, FACE_ATTEMPTS),
getIntValue(frrStatsJson, FACE_REJECTIONS),
getIntValue(frrStatsJson, ENROLLMENT_NOTIFICATIONS),
modality));
} else if (modality == BiometricsProtoEnums.MODALITY_FINGERPRINT) {
authenticationStatsList.add(new AuthenticationStats(
getIntValue(frrStatsJson, USER_ID, -1 /* defaultValue */),
getIntValue(frrStatsJson, USER_ID,
UserHandle.USER_NULL /* defaultValue */),
getIntValue(frrStatsJson, FINGERPRINT_ATTEMPTS),
getIntValue(frrStatsJson, FINGERPRINT_REJECTIONS),
getIntValue(frrStatsJson, ENROLLMENT_NOTIFICATIONS),
......@@ -138,13 +141,11 @@ public class AuthenticationStatsPersister {
// If there's existing frr stats in the file, we want to update the stats for the given
// modality and keep the stats for other modalities.
if (frrStatJson != null) {
frrStatsSet.add(buildFrrStats(frrStatJson, totalAttempts, rejectedAttempts,
enrollmentNotifications, modality));
} else {
frrStatsSet.add(buildFrrStats(userId, totalAttempts, rejectedAttempts,
enrollmentNotifications, modality));
if (frrStatJson == null) {
frrStatJson = new JSONObject().put(USER_ID, userId);
}
frrStatsSet.add(buildFrrStats(frrStatJson, totalAttempts, rejectedAttempts,
enrollmentNotifications, modality));
mSharedPreferences.edit().putStringSet(KEY, frrStatsSet).apply();
......@@ -177,29 +178,6 @@ public class AuthenticationStatsPersister {
}
}
// Build string for new user and new authentication stats.
private String buildFrrStats(int userId, int totalAttempts, int rejectedAttempts,
int enrollmentNotifications, int modality)
throws JSONException {
if (modality == BiometricsProtoEnums.MODALITY_FACE) {
return new JSONObject()
.put(USER_ID, userId)
.put(FACE_ATTEMPTS, totalAttempts)
.put(FACE_REJECTIONS, rejectedAttempts)
.put(ENROLLMENT_NOTIFICATIONS, enrollmentNotifications)
.toString();
} else if (modality == BiometricsProtoEnums.MODALITY_FINGERPRINT) {
return new JSONObject()
.put(USER_ID, userId)
.put(FINGERPRINT_ATTEMPTS, totalAttempts)
.put(FINGERPRINT_REJECTIONS, rejectedAttempts)
.put(ENROLLMENT_NOTIFICATIONS, enrollmentNotifications)
.toString();
} else {
return "";
}
}
private String getValue(JSONObject jsonObject, String key) throws JSONException {
return jsonObject.has(key) ? jsonObject.getString(key) : "";
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment