Remove private space biometrics on switching to device lock

Bug: 320685466
Test: Verified manually
Change-Id: I5fe850ada9ae53bb1a00ed171beb6f8e099fbc0d
This commit is contained in:
josephpv
2024-01-22 16:21:58 +00:00
parent a05b33b661
commit ec273aca12
4 changed files with 67 additions and 0 deletions

View File

@@ -54,7 +54,9 @@ import android.graphics.drawable.AdaptiveIconDrawable;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.VectorDrawable;
import android.hardware.face.Face;
import android.hardware.face.FaceManager;
import android.hardware.fingerprint.Fingerprint;
import android.hardware.fingerprint.FingerprintManager;
import android.net.ConnectivityManager;
import android.net.LinkAddress;
@@ -1333,4 +1335,64 @@ public final class Utils extends com.android.settingslib.Utils {
return dreamsSupported && (!dreamsOnlyEnabledForDockUser || canCurrentUserDream(context));
}
/**
* Removes fingerprint templates enrolled for a given user.
*
* @param context application context.
* @param userId the id of the relevant user
*/
public static void removeEnrolledFingerprintForUser(Context context, int userId) {
FingerprintManager fingerprintManager = getFingerprintManagerOrNull(context);
if (fingerprintManager != null && fingerprintManager.hasEnrolledTemplates(userId)) {
fingerprintManager.removeAll(userId,
fingerprintManagerRemovalCallback(userId));
}
}
/**
* Removes face templates enrolled for a given user.
*
* @param context application context.
* @param userId the id of the relevant user
*/
public static void removeEnrolledFaceForUser(Context context, int userId) {
FaceManager faceManager = getFaceManagerOrNull(context);
if (faceManager != null && faceManager.hasEnrolledTemplates(userId)) {
faceManager.removeAll(userId, faceManagerRemovalCallback(userId));
}
}
private static FaceManager.RemovalCallback faceManagerRemovalCallback(int userId) {
return new FaceManager.RemovalCallback() {
@Override
public void onRemovalError(@Nullable Face face, int errMsgId, CharSequence err) {
Log.e(TAG, "Unable to remove face template for user " + userId + ", error: " + err);
}
@Override
public void onRemovalSucceeded(Face face, int remaining) {
if (remaining == 0) {
Log.d(TAG, "Enrolled face templates removed for user " + userId);
}
}
};
}
private static FingerprintManager.RemovalCallback fingerprintManagerRemovalCallback(
int userId) {
return new FingerprintManager.RemovalCallback() {
@Override
public void onRemovalError(@Nullable Fingerprint fp, int errMsgId, CharSequence err) {
Log.e(TAG, "Unable to remove fingerprint for user " + userId + " , error: " + err);
}
@Override
public void onRemovalSucceeded(Fingerprint fp, int remaining) {
if (remaining == 0) {
Log.d(TAG, "Enrolled fingerprints removed for user " + userId);
}
}
};
}
}