Search in sources :

Example 66 with CancellationSignal

use of android.os.CancellationSignal in project android_packages_apps_Launcher3 by crdroidandroid.

the class FloatingIconView method checkIconResult.

/**
 * Checks if the icon result is loaded. If true, we set the icon immediately. Else, we add a
 * callback to set the icon once the icon result is loaded.
 */
private void checkIconResult(View originalView) {
    CancellationSignal cancellationSignal = new CancellationSignal();
    if (mIconLoadResult == null) {
        Log.w(TAG, "No icon load result found in checkIconResult");
        return;
    }
    synchronized (mIconLoadResult) {
        if (mIconLoadResult.isIconLoaded) {
            setIcon(mIconLoadResult.drawable, mIconLoadResult.badge, mIconLoadResult.btvDrawable, mIconLoadResult.iconOffset);
            setVisibility(VISIBLE);
            setIconAndDotVisible(originalView, false);
        } else {
            mIconLoadResult.onIconLoaded = () -> {
                if (cancellationSignal.isCanceled()) {
                    return;
                }
                setIcon(mIconLoadResult.drawable, mIconLoadResult.badge, mIconLoadResult.btvDrawable, mIconLoadResult.iconOffset);
                setVisibility(VISIBLE);
                setIconAndDotVisible(originalView, false);
            };
            mLoadIconSignal = cancellationSignal;
        }
    }
}
Also used : CancellationSignal(android.os.CancellationSignal)

Example 67 with CancellationSignal

use of android.os.CancellationSignal in project packages_apps_Settings by Evolution-X.

the class BiometricFragment method onResume.

@Override
public void onResume() {
    super.onResume();
    if (mCancellationSignal == null) {
        mCancellationSignal = new CancellationSignal();
        mBiometricPrompt.authenticateUser(mCancellationSignal, mClientExecutor, mAuthenticationCallback, mUserId);
    }
}
Also used : CancellationSignal(android.os.CancellationSignal)

Example 68 with CancellationSignal

use of android.os.CancellationSignal in project packages_apps_Settings by Evolution-X.

the class WifiDppUtils method showLockScreen.

/**
 * Shows authentication screen to confirm credentials (pin, pattern or password) for the current
 * user of the device.
 *
 * @param context The {@code Context} used to get {@code KeyguardManager} service
 * @param successRunnable The {@code Runnable} which will be executed if the user does not setup
 *                        device security or if lock screen is unlocked
 */
public static void showLockScreen(Context context, Runnable successRunnable) {
    final KeyguardManager keyguardManager = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
    if (keyguardManager.isKeyguardSecure()) {
        final BiometricPrompt.AuthenticationCallback authenticationCallback = new BiometricPrompt.AuthenticationCallback() {

            @Override
            public void onAuthenticationSucceeded(BiometricPrompt.AuthenticationResult result) {
                successRunnable.run();
            }

            @Override
            public void onAuthenticationError(int errorCode, CharSequence errString) {
            // Do nothing
            }
        };
        final BiometricPrompt.Builder builder = new BiometricPrompt.Builder(context).setTitle(context.getText(R.string.wifi_dpp_lockscreen_title));
        if (keyguardManager.isDeviceSecure()) {
            builder.setDeviceCredentialAllowed(true);
        }
        final BiometricPrompt bp = builder.build();
        final Handler handler = new Handler(Looper.getMainLooper());
        bp.authenticate(new CancellationSignal(), runnable -> handler.post(runnable), authenticationCallback);
    } else {
        successRunnable.run();
    }
}
Also used : BiometricPrompt(android.hardware.biometrics.BiometricPrompt) Handler(android.os.Handler) KeyguardManager(android.app.KeyguardManager) CancellationSignal(android.os.CancellationSignal)

Example 69 with CancellationSignal

use of android.os.CancellationSignal in project packages_apps_Settings by Evolution-X.

the class FingerprintAuthenticateSidecar method startAuthentication.

public void startAuthentication(int userId) {
    mCancellationSignal = new CancellationSignal();
    mFingerprintManager.authenticate(null, /* crypto */
    mCancellationSignal, mAuthenticationCallback, null, /* handler */
    userId);
}
Also used : CancellationSignal(android.os.CancellationSignal)

Example 70 with CancellationSignal

use of android.os.CancellationSignal in project packages_apps_Settings by Evolution-X.

the class BiometricEnrollSidecar method startEnrollment.

protected void startEnrollment() {
    mHandler.removeCallbacks(mTimeoutRunnable);
    mEnrollmentSteps = -1;
    mEnrollmentCancel = new CancellationSignal();
    mEnrolling = true;
}
Also used : CancellationSignal(android.os.CancellationSignal)

Aggregations

CancellationSignal (android.os.CancellationSignal)170 Cursor (android.database.Cursor)22 Test (org.junit.Test)21 BiometricPrompt (android.hardware.biometrics.BiometricPrompt)20 OperationCanceledException (android.os.OperationCanceledException)18 ParcelFileDescriptor (android.os.ParcelFileDescriptor)17 Handler (android.os.Handler)15 KeyguardManager (android.app.KeyguardManager)14 Intent (android.content.Intent)14 FingerprintManager (android.hardware.fingerprint.FingerprintManager)14 Bundle (android.os.Bundle)14 Activity (android.app.Activity)12 PrintAttributes (android.print.PrintAttributes)12 PrintDocumentAdapter (android.print.PrintDocumentAdapter)12 PrintJob (android.print.PrintJob)12 PrintManager (android.print.PrintManager)12 UiDevice (android.support.test.uiautomator.UiDevice)12 UiObject2 (android.support.test.uiautomator.UiObject2)12 LargeTest (androidx.test.filters.LargeTest)12 UUID (java.util.UUID)12