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