Merge "Add fallback for missing remote animation callbacks"
diff --git a/quickstep/src/com/android/quickstep/OverviewCommandHelper.java b/quickstep/src/com/android/quickstep/OverviewCommandHelper.java
index 75e8dd1..17baa3a 100644
--- a/quickstep/src/com/android/quickstep/OverviewCommandHelper.java
+++ b/quickstep/src/com/android/quickstep/OverviewCommandHelper.java
@@ -38,6 +38,7 @@
import com.android.systemui.shared.recents.model.ThumbnailData;
import com.android.systemui.shared.system.InteractionJankMonitorWrapper;
+import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
@@ -271,6 +272,14 @@
scheduleNextTask(cmd);
}
+ public void dump(PrintWriter pw) {
+ pw.println("OverviewCommandHelper:");
+ pw.println(" mPendingCommands=" + mPendingCommands.size());
+ if (!mPendingCommands.isEmpty()) {
+ pw.println(" pendingCommandType=" + mPendingCommands.get(0).type);
+ }
+ }
+
private static class CommandInfo {
public final long createTime = SystemClock.elapsedRealtime();
public final int type;
diff --git a/quickstep/src/com/android/quickstep/RecentsActivity.java b/quickstep/src/com/android/quickstep/RecentsActivity.java
index 3e00279..db92e33 100644
--- a/quickstep/src/com/android/quickstep/RecentsActivity.java
+++ b/quickstep/src/com/android/quickstep/RecentsActivity.java
@@ -100,6 +100,7 @@
private Handler mUiHandler = new Handler(Looper.getMainLooper());
private static final long HOME_APPEAR_DURATION = 250;
+ private static final long RECENTS_ANIMATION_TIMEOUT = 1000;
private RecentsDragLayer mDragLayer;
private ScrimView mScrimView;
@@ -116,6 +117,11 @@
// Strong refs to runners which are cleared when the activity is destroyed
private RemoteAnimationFactory mActivityLaunchAnimationRunner;
+ // For handling degenerate cases where starting an activity doesn't actually trigger the remote
+ // animation callback
+ private final Handler mHandler = new Handler();
+ private final Runnable mAnimationStartTimeoutRunnable = this::onAnimationStartTimeout;
+
/**
* Init drag layer and overview panel views.
*/
@@ -220,6 +226,16 @@
// TODO(b/137318995) This should go home, but doing so removes freeform windows
}
+ /**
+ * Called if the remote animation callback from #getActivityLaunchOptions() hasn't called back
+ * in a reasonable time due to a conflict with the recents animation.
+ */
+ private void onAnimationStartTimeout() {
+ if (mActivityLaunchAnimationRunner != null) {
+ mActivityLaunchAnimationRunner.onAnimationCancelled();
+ }
+ }
+
@Override
public ActivityOptionsWrapper getActivityLaunchOptions(final View v, @Nullable ItemInfo item) {
if (!(v instanceof TaskView)) {
@@ -234,6 +250,7 @@
public void onCreateAnimation(int transit, RemoteAnimationTargetCompat[] appTargets,
RemoteAnimationTargetCompat[] wallpaperTargets,
RemoteAnimationTargetCompat[] nonAppTargets, AnimationResult result) {
+ mHandler.removeCallbacks(mAnimationStartTimeoutRunnable);
AnimatorSet anim = composeRecentsLaunchAnimator(taskView, appTargets,
wallpaperTargets, nonAppTargets);
anim.addListener(resetStateListener());
@@ -243,6 +260,7 @@
@Override
public void onAnimationCancelled() {
+ mHandler.removeCallbacks(mAnimationStartTimeoutRunnable);
onEndCallback.executeAllAndDestroy();
}
};
@@ -260,6 +278,7 @@
activityOptions.options.setLaunchDisplayId(
(v != null && v.getDisplay() != null) ? v.getDisplay().getDisplayId()
: Display.DEFAULT_DISPLAY);
+ mHandler.postDelayed(mAnimationStartTimeoutRunnable, RECENTS_ANIMATION_TIMEOUT);
return activityOptions;
}
diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java
index a3d48da..d09a5d4 100644
--- a/quickstep/src/com/android/quickstep/TouchInteractionService.java
+++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java
@@ -942,6 +942,9 @@
if (mOverviewComponentObserver != null) {
mOverviewComponentObserver.dump(pw);
}
+ if (mOverviewCommandHelper != null) {
+ mOverviewCommandHelper.dump(pw);
+ }
if (mGestureState != null) {
mGestureState.dump(pw);
}