diff options
11 files changed, 52 insertions, 59 deletions
diff --git a/core/java/android/hardware/face/Face.java b/core/java/android/hardware/face/Face.java index 6a508ac7accd..d6724d7d74f6 100644 --- a/core/java/android/hardware/face/Face.java +++ b/core/java/android/hardware/face/Face.java @@ -26,47 +26,13 @@ import android.os.Parcelable; * @hide */ public final class Face extends BiometricAuthenticator.Identifier { - private CharSequence mName; - private int mFaceId; - private long mDeviceId; // physical device this face is associated with public Face(CharSequence name, int faceId, long deviceId) { - mName = name; - mFaceId = faceId; - mDeviceId = deviceId; + super(name, faceId, deviceId); } private Face(Parcel in) { - mName = in.readString(); - mFaceId = in.readInt(); - mDeviceId = in.readLong(); - } - - /** - * Gets the human-readable name for the given fingerprint. - * @return name given to finger - */ - public CharSequence getName() { - return mName; - } - - /** - * Gets the device-specific finger id. Used by Settings to map a name to a specific - * fingerprint template. - * @return device-specific id for this finger - * @hide - */ - public int getFaceId() { - return mFaceId; - } - - /** - * Device this face belongs to. - * - * @hide - */ - public long getDeviceId() { - return mDeviceId; + super(in.readString(), in.readInt(), in.readLong()); } /** @@ -83,9 +49,9 @@ public final class Face extends BiometricAuthenticator.Identifier { * @param flags Additional flags about how the object should be written. */ public void writeToParcel(Parcel out, int flags) { - out.writeString(mName.toString()); - out.writeInt(mFaceId); - out.writeLong(mDeviceId); + out.writeString(getName().toString()); + out.writeInt(getBiometricId()); + out.writeLong(getDeviceId()); } public static final Parcelable.Creator<Face> CREATOR = new Parcelable.Creator<Face>() { diff --git a/core/java/android/hardware/face/FaceManager.java b/core/java/android/hardware/face/FaceManager.java index 3de9de3ed627..6a3dd7dd0693 100644 --- a/core/java/android/hardware/face/FaceManager.java +++ b/core/java/android/hardware/face/FaceManager.java @@ -418,7 +418,7 @@ public class FaceManager implements BiometricFaceConstants { try { mRemovalCallback = callback; mRemovalFace = face; - mService.remove(mToken, face.getFaceId(), userId, mServiceReceiver); + mService.remove(mToken, face.getBiometricId(), userId, mServiceReceiver); } catch (RemoteException e) { Log.w(TAG, "Remote exception in remove: ", e); if (callback != null) { @@ -796,6 +796,18 @@ public class FaceManager implements BiometricFaceConstants { */ public void onAuthenticationAcquired(int acquireInfo) { } + + /** + * @hide + * @param result + */ + @Override + public void onAuthenticationSucceeded(BiometricAuthenticator.AuthenticationResult result) { + onAuthenticationSucceeded(new AuthenticationResult( + result.getCryptoObject(), + (Face) result.getId(), result.getUserId())); + } + } /** diff --git a/services/core/java/com/android/server/biometrics/common/AuthenticationClient.java b/services/core/java/com/android/server/biometrics/common/AuthenticationClient.java index 6e5858a46056..02cc6d522030 100644 --- a/services/core/java/com/android/server/biometrics/common/AuthenticationClient.java +++ b/services/core/java/com/android/server/biometrics/common/AuthenticationClient.java @@ -153,11 +153,12 @@ public abstract class AuthenticationClient extends ClientMonitor { } @Override - public boolean onAuthenticated(int fingerId, int groupId) { + public boolean onAuthenticated(BiometricAuthenticator.Identifier identifier, + boolean authenticated) { boolean result = false; - boolean authenticated = fingerId != 0; // If the fingerprint dialog is showing, notify authentication succeeded + // TODO: this goes to BiometricPrompt, split between biometric modalities if (mBundle != null) { try { if (authenticated) { @@ -180,12 +181,18 @@ public abstract class AuthenticationClient extends ClientMonitor { } else { if (DEBUG) { Slog.v(getLogTag(), "onAuthenticated(owner=" + getOwnerString() - + ", id=" + fingerId + ", gp=" + groupId + ")"); + + ", id=" + identifier.getBiometricId()); + } + + // Explicitly have if/else here to make it super obvious in case the code is + // touched in the future. + if (!getIsRestricted()) { + listener.onAuthenticationSucceeded( + getHalDeviceId(), identifier, getTargetUserId()); + } else { + listener.onAuthenticationSucceeded( + getHalDeviceId(), null, getTargetUserId()); } - Fingerprint fp = !getIsRestricted() - ? new Fingerprint("" /* TODO */, groupId, fingerId, getHalDeviceId()) - : null; - listener.onAuthenticationSucceeded(getHalDeviceId(), fp, getTargetUserId()); } } catch (RemoteException e) { Slog.w(getLogTag(), "Failed to notify Authenticated:", e); diff --git a/services/core/java/com/android/server/biometrics/common/BiometricService.java b/services/core/java/com/android/server/biometrics/common/BiometricService.java index 41b15751b26c..f54baefa7161 100644 --- a/services/core/java/com/android/server/biometrics/common/BiometricService.java +++ b/services/core/java/com/android/server/biometrics/common/BiometricService.java @@ -577,20 +577,22 @@ public abstract class BiometricService extends SystemService implements IHwBinde } } - protected void handleAuthenticated(long deviceId, int biometricId, int groupId, + protected void handleAuthenticated(BiometricAuthenticator.Identifier identifier, ArrayList<Byte> token) { ClientMonitor client = mCurrentClient; - if (biometricId != 0) { + final boolean authenticated = identifier.getBiometricId() != 0; + + if (authenticated) { final byte[] byteToken = new byte[token.size()]; for (int i = 0; i < token.size(); i++) { byteToken[i] = token.get(i); } KeyStore.getInstance().addAuthToken(byteToken); } - if (client != null && client.onAuthenticated(biometricId, groupId)) { + if (client != null && client.onAuthenticated(identifier, authenticated)) { removeClient(client); } - if (biometricId != 0) { + if (authenticated) { mPerformanceStats.accept++; } else { mPerformanceStats.reject++; diff --git a/services/core/java/com/android/server/biometrics/common/ClientMonitor.java b/services/core/java/com/android/server/biometrics/common/ClientMonitor.java index 699fc32e3464..14867541d5b5 100644 --- a/services/core/java/com/android/server/biometrics/common/ClientMonitor.java +++ b/services/core/java/com/android/server/biometrics/common/ClientMonitor.java @@ -127,7 +127,8 @@ public abstract class ClientMonitor implements IBinder.DeathRecipient { // to the next client (e.g. authentication accepts or rejects a biometric). public abstract boolean onEnrollResult(BiometricAuthenticator.Identifier identifier, int remaining); - public abstract boolean onAuthenticated(int biometricId, int groupId); + public abstract boolean onAuthenticated(BiometricAuthenticator.Identifier identifier, + boolean authenticated); public abstract boolean onRemoved(BiometricAuthenticator.Identifier identifier, int remaining); public abstract boolean onEnumerationResult( diff --git a/services/core/java/com/android/server/biometrics/common/EnrollClient.java b/services/core/java/com/android/server/biometrics/common/EnrollClient.java index 5744fdbd0de0..aee772b15575 100644 --- a/services/core/java/com/android/server/biometrics/common/EnrollClient.java +++ b/services/core/java/com/android/server/biometrics/common/EnrollClient.java @@ -125,7 +125,8 @@ public abstract class EnrollClient extends ClientMonitor { } @Override - public boolean onAuthenticated(int biometricId, int groupId) { + public boolean onAuthenticated(BiometricAuthenticator.Identifier identifier, + boolean authenticated) { if (DEBUG) Slog.w(getLogTag(), "onAuthenticated() called for enroll!"); return true; // Invalid for EnrollClient } diff --git a/services/core/java/com/android/server/biometrics/common/EnumerateClient.java b/services/core/java/com/android/server/biometrics/common/EnumerateClient.java index e51c1c683e06..ee40ee920b8b 100644 --- a/services/core/java/com/android/server/biometrics/common/EnumerateClient.java +++ b/services/core/java/com/android/server/biometrics/common/EnumerateClient.java @@ -93,7 +93,8 @@ public abstract class EnumerateClient extends ClientMonitor { } @Override - public boolean onAuthenticated(int biometricId, int groupId) { + public boolean onAuthenticated(BiometricAuthenticator.Identifier identifier, + boolean authenticated) { if (DEBUG) Slog.w(getLogTag(), "onAuthenticated() called for enumerate!"); return true; // Invalid for Enumerate. } diff --git a/services/core/java/com/android/server/biometrics/common/RemovalClient.java b/services/core/java/com/android/server/biometrics/common/RemovalClient.java index 23d55397eefc..27c42ab20a4d 100644 --- a/services/core/java/com/android/server/biometrics/common/RemovalClient.java +++ b/services/core/java/com/android/server/biometrics/common/RemovalClient.java @@ -110,7 +110,8 @@ public abstract class RemovalClient extends ClientMonitor { } @Override - public boolean onAuthenticated(int biometricId, int groupId) { + public boolean onAuthenticated(BiometricAuthenticator.Identifier identifier, + boolean authenticated) { if (DEBUG) Slog.w(getLogTag(), "onAuthenticated() called for remove!"); return true; // Invalid for Remove. } diff --git a/services/core/java/com/android/server/biometrics/face/FaceService.java b/services/core/java/com/android/server/biometrics/face/FaceService.java index 35679a8824b1..f8ccef5c73c1 100644 --- a/services/core/java/com/android/server/biometrics/face/FaceService.java +++ b/services/core/java/com/android/server/biometrics/face/FaceService.java @@ -400,7 +400,8 @@ public class FaceService extends BiometricService { public void onAuthenticated(final long deviceId, final int faceId, final int userId, ArrayList<Byte> token) { mHandler.post(() -> { - FaceService.super.handleAuthenticated(deviceId, faceId, userId, token); + Face face = new Face("", faceId, deviceId); + FaceService.super.handleAuthenticated(face, token); }); } diff --git a/services/core/java/com/android/server/biometrics/face/FaceUserState.java b/services/core/java/com/android/server/biometrics/face/FaceUserState.java index e12498ebcf29..c438bfbdd8fa 100644 --- a/services/core/java/com/android/server/biometrics/face/FaceUserState.java +++ b/services/core/java/com/android/server/biometrics/face/FaceUserState.java @@ -85,7 +85,7 @@ public class FaceUserState extends BiometricUserState { ArrayList<Face> result = new ArrayList<>(array.size()); for (int i = 0; i < array.size(); i++) { Face f = (Face) array.get(i); - result.add(new Face(f.getName(), f.getFaceId(), f.getDeviceId())); + result.add(new Face(f.getName(), f.getBiometricId(), f.getDeviceId())); } return result; } @@ -114,7 +114,7 @@ public class FaceUserState extends BiometricUserState { for (int i = 0; i < count; i++) { Face f = faces.get(i); serializer.startTag(null, TAG_FACE); - serializer.attribute(null, ATTR_FACE_ID, Integer.toString(f.getFaceId())); + serializer.attribute(null, ATTR_FACE_ID, Integer.toString(f.getBiometricId())); serializer.attribute(null, ATTR_NAME, f.getName().toString()); serializer.attribute(null, ATTR_DEVICE_ID, Long.toString(f.getDeviceId())); serializer.endTag(null, TAG_FACE); diff --git a/services/core/java/com/android/server/biometrics/fingerprint/FingerprintService.java b/services/core/java/com/android/server/biometrics/fingerprint/FingerprintService.java index 7004e1b37ed5..64b248e16554 100644 --- a/services/core/java/com/android/server/biometrics/fingerprint/FingerprintService.java +++ b/services/core/java/com/android/server/biometrics/fingerprint/FingerprintService.java @@ -528,7 +528,8 @@ public class FingerprintService extends BiometricService { public void onAuthenticated(final long deviceId, final int fingerId, final int groupId, ArrayList<Byte> token) { mHandler.post(() -> { - FingerprintService.super.handleAuthenticated(deviceId, fingerId, groupId, token); + Fingerprint fp = new Fingerprint("", groupId, fingerId, deviceId); + FingerprintService.super.handleAuthenticated(fp, token); }); } |