use of android.os.CancellationSignal in project android_packages_apps_Launcher3 by crdroidandroid.
the class LauncherInitListener method handleInit.
@Override
public boolean handleInit(Launcher launcher, boolean alreadyOnHome) {
if (mRemoteAnimationProvider != null) {
QuickstepTransitionManager appTransitionManager = ((BaseQuickstepLauncher) launcher).getAppTransitionManager();
// Set a one-time animation provider. After the first call, this will get cleared.
// TODO: Probably also check the intended target id.
CancellationSignal cancellationSignal = new CancellationSignal();
appTransitionManager.setRemoteAnimationProvider(new RemoteAnimationProvider() {
@Override
public AnimatorSet createWindowAnimation(RemoteAnimationTargetCompat[] appTargets, RemoteAnimationTargetCompat[] wallpaperTargets) {
// On the first call clear the reference.
cancellationSignal.cancel();
RemoteAnimationProvider provider = mRemoteAnimationProvider;
mRemoteAnimationProvider = null;
if (provider != null && launcher.getStateManager().getState().overviewUi) {
return provider.createWindowAnimation(appTargets, wallpaperTargets);
}
return null;
}
}, cancellationSignal);
}
launcher.deferOverlayCallbacksUntilNextResumeOrStop();
return super.handleInit(launcher, alreadyOnHome);
}
use of android.os.CancellationSignal in project android_packages_apps_Launcher3 by crdroidandroid.
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();
}
}
use of android.os.CancellationSignal in project android_packages_apps_Launcher3 by crdroidandroid.
the class DatabaseWidgetPreviewLoader method loadPreview.
/**
* 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.
*/
@Override
@NonNull
public CancellationSignal loadPreview(@NonNull BaseActivity activity, @NonNull WidgetItem item, @NonNull Size previewSize, @NonNull WidgetPreviewLoadedCallback callback) {
int previewWidth = previewSize.getWidth();
int previewHeight = previewSize.getHeight();
String size = previewWidth + "x" + previewHeight;
WidgetCacheKey key = new WidgetCacheKey(item.componentName, item.user, size);
PreviewLoadTask task = new PreviewLoadTask(activity, key, item, previewWidth, previewHeight, callback);
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_Launcher3 by crdroidandroid.
the class CachingWidgetPreviewLoaderTest method loadPreview_thenLoaded_thenCancelled_shouldNotRemovePreviewFromCache.
@Test
public void loadPreview_thenLoaded_thenCancelled_shouldNotRemovePreviewFromCache() {
CancellationSignal cancellationSignal = mLoader.loadPreview(mTestActivity, mWidgetItem, SIZE_10_10, mPreviewLoadedCallback);
verify(mDelegate).loadPreview(any(), any(), any(), mCallbackCaptor.capture());
WidgetPreviewLoadedCallback loaderCallback = mCallbackCaptor.getValue();
loaderCallback.onPreviewLoaded(BITMAP);
cancellationSignal.cancel();
assertThat(mLoader.getPreview(mWidgetItem, SIZE_10_10)).isEqualTo(BITMAP);
}
use of android.os.CancellationSignal in project android_packages_apps_Launcher3 by crdroidandroid.
the class CachingWidgetPreviewLoaderTest method loadPreview_thenCancelled_shouldCancelDelegateRequest.
@Test
public void loadPreview_thenCancelled_shouldCancelDelegateRequest() {
CancellationSignal cancellationSignal = mLoader.loadPreview(mTestActivity, mWidgetItem, SIZE_10_10, mPreviewLoadedCallback);
cancellationSignal.cancel();
verify(mCancellationSignal).cancel();
verifyZeroInteractions(mPreviewLoadedCallback);
assertThat(mLoader.getPreview(mWidgetItem, SIZE_10_10)).isNull();
}
Aggregations