diff options
| author | 2019-04-11 18:30:40 -0700 | |
|---|---|---|
| committer | 2019-04-12 11:48:12 -0700 | |
| commit | 8d2694a351fcb024c87838973a515a147ee84183 (patch) | |
| tree | 15f7879323e6bca3a562c5d206414c68378cdf7c | |
| parent | 1c100834ddea99b4e36dfcff533faa3b3011d007 (diff) | |
Authenticate with the correct user from KeyguardUpdateMonitor
Fixes: 130242795
Test: manual
Change-Id: I5c5e400de9d204d89abbe07bc6b3265dbc4ea973
6 files changed, 51 insertions, 22 deletions
diff --git a/core/java/android/hardware/face/FaceManager.java b/core/java/android/hardware/face/FaceManager.java index 6035f40e768a..7349f0cbe55d 100644 --- a/core/java/android/hardware/face/FaceManager.java +++ b/core/java/android/hardware/face/FaceManager.java @@ -93,8 +93,8 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan } @Override // binder call - public void onAuthenticationSucceeded(long deviceId, Face face) { - mHandler.obtainMessage(MSG_AUTHENTICATION_SUCCEEDED, face).sendToTarget(); + public void onAuthenticationSucceeded(long deviceId, Face face, int userId) { + mHandler.obtainMessage(MSG_AUTHENTICATION_SUCCEEDED, userId, 0, face).sendToTarget(); } @Override // binder call @@ -168,6 +168,44 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan @RequiresPermission(USE_BIOMETRIC_INTERNAL) public void authenticate(@Nullable CryptoObject crypto, @Nullable CancellationSignal cancel, int flags, @NonNull AuthenticationCallback callback, @Nullable Handler handler) { + authenticate(crypto, cancel, flags, callback, handler, mContext.getUserId()); + } + + /** + * Use the provided handler thread for events. + */ + private void useHandler(Handler handler) { + if (handler != null) { + mHandler = new MyHandler(handler.getLooper()); + } else if (mHandler.getLooper() != mContext.getMainLooper()) { + mHandler = new MyHandler(mContext.getMainLooper()); + } + } + + /** + * Request authentication of a crypto object. This call operates the face recognition hardware + * and starts capturing images. It terminates when + * {@link AuthenticationCallback#onAuthenticationError(int, CharSequence)} or + * {@link AuthenticationCallback#onAuthenticationSucceeded(AuthenticationResult)} is called, at + * which point the object is no longer valid. The operation can be canceled by using the + * provided cancel object. + * + * @param crypto object associated with the call or null if none required. + * @param cancel an object that can be used to cancel authentication + * @param flags optional flags; should be 0 + * @param callback an object to receive authentication events + * @param handler an optional handler to handle callback events + * @param userId userId to authenticate for + * @throws IllegalArgumentException if the crypto operation is not supported or is not backed + * by + * <a href="{@docRoot}training/articles/keystore.html">Android + * Keystore facility</a>. + * @throws IllegalStateException if the crypto primitive is not initialized. + * @hide + */ + public void authenticate(@Nullable CryptoObject crypto, @Nullable CancellationSignal cancel, + int flags, @NonNull AuthenticationCallback callback, @Nullable Handler handler, + int userId) { if (callback == null) { throw new IllegalArgumentException("Must supply an authentication callback"); } @@ -187,7 +225,7 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan mAuthenticationCallback = callback; mCryptoObject = crypto; long sessionId = crypto != null ? crypto.getOpId() : 0; - mService.authenticate(mToken, sessionId, mContext.getUserId(), mServiceReceiver, + mService.authenticate(mToken, sessionId, userId, mServiceReceiver, flags, mContext.getOpPackageName()); } catch (RemoteException e) { Log.w(TAG, "Remote exception while authenticating: ", e); @@ -196,24 +234,13 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan // try again later. callback.onAuthenticationError(FACE_ERROR_HW_UNAVAILABLE, getErrorString(mContext, FACE_ERROR_HW_UNAVAILABLE, - 0 /* vendorCode */)); + 0 /* vendorCode */)); } } } } /** - * Use the provided handler thread for events. - */ - private void useHandler(Handler handler) { - if (handler != null) { - mHandler = new MyHandler(handler.getLooper()); - } else if (mHandler.getLooper() != mContext.getMainLooper()) { - mHandler = new MyHandler(mContext.getMainLooper()); - } - } - - /** * Request face authentication enrollment. This call operates the face authentication hardware * and starts capturing images. Progress will be indicated by callbacks to the * {@link EnrollmentCallback} object. It terminates when diff --git a/core/java/android/hardware/face/IFaceServiceReceiver.aidl b/core/java/android/hardware/face/IFaceServiceReceiver.aidl index 217690273969..10f9c435c415 100644 --- a/core/java/android/hardware/face/IFaceServiceReceiver.aidl +++ b/core/java/android/hardware/face/IFaceServiceReceiver.aidl @@ -24,7 +24,7 @@ import android.hardware.face.Face; oneway interface IFaceServiceReceiver { void onEnrollResult(long deviceId, int faceId, int remaining); void onAcquired(long deviceId, int acquiredInfo, int vendorCode); - void onAuthenticationSucceeded(long deviceId, in Face face); + void onAuthenticationSucceeded(long deviceId, in Face face, int userId); void onAuthenticationFailed(long deviceId); void onError(long deviceId, int error, int vendorCode); void onRemoved(long deviceId, int faceId, int remaining); diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java index fa39ccd28ff1..fd557083aefd 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java @@ -1665,7 +1665,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { } mFaceCancelSignal = new CancellationSignal(); mFaceManager.authenticate(null, mFaceCancelSignal, 0, - mFaceAuthenticationCallback, null); + mFaceAuthenticationCallback, null, userId); setFaceRunningState(BIOMETRIC_STATE_RUNNING); } } diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java index ffe3ece52e45..6bed43eb37b6 100644 --- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java +++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java @@ -288,7 +288,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { mKeyguardUpdateMonitor.sendKeyguardBouncerChanged(true); mTestableLooper.processAllMessages(); - verify(mFaceManager).authenticate(any(), any(), anyInt(), any(), any()); + verify(mFaceManager).authenticate(any(), any(), anyInt(), any(), any(), anyInt()); verify(mFaceManager).isHardwareDetected(); verify(mFaceManager).hasEnrolledTemplates(anyInt()); } @@ -298,7 +298,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { mKeyguardUpdateMonitor.dispatchStartedWakingUp(); mTestableLooper.processAllMessages(); mKeyguardUpdateMonitor.onKeyguardVisibilityChanged(true); - verify(mFaceManager).authenticate(any(), any(), anyInt(), any(), any()); + verify(mFaceManager).authenticate(any(), any(), anyInt(), any(), any(), anyInt()); } @Test @@ -317,7 +317,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { mKeyguardUpdateMonitor.setKeyguardOccluded(true); mKeyguardUpdateMonitor.setAssistantVisible(true); - verify(mFaceManager).authenticate(any(), any(), anyInt(), any(), any()); + verify(mFaceManager).authenticate(any(), any(), anyInt(), any(), any(), anyInt()); } @Test diff --git a/services/core/java/com/android/server/biometrics/AuthenticationClient.java b/services/core/java/com/android/server/biometrics/AuthenticationClient.java index f7278d2601c3..da13c8033fd4 100644 --- a/services/core/java/com/android/server/biometrics/AuthenticationClient.java +++ b/services/core/java/com/android/server/biometrics/AuthenticationClient.java @@ -134,7 +134,8 @@ public abstract class AuthenticationClient extends ClientMonitor { + ", Owner: " + getOwnerString() + ", isBP: " + isBiometricPrompt() + ", listener: " + listener - + ", requireConfirmation: " + mRequireConfirmation); + + ", requireConfirmation: " + mRequireConfirmation + + ", user: " + getTargetUserId()); if (authenticated) { mAlreadyDone = true; 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 aa52621d044d..4709bea3d4bc 100644 --- a/services/core/java/com/android/server/biometrics/face/FaceService.java +++ b/services/core/java/com/android/server/biometrics/face/FaceService.java @@ -546,7 +546,8 @@ public class FaceService extends BiometricServiceBase { throws RemoteException { if (mFaceServiceReceiver != null) { if (biometric == null || biometric instanceof Face) { - mFaceServiceReceiver.onAuthenticationSucceeded(deviceId, (Face)biometric); + mFaceServiceReceiver.onAuthenticationSucceeded(deviceId, (Face) biometric, + userId); } else { Slog.e(TAG, "onAuthenticationSucceeded received non-face biometric"); } |