Search in sources :

Example 96 with CancellationSignal

use of android.os.CancellationSignal in project robolectric by robolectric.

the class ShadowUwbManager method openRangingSession.

/**
 * Instantiates a {@link ShadowRangingSession} with the adapter provided by {@link
 * ShadowUwbManager#setUwbAdapter()}, allowing the tester dictate the results of ranging attempts.
 */
@Implementation
protected CancellationSignal openRangingSession(PersistableBundle params, Executor executor, RangingSession.Callback callback) {
    RangingSession session = ShadowRangingSession.newInstance(executor, callback, adapter);
    CancellationSignal cancellationSignal = new CancellationSignal();
    cancellationSignal.setOnCancelListener(session::close);
    Shadow.<ShadowRangingSession>extract(session).open(params);
    return cancellationSignal;
}
Also used : CancellationSignal(android.os.CancellationSignal) RangingSession(android.uwb.RangingSession) Implementation(org.robolectric.annotation.Implementation)

Example 97 with CancellationSignal

use of android.os.CancellationSignal in project EhViewer by seven332.

the class SecurityScene method onResume.

@Override
public void onResume() {
    super.onResume();
    if (null != mShakeDetector) {
        mSensorManager.registerListener(mShakeDetector, mAccelerometer, SensorManager.SENSOR_DELAY_UI);
    }
    if (isFingerprintAuthAvailable()) {
        mFingerprintCancellationSignal = new CancellationSignal();
        // The line below prevents the false positive inspection from Android Studio
        // noinspection ResourceType
        mFingerprintManager.authenticate(null, mFingerprintCancellationSignal, 0, new FingerprintManager.AuthenticationCallback() {

            @Override
            public void onAuthenticationError(int errMsgId, CharSequence errString) {
                fingerprintError(true);
            }

            @Override
            public void onAuthenticationFailed() {
                fingerprintError(false);
            }

            @Override
            public void onAuthenticationSucceeded(FingerprintManager.AuthenticationResult result) {
                mFingerprintIcon.setImageResource(R.drawable.fingerprint_success);
                mFingerprintIcon.postDelayed(new Runnable() {

                    @Override
                    public void run() {
                        startSceneForCheckStep(CHECK_STEP_SECURITY, getArguments());
                        finish();
                    }
                }, SUCCESS_DELAY_MILLIS);
            }
        }, null);
    }
}
Also used : FingerprintManager(android.hardware.fingerprint.FingerprintManager) CancellationSignal(android.os.CancellationSignal)

Example 98 with CancellationSignal

use of android.os.CancellationSignal in project platform_frameworks_base by android.

the class RemoteViews method startTaskOnExecutor.

private CancellationSignal startTaskOnExecutor(AsyncApplyTask task, Executor executor) {
    CancellationSignal cancelSignal = new CancellationSignal();
    cancelSignal.setOnCancelListener(task);
    task.executeOnExecutor(executor == null ? AsyncTask.THREAD_POOL_EXECUTOR : executor);
    return cancelSignal;
}
Also used : CancellationSignal(android.os.CancellationSignal)

Example 99 with CancellationSignal

use of android.os.CancellationSignal in project android_frameworks_base by ParanoidAndroid.

the class CursorLoader method loadInBackground.

/* Runs on a worker thread */
@Override
public Cursor loadInBackground() {
    synchronized (this) {
        if (isLoadInBackgroundCanceled()) {
            throw new OperationCanceledException();
        }
        mCancellationSignal = new CancellationSignal();
    }
    try {
        Cursor cursor = getContext().getContentResolver().query(mUri, mProjection, mSelection, mSelectionArgs, mSortOrder, mCancellationSignal);
        if (cursor != null) {
            try {
                // Ensure the cursor window is filled.
                cursor.getCount();
                cursor.registerContentObserver(mObserver);
            } catch (RuntimeException ex) {
                cursor.close();
                throw ex;
            }
        }
        return cursor;
    } finally {
        synchronized (this) {
            mCancellationSignal = null;
        }
    }
}
Also used : OperationCanceledException(android.os.OperationCanceledException) Cursor(android.database.Cursor) CancellationSignal(android.os.CancellationSignal)

Example 100 with CancellationSignal

use of android.os.CancellationSignal in project platform_frameworks_base by android.

the class KeyguardUpdateMonitor method startListeningForFingerprint.

private void startListeningForFingerprint() {
    if (mFingerprintRunningState == FINGERPRINT_STATE_CANCELLING) {
        setFingerprintRunningState(FINGERPRINT_STATE_CANCELLING_RESTARTING);
        return;
    }
    if (DEBUG)
        Log.v(TAG, "startListeningForFingerprint()");
    int userId = ActivityManager.getCurrentUser();
    if (isUnlockWithFingerprintPossible(userId)) {
        if (mFingerprintCancelSignal != null) {
            mFingerprintCancelSignal.cancel();
        }
        mFingerprintCancelSignal = new CancellationSignal();
        mFpm.authenticate(null, mFingerprintCancelSignal, 0, mAuthenticationCallback, null, userId);
        setFingerprintRunningState(FINGERPRINT_STATE_RUNNING);
    }
}
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