From c169e5b9af9a69a059ca162ffbb94c28f75a17ba Mon Sep 17 00:00:00 2001 From: Cyrus Boadway Date: Thu, 13 May 2021 14:57:24 +0000 Subject: [PATCH] Register a remote animation for the next activity start Widgets are permitted to start broadcast receivers which launch activities, otherwise known as a broadcast trampoline. Unfortunately, launch animations provided through ActivityOptions are not applied to the activity launch. If a widget interaction's pending intent is not an activity, set a return animation for the next activity start, in the event it starts an activity. Bug: 169042867 Test: presubmit Change-Id: Ibbee9cadcd5153e285433fcb1b8038d77b1384a2 --- .../uioverrides/QuickstepInteractionHandler.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/quickstep/src/com/android/launcher3/uioverrides/QuickstepInteractionHandler.java b/quickstep/src/com/android/launcher3/uioverrides/QuickstepInteractionHandler.java index a54f963100..0014b85125 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/QuickstepInteractionHandler.java +++ b/quickstep/src/com/android/launcher3/uioverrides/QuickstepInteractionHandler.java @@ -16,8 +16,11 @@ package com.android.launcher3.uioverrides; import android.app.ActivityOptions; +import android.app.ActivityTaskManager; import android.app.PendingIntent; import android.content.Intent; +import android.os.Build; +import android.os.RemoteException; import android.util.Log; import android.util.Pair; import android.view.View; @@ -50,6 +53,18 @@ class QuickstepInteractionHandler implements RemoteViews.InteractionHandler { Pair options = remoteResponse.getLaunchOptions(hostView); ActivityOptionsWrapper activityOptions = mLauncher.getAppTransitionManager() .getActivityLaunchOptions(mLauncher, hostView); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && !pendingIntent.isActivity()) { + // In the event this pending intent eventually launches an activity, i.e. a trampoline, + // use the Quickstep transition animation. + try { + ActivityTaskManager.getService() + .registerRemoteAnimationForNextActivityStart( + pendingIntent.getCreatorPackage(), + activityOptions.options.getRemoteAnimationAdapter()); + } catch (RemoteException e) { + // Do nothing. + } + } activityOptions.options.setPendingIntentLaunchFlags(Intent.FLAG_ACTIVITY_NEW_TASK); Object itemInfo = hostView.getTag(); if (itemInfo instanceof ItemInfo) {