Search in sources :

Example 31 with CancellationSignal

use of android.os.CancellationSignal in project android_packages_apps_Settings by DirtyUnicorns.

the class FingerprintUiHelper method startListening.

public void startListening() {
    if (mFingerprintManager != null && mFingerprintManager.isHardwareDetected() && mFingerprintManager.getEnrolledFingerprints(mUserId).size() > 0) {
        mCancellationSignal = new CancellationSignal();
        mFingerprintManager.setActiveUser(mUserId);
        mFingerprintManager.authenticate(null, mCancellationSignal, 0, /* flags */
        this, null, mUserId);
        setFingerprintIconVisibility(true);
        mIcon.setImageResource(R.drawable.ic_fingerprint);
    }
}
Also used : CancellationSignal(android.os.CancellationSignal)

Example 32 with CancellationSignal

use of android.os.CancellationSignal in project SightRemote by TebbeUbben.

the class ConfirmationDialog method show.

@SuppressLint("NewApi")
public void show() {
    prepareViews();
    dialog = builder.show();
    dialog.setOnDismissListener((dialogInterface -> onClose()));
    dialog.setOnCancelListener((dialog -> onClose()));
    if (useFingerprint())
        getFingerprintManager().authenticate(null, cancellationSignal = new CancellationSignal(), 0, new FingerprintManager.AuthenticationCallback() {

            @Override
            public void onAuthenticationSucceeded(FingerprintManager.AuthenticationResult result) {
                onConfirm();
            }

            @Override
            public void onAuthenticationFailed() {
                fingerprintIcon.getBackground().setColorFilter(ContextCompat.getColor(SightRemote.getInstance(), R.color.colorWrong), PorterDuff.Mode.MULTIPLY);
                fingerprintText.setText(R.string.couldnt_recognize_fingerprint);
                fingerprintText.setTextColor(ContextCompat.getColor(SightRemote.getInstance(), R.color.colorWrong));
            }
        }, null);
    if (getBooleanPref(PREF_BOOLEAN_ENABLE_CONFIRMATION_CHALLENGES))
        pin.requestFocus();
}
Also used : Context(android.content.Context) LinearLayout(android.widget.LinearLayout) PREF_BOOLEAN_CONFIRMATION_USE_FINGERPRINT(sugar.free.sightremote.utils.Preferences.PREF_BOOLEAN_CONFIRMATION_USE_FINGERPRINT) Spanned(android.text.Spanned) PackageManager(android.content.pm.PackageManager) RequiresApi(android.support.annotation.RequiresApi) Preferences.getStringPref(sugar.free.sightremote.utils.Preferences.getStringPref) Editable(android.text.Editable) ArrayList(java.util.ArrayList) Manifest(android.Manifest) SuppressLint(android.annotation.SuppressLint) Handler(android.os.Handler) Looper(android.os.Looper) View(android.view.View) Button(android.widget.Button) PREF_STRING_CONFIRMATION_PIN(sugar.free.sightremote.utils.Preferences.PREF_STRING_CONFIRMATION_PIN) Preferences.getBooleanPref(sugar.free.sightremote.utils.Preferences.getBooleanPref) Build(android.os.Build) DialogInterface(android.content.DialogInterface) LayoutInflater(android.view.LayoutInflater) CancellationSignal(android.os.CancellationSignal) ContextCompat(android.support.v4.content.ContextCompat) HTMLUtil(sugar.free.sightremote.utils.HTMLUtil) PREF_BOOLEAN_ENABLE_CONFIRMATION_CHALLENGES(sugar.free.sightremote.utils.Preferences.PREF_BOOLEAN_ENABLE_CONFIRMATION_CHALLENGES) FingerprintManager(android.hardware.fingerprint.FingerprintManager) PREF_BOOLEAN_CONFIRMATION_USE_PIN(sugar.free.sightremote.utils.Preferences.PREF_BOOLEAN_CONFIRMATION_USE_PIN) PorterDuff(android.graphics.PorterDuff) List(java.util.List) R(sugar.free.sightremote.R) AlertDialog(android.support.v7.app.AlertDialog) TextView(android.widget.TextView) Vibrator(android.os.Vibrator) SightRemote(sugar.free.sightremote.SightRemote) Collections(java.util.Collections) TextWatcher(android.text.TextWatcher) CancellationSignal(android.os.CancellationSignal) SuppressLint(android.annotation.SuppressLint)

Example 33 with CancellationSignal

use of android.os.CancellationSignal in project android-fingerprint-authentication by multidots.

the class FingerPrintAuthHelper method startAuth.

/**
 * Start the finger print authentication by enabling the finger print sensor.
 * Note: Use this function in the onResume() of the activity/fragment. Never forget to call {@link #stopAuth()}
 * in onPause() of the activity/fragment.
 */
@TargetApi(Build.VERSION_CODES.M)
public void startAuth() {
    if (isScanning)
        stopAuth();
    // check if the device supports the finger print hardware?
    if (!checkFingerPrintAvailability(mContext))
        return;
    FingerprintManager fingerprintManager = (FingerprintManager) mContext.getSystemService(Context.FINGERPRINT_SERVICE);
    FingerprintManager.CryptoObject cryptoObject = getCryptoObject();
    if (cryptoObject == null) {
        mCallback.onAuthFailed(AuthErrorCodes.NON_RECOVERABLE_ERROR, ERROR_FAILED_TO_INIT_CHIPPER);
    } else {
        mCancellationSignal = new CancellationSignal();
        // noinspection MissingPermission
        fingerprintManager.authenticate(cryptoObject, mCancellationSignal, 0, new FingerprintManager.AuthenticationCallback() {

            @Override
            public void onAuthenticationError(int errMsgId, CharSequence errString) {
                mCallback.onAuthFailed(AuthErrorCodes.NON_RECOVERABLE_ERROR, errString.toString());
            }

            @Override
            public void onAuthenticationHelp(int helpMsgId, CharSequence helpString) {
                mCallback.onAuthFailed(AuthErrorCodes.RECOVERABLE_ERROR, helpString.toString());
            }

            @Override
            public void onAuthenticationFailed() {
                mCallback.onAuthFailed(AuthErrorCodes.CANNOT_RECOGNIZE_ERROR, null);
            }

            @Override
            public void onAuthenticationSucceeded(FingerprintManager.AuthenticationResult result) {
                mCallback.onAuthSuccess(result.getCryptoObject());
            }
        }, null);
    }
}
Also used : FingerprintManager(android.hardware.fingerprint.FingerprintManager) CancellationSignal(android.os.CancellationSignal) TargetApi(android.annotation.TargetApi)

Example 34 with CancellationSignal

use of android.os.CancellationSignal in project platform_packages_apps_Settings by BlissRoms.

the class FingerprintEnrollSidecar method startEnrollment.

private void startEnrollment() {
    mHandler.removeCallbacks(mTimeoutRunnable);
    mEnrollmentSteps = -1;
    mEnrollmentCancel = new CancellationSignal();
    if (mUserId != UserHandle.USER_NULL) {
        mFingerprintManager.setActiveUser(mUserId);
    }
    mFingerprintManager.enroll(mToken, mEnrollmentCancel, 0, /* flags */
    mUserId, mEnrollmentCallback);
    mEnrolling = true;
}
Also used : CancellationSignal(android.os.CancellationSignal)

Example 35 with CancellationSignal

use of android.os.CancellationSignal in project QR-Code-Based-Attendance-System by ishan0445.

the class FingerprintHandler method startAuth.

public void startAuth(FingerprintManager manager, FingerprintManager.CryptoObject cryptoObject) {
    CancellationSignal cancellationSignal = new CancellationSignal();
    if (ActivityCompat.checkSelfPermission(context, Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) {
        return;
    }
    manager.authenticate(cryptoObject, cancellationSignal, 0, this, null);
}
Also used : CancellationSignal(android.os.CancellationSignal)

Aggregations

CancellationSignal (android.os.CancellationSignal)79 OperationCanceledException (android.os.OperationCanceledException)18 Cursor (android.database.Cursor)13 FileNotFoundException (java.io.FileNotFoundException)11 IOException (java.io.IOException)11 RemoteException (android.os.RemoteException)10 FingerprintManager (android.hardware.fingerprint.FingerprintManager)8 ContentProviderClient (android.content.ContentProviderClient)7 ContentResolver (android.content.ContentResolver)6 Uri (android.net.Uri)6 ParcelFileDescriptor (android.os.ParcelFileDescriptor)6 AssetFileDescriptor (android.content.res.AssetFileDescriptor)5 MtpEvent (android.mtp.MtpEvent)5 InputStream (java.io.InputStream)5 FutureTask (java.util.concurrent.FutureTask)4 Test (org.junit.Test)4 KeyguardManager (android.app.KeyguardManager)2 BiometricPrompt (android.hardware.biometrics.BiometricPrompt)2 Bundle (android.os.Bundle)2 Handler (android.os.Handler)2