Search in sources :

Example 41 with CancellationSignal

use of android.os.CancellationSignal in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class BiometricFragment method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setRetainInstance(true);
    mBundle = getArguments();
    final BiometricPrompt.Builder builder = new BiometricPrompt.Builder(getContext()).setTitle(mBundle.getString(BiometricPrompt.KEY_TITLE)).setUseDefaultTitle().setFromConfirmDeviceCredential().setSubtitle(mBundle.getString(BiometricPrompt.KEY_SUBTITLE)).setDescription(mBundle.getString(BiometricPrompt.KEY_DESCRIPTION)).setApplockPackage(mBundle.getString(BiometricPrompt.KEY_APPLOCK_PKG)).setConfirmationRequired(mBundle.getBoolean(BiometricPrompt.KEY_REQUIRE_CONFIRMATION, true));
    final LockPatternUtils lockPatternUtils = FeatureFactory.getFactory(getContext()).getSecurityFeatureProvider().getLockPatternUtils(getContext());
    switch(lockPatternUtils.getKeyguardStoredPasswordQuality(mUserId)) {
        case DevicePolicyManager.PASSWORD_QUALITY_SOMETHING:
            builder.setNegativeButton(getResources().getString(R.string.confirm_device_credential_pattern), mClientExecutor, mNegativeButtonListener);
            break;
        case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC:
        case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC_COMPLEX:
            builder.setNegativeButton(getResources().getString(R.string.confirm_device_credential_pin), mClientExecutor, mNegativeButtonListener);
            break;
        case DevicePolicyManager.PASSWORD_QUALITY_ALPHABETIC:
        case DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC:
        case DevicePolicyManager.PASSWORD_QUALITY_COMPLEX:
        case DevicePolicyManager.PASSWORD_QUALITY_MANAGED:
            builder.setNegativeButton(getResources().getString(R.string.confirm_device_credential_password), mClientExecutor, mNegativeButtonListener);
            break;
    }
    mBiometricPrompt = builder.build();
    mCancellationSignal = new CancellationSignal();
    // TODO: CC doesn't use crypto for now
    mAuthenticating = true;
    mBiometricPrompt.authenticateUser(mCancellationSignal, mClientExecutor, mAuthenticationCallback, mUserId, mCancelCallback);
}
Also used : BiometricPrompt(android.hardware.biometrics.BiometricPrompt) LockPatternUtils(com.android.internal.widget.LockPatternUtils) CancellationSignal(android.os.CancellationSignal)

Example 42 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 43 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 44 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)

Example 45 with CancellationSignal

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

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)

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