FileDocCategorySizeDatePackage
FingerprintManager.javaAPI DocAndroid 5.1 API9156Thu Mar 12 22:22:10 GMT 2015android.service.fingerprint

FingerprintManager

public class FingerprintManager extends Object
A class that coordinates access to the fingerprint hardware.
hide

Fields Summary
private static final String
TAG
private static final boolean
DEBUG
private static final int
MSG_ENROLL_RESULT
private static final int
MSG_ACQUIRED
private static final int
MSG_PROCESSED
private static final int
MSG_ERROR
private static final int
MSG_REMOVED
public static final int
FINGERPRINT_ERROR_NO_RECEIVER
public static final int
FINGERPRINT_ERROR
public static final int
FINGERPRINT_ACQUIRED
public static final int
FINGERPRINT_PROCESSED
public static final int
FINGERPRINT_TEMPLATE_ENROLLING
public static final int
FINGERPRINT_TEMPLATE_REMOVED
public static final int
FINGERPRINT_ERROR_HW_UNAVAILABLE
public static final int
FINGERPRINT_ERROR_UNABLE_TO_PROCESS
public static final int
FINGERPRINT_ERROR_TIMEOUT
public static final int
FINGERPRINT_ERROR_NO_SPACE
public static final int
FINGERPRINT_ACQUIRED_GOOD
public static final int
FINGERPRINT_ACQUIRED_PARTIAL
public static final int
FINGERPRINT_ACQUIRED_INSUFFICIENT
public static final int
FINGERPRINT_ACQUIRED_IMAGER_DIRTY
public static final int
FINGERPRINT_ACQUIRED_TOO_SLOW
public static final int
FINGERPRINT_ACQUIRED_TOO_FAST
private IFingerprintService
mService
private FingerprintManagerReceiver
mClientReceiver
private android.content.Context
mContext
private android.os.IBinder
mToken
private android.os.Handler
mHandler
private IFingerprintServiceReceiver
mServiceReceiver
Constructors Summary
public FingerprintManager(android.content.Context context, IFingerprintService service)

hide


          
         
        mContext = context;
        mService = service;
        if (mService == null) {
            Slog.v(TAG, "FingerprintManagerService was null");
        }
    
Methods Summary
public voidenroll(long timeout)
Start the enrollment process. Timeout dictates how long to wait for the user to enroll a fingerprint.

param
timeout

        if (mServiceReceiver == null) {
            sendError(FINGERPRINT_ERROR_NO_RECEIVER, 0, 0);
            return;
        }
        if (mService != null) try {
            mService.enroll(mToken, timeout, getCurrentUserId());
        } catch (RemoteException e) {
            Log.v(TAG, "Remote exception while enrolling: ", e);
            sendError(FINGERPRINT_ERROR_HW_UNAVAILABLE, 0, 0);
        }
    
public voidenrollCancel()

        if (mServiceReceiver == null) {
            sendError(FINGERPRINT_ERROR_NO_RECEIVER, 0, 0);
            return;
        }
        if (mService != null) {
            try {
                mService.enrollCancel(mToken, getCurrentUserId());
                mClientReceiver = null;
            } catch (RemoteException e) {
                Log.v(TAG, "Remote exception in enrollCancel(): ", e);
                sendError(FINGERPRINT_ERROR_HW_UNAVAILABLE, 0, 0);
            }
        } else {
            Log.w(TAG, "enrollCancel(): Service not connected!");
        }
    
public booleanenrolledAndEnabled()
Determine whether the user has at least one fingerprint enrolled and enabled.

return
true if at least one is enrolled and enabled


                               
       
        ContentResolver res = mContext.getContentResolver();
        return Settings.Secure.getInt(res, "fingerprint_enabled", 0) != 0
                && FingerprintUtils.getFingerprintIdsForUser(res, getCurrentUserId()).length > 0;
    
private intgetCurrentUserId()

        try {
            return ActivityManagerNative.getDefault().getCurrentUser().id;
        } catch (RemoteException e) {
            Log.w(TAG, "Failed to get current user id\n");
            return UserHandle.USER_NULL;
        }
    
public voidremove(int fingerprintId)
Remove the given fingerprintId from the system. FingerprintId of 0 has special meaning which is to delete all fingerprint data for the current user. Use with caution.

param
fingerprintId

        if (mServiceReceiver == null) {
            sendError(FINGERPRINT_ERROR_NO_RECEIVER, 0, 0);
            return;
        }
        if (mService != null) {
            try {
                mService.remove(mToken, fingerprintId, getCurrentUserId());
            } catch (RemoteException e) {
                Log.v(TAG, "Remote exception during remove of fingerprintId: " + fingerprintId, e);
            }
        } else {
            Log.w(TAG, "remove(): Service not connected!");
            sendError(FINGERPRINT_ERROR_HW_UNAVAILABLE, 0, 0);
        }
    
private voidsendError(int msg, int arg1, int arg2)

        mHandler.obtainMessage(msg, arg1, arg2);
    
public voidstartListening(FingerprintManagerReceiver receiver)
Starts listening for fingerprint events. When a finger is scanned or recognized, the client will be notified via the callback.

        mClientReceiver = receiver;
        if (mService != null) {
            try {
                mService.startListening(mToken, mServiceReceiver, getCurrentUserId());
            } catch (RemoteException e) {
                Log.v(TAG, "Remote exception in startListening(): ", e);
            }
        } else {
            Log.w(TAG, "startListening(): Service not connected!");
            sendError(FINGERPRINT_ERROR_HW_UNAVAILABLE, 0, 0);
        }
    
public voidstopListening()
Stops the client from listening to fingerprint events.

        if (mService != null) {
            try {
                mService.stopListening(mToken, getCurrentUserId());
                mClientReceiver = null;
            } catch (RemoteException e) {
                Log.v(TAG, "Remote exception in stopListening(): ", e);
            }
        } else {
            Log.w(TAG, "stopListening(): Service not connected!");
            sendError(FINGERPRINT_ERROR_HW_UNAVAILABLE, 0, 0);
        }