Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7caa6916 authored by Jorim Jaggi's avatar Jorim Jaggi Committed by Android (Google) Code Review
Browse files

Merge "Fix fingerprint API for 3rd party apps"

parents bd1c50d1 ccdfa93f
Loading
Loading
Loading
Loading
+21 −1
Original line number Original line Diff line number Diff line
@@ -380,6 +380,26 @@ public class FingerprintManager {
     */
     */
    public void authenticate(@Nullable CryptoObject crypto, @Nullable CancellationSignal cancel,
    public void authenticate(@Nullable CryptoObject crypto, @Nullable CancellationSignal cancel,
            @NonNull AuthenticationCallback callback, int flags) {
            @NonNull AuthenticationCallback callback, int flags) {
        authenticate(crypto, cancel, callback, flags, UserHandle.myUserId());
    }

    /**
     * Request authentication of a crypto object. This call warms up the fingerprint hardware
     * and starts scanning for a fingerprint. 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 callback an object to receive authentication events
     * @param flags optional flags; should be 0
     * @param userId the userId the fingerprint belongs to
     * @hide
     */
    public void authenticate(@Nullable CryptoObject crypto, @Nullable CancellationSignal cancel,
            @NonNull AuthenticationCallback callback, int flags, int userId) {
        if (callback == null) {
        if (callback == null) {
            throw new IllegalArgumentException("Must supply an authentication callback");
            throw new IllegalArgumentException("Must supply an authentication callback");
        }
        }
@@ -397,7 +417,7 @@ public class FingerprintManager {
            mAuthenticationCallback = callback;
            mAuthenticationCallback = callback;
            mCryptoObject = crypto;
            mCryptoObject = crypto;
            long sessionId = crypto != null ? crypto.getOpId() : 0;
            long sessionId = crypto != null ? crypto.getOpId() : 0;
            mService.authenticate(mToken, sessionId, getCurrentUserId(), mServiceReceiver, flags);
            mService.authenticate(mToken, sessionId, userId, mServiceReceiver, flags);
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            Log.w(TAG, "Remote exception while authenticating: ", e);
            Log.w(TAG, "Remote exception while authenticating: ", e);
            if (callback != null) {
            if (callback != null) {
+3 −1
Original line number Original line Diff line number Diff line
@@ -16,6 +16,7 @@


package com.android.keyguard;
package com.android.keyguard;


import android.app.ActivityManager;
import android.app.ActivityManagerNative;
import android.app.ActivityManagerNative;
import android.app.AlarmManager;
import android.app.AlarmManager;
import android.app.IUserSwitchObserver;
import android.app.IUserSwitchObserver;
@@ -795,7 +796,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
                mFingerprintCancelSignal.cancel();
                mFingerprintCancelSignal.cancel();
            }
            }
            mFingerprintCancelSignal = new CancellationSignal();
            mFingerprintCancelSignal = new CancellationSignal();
            mFpm.authenticate(null, mFingerprintCancelSignal, mAuthenticationCallback, 0);
            mFpm.authenticate(null, mFingerprintCancelSignal, mAuthenticationCallback, 0,
                    ActivityManager.getCurrentUser());
            setFingerprintRunningDetectionRunning(true);
            setFingerprintRunningDetectionRunning(true);
        }
        }
    }
    }