Merge "Authenticate with the correct user from KeyguardUpdateMonitor" into qt-dev
This commit is contained in:
@@ -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,23 +234,12 @@ 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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -548,7 +548,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");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user