Search in sources :

Example 81 with CancellationSignal

use of android.os.CancellationSignal in project android_packages_apps_Settings by Project-Kaleidoscope.

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 82 with CancellationSignal

use of android.os.CancellationSignal in project android_packages_apps_Settings by Project-Kaleidoscope.

the class BiometricEnrollSidecar method startEnrollment.

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

Example 83 with CancellationSignal

use of android.os.CancellationSignal in project android_packages_apps_Trebuchet by LineageOS.

the class WidgetPreviewLoader method getPreview.

/**
 * Generates the widget preview on {@link AsyncTask#THREAD_POOL_EXECUTOR}. Must be
 * called on UI thread
 *
 * @return a request id which can be used to cancel the request.
 */
public CancellationSignal getPreview(WidgetItem item, int previewWidth, int previewHeight, WidgetCell caller) {
    String size = previewWidth + "x" + previewHeight;
    WidgetCacheKey key = new WidgetCacheKey(item.componentName, item.user, size);
    PreviewLoadTask task = new PreviewLoadTask(key, item, previewWidth, previewHeight, caller);
    task.executeOnExecutor(Executors.THREAD_POOL_EXECUTOR);
    CancellationSignal signal = new CancellationSignal();
    signal.setOnCancelListener(task);
    return signal;
}
Also used : CancellationSignal(android.os.CancellationSignal)

Example 84 with CancellationSignal

use of android.os.CancellationSignal in project android_packages_apps_Trebuchet by LineageOS.

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.iconOffset);
            setIconAndDotVisible(originalView, false);
        } else {
            mIconLoadResult.onIconLoaded = () -> {
                if (cancellationSignal.isCanceled()) {
                    return;
                }
                setIcon(mIconLoadResult.drawable, mIconLoadResult.badge, mIconLoadResult.iconOffset);
                setVisibility(VISIBLE);
                setIconAndDotVisible(originalView, false);
            };
            mLoadIconSignal = cancellationSignal;
        }
    }
}
Also used : CancellationSignal(android.os.CancellationSignal)

Example 85 with CancellationSignal

use of android.os.CancellationSignal in project android_packages_apps_Trebuchet by LineageOS.

the class LineageUtils 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 title the {@code String} which will be shown as the pompt title
 * @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, String title, Runnable successRunnable) {
    if (hasSecureKeyguard(context)) {
        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 bp = new BiometricPrompt.Builder(context).setTitle(title).setAllowedAuthenticators(Authenticators.BIOMETRIC_STRONG | Authenticators.DEVICE_CREDENTIAL).build();
        final Handler handler = new Handler(Looper.getMainLooper());
        bp.authenticate(new CancellationSignal(), runnable -> handler.post(runnable), authenticationCallback);
    } else {
        // Notify the user a secure keyguard is required for protected apps,
        // but allow to set hidden apps
        Toast.makeText(context, R.string.trust_apps_no_lock_error, Toast.LENGTH_LONG).show();
        successRunnable.run();
    }
}
Also used : BiometricPrompt(android.hardware.biometrics.BiometricPrompt) Handler(android.os.Handler) 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