Search in sources :

Example 1 with CancellationSignal

use of android.support.v4.os.CancellationSignal in project MTweaks-KernelAdiutorMOD by morogoku.

the class FingerprintUiHelper method startListening.

public void startListening(FingerprintManagerCompat.CryptoObject cryptoObject) {
    if (!mListening) {
        mListening = true;
        mCancellationSignal = new CancellationSignal();
        mSelfCancelled = false;
        mFingerprintManagerCompat.authenticate(cryptoObject, 0, mCancellationSignal, this, null);
        mSwirlView.setState(SwirlView.State.ON);
    }
}
Also used : CancellationSignal(android.support.v4.os.CancellationSignal)

Example 2 with CancellationSignal

use of android.support.v4.os.CancellationSignal in project Signal-Android by signalapp.

the class PassphrasePromptActivity method resumeScreenLock.

private void resumeScreenLock() {
    KeyguardManager keyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
    assert keyguardManager != null;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN && !keyguardManager.isKeyguardSecure()) {
        Log.w(TAG, "Keyguard not secure...");
        handleAuthenticated();
        return;
    }
    if (Build.VERSION.SDK_INT >= 16 && fingerprintManager.isHardwareDetected() && fingerprintManager.hasEnrolledFingerprints()) {
        Log.w(TAG, "Listening for fingerprints...");
        fingerprintCancellationSignal = new CancellationSignal();
        fingerprintManager.authenticate(null, 0, fingerprintCancellationSignal, fingerprintListener, null);
    } else if (Build.VERSION.SDK_INT >= 21) {
        Log.w(TAG, "firing intent...");
        Intent intent = keyguardManager.createConfirmDeviceCredentialIntent("Unlock Signal", "");
        startActivityForResult(intent, 1);
    } else {
        Log.w(TAG, "Not compatible...");
        handleAuthenticated();
    }
}
Also used : Intent(android.content.Intent) KeyguardManager(android.app.KeyguardManager) CancellationSignal(android.support.v4.os.CancellationSignal)

Example 3 with CancellationSignal

use of android.support.v4.os.CancellationSignal in project MaxLock by Maxr1998.

the class FingerprintView method onWindowFocusChanged.

@Override
public void onWindowFocusChanged(boolean hasWindowFocus) {
    super.onWindowFocusChanged(hasWindowFocus);
    if (hasWindowFocus) {
        FingerprintManagerCompat mFingerprintManager = FingerprintManagerCompat.from(getContext());
        if (mFingerprintManager.isHardwareDetected() && mFingerprintManager.hasEnrolledFingerprints()) {
            if (!mLockView.allowFingerprint()) {
                handleFingerprintIndicator(R.drawable.lockscreen_fingerprint_fp_to_error_state_animation);
                setOnClickListener(mNotAllowedToast);
                return;
            }
            if (mCancelFingerprint.isCanceled()) {
                mCancelFingerprint = new CancellationSignal();
            }
            mFingerprintManager.authenticate(null, 0, mCancelFingerprint, mFPAuthenticationCallback, null);
            handleFingerprintIndicator(R.drawable.lockscreen_fingerprint_draw_on_animation);
        } else {
            setVisibility(GONE);
        }
    } else {
        mCancelFingerprint.cancel();
    }
}
Also used : FingerprintManagerCompat(android.support.v4.hardware.fingerprint.FingerprintManagerCompat) CancellationSignal(android.support.v4.os.CancellationSignal)

Example 4 with CancellationSignal

use of android.support.v4.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 5 with CancellationSignal

use of android.support.v4.os.CancellationSignal in project iosched by google.

the class CursorModelLoader method loadInBackground.

@Override
public D loadInBackground() {
    synchronized (this) {
        if (isLoadInBackgroundCanceled()) {
            throw new OperationCanceledException();
        }
        mCancellationSignal = new CancellationSignal();
    }
    Cursor cursor = null;
    try {
        cursor = mCursorTransform.performQuery(this, mCancellationSignal);
        if (cursor != null) {
            try {
                // Ensure the cursor window is filled.
                cursor.getCount();
                cursor.registerContentObserver(mObserver);
            } catch (RuntimeException ex) {
                cursor.close();
                throw ex;
            }
        }
    } finally {
        synchronized (this) {
            mCancellationSignal = null;
        }
    }
    if (cursor != null) {
        try {
            return mCursorTransform.cursorToModel(this, cursor);
        } finally {
            cursor.close();
        }
    }
    return null;
}
Also used : OperationCanceledException(android.support.v4.os.OperationCanceledException) Cursor(android.database.Cursor) CancellationSignal(android.support.v4.os.CancellationSignal)

Aggregations

CancellationSignal (android.support.v4.os.CancellationSignal)6 Manifest (android.Manifest)1 SuppressLint (android.annotation.SuppressLint)1 KeyguardManager (android.app.KeyguardManager)1 Context (android.content.Context)1 DialogInterface (android.content.DialogInterface)1 Intent (android.content.Intent)1 PackageManager (android.content.pm.PackageManager)1 Cursor (android.database.Cursor)1 PorterDuff (android.graphics.PorterDuff)1 FingerprintManager (android.hardware.fingerprint.FingerprintManager)1 Build (android.os.Build)1 CancellationSignal (android.os.CancellationSignal)1 Handler (android.os.Handler)1 Looper (android.os.Looper)1 Vibrator (android.os.Vibrator)1 RequiresApi (android.support.annotation.RequiresApi)1 ContextCompat (android.support.v4.content.ContextCompat)1 FingerprintManagerCompat (android.support.v4.hardware.fingerprint.FingerprintManagerCompat)1 OperationCanceledException (android.support.v4.os.OperationCanceledException)1