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;
}
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);
}
}
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;
}
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;
}
}
}
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);
}
}
Aggregations