From 0844f2e8ef0c3152dbda50e46158b74a40b548cd Mon Sep 17 00:00:00 2001 From: Schneider Victor-tulias Date: Thu, 10 Nov 2022 11:22:33 -0800 Subject: [PATCH] Return to home when overview command fails. Returning a runnable list that doesn't get run later causes the overview command to be added to the pending command queue, but never gets removed. This causes following overview (and home on tablets) commands not to respond. Test: forcefully caused the error condition programmatically; checked the queue is cleared and the user is sent home. Fixes: 255851262 Change-Id: I9d2f54960c54963b1e7480a597d05911201c152b --- .../android/quickstep/OverviewCommandHelper.java | 2 +- .../android/quickstep/views/DesktopTaskView.java | 2 +- .../src/com/android/quickstep/views/TaskView.java | 14 ++++++++++---- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/quickstep/src/com/android/quickstep/OverviewCommandHelper.java b/quickstep/src/com/android/quickstep/OverviewCommandHelper.java index 875b72cb34..5a09e021b2 100644 --- a/quickstep/src/com/android/quickstep/OverviewCommandHelper.java +++ b/quickstep/src/com/android/quickstep/OverviewCommandHelper.java @@ -116,7 +116,7 @@ public class OverviewCommandHelper { */ @BinderThread public void addCommand(int type) { - if (mPendingCommands.size() > MAX_QUEUE_SIZE) { + if (mPendingCommands.size() >= MAX_QUEUE_SIZE) { return; } CommandInfo cmd = new CommandInfo(type); diff --git a/quickstep/src/com/android/quickstep/views/DesktopTaskView.java b/quickstep/src/com/android/quickstep/views/DesktopTaskView.java index 2abd715fae..8c43fd108f 100644 --- a/quickstep/src/com/android/quickstep/views/DesktopTaskView.java +++ b/quickstep/src/com/android/quickstep/views/DesktopTaskView.java @@ -288,7 +288,7 @@ public class DesktopTaskView extends TaskView { public RunnableList launchTasks() { SystemUiProxy.INSTANCE.get(getContext()).showDesktopApps(); getRecentsView().startHome(); - return new RunnableList(); + return null; } @Nullable diff --git a/quickstep/src/com/android/quickstep/views/TaskView.java b/quickstep/src/com/android/quickstep/views/TaskView.java index 527a0d1b36..b7fbed5ab1 100644 --- a/quickstep/src/com/android/quickstep/views/TaskView.java +++ b/quickstep/src/com/android/quickstep/views/TaskView.java @@ -725,13 +725,14 @@ public class TaskView extends FrameLayout implements Reusable { /** * Launch of the current task (both live and inactive tasks) with an animation. */ + @Nullable public RunnableList launchTasks() { RecentsView recentsView = getRecentsView(); RemoteTargetHandle[] remoteTargetHandles = recentsView.mRemoteTargetHandles; - RunnableList runnableList = new RunnableList(); if (isRunningTask() && remoteTargetHandles != null) { if (!mIsClickableAsLiveTile) { - return runnableList; + Log.e(TAG, "TaskView is not clickable as a live tile; returning to home."); + return null; } mIsClickableAsLiveTile = false; @@ -756,11 +757,16 @@ public class TaskView extends FrameLayout implements Reusable { if (targets == null) { // If the recents animation is cancelled somehow between the parent if block and // here, try to launch the task as a non live tile task. - launchTaskAnimated(); + RunnableList runnableList = launchTaskAnimated(); + if (runnableList == null) { + Log.e(TAG, "Recents animation cancelled and cannot launch task as non-live tile" + + "; returning to home"); + } mIsClickableAsLiveTile = true; return runnableList; } + RunnableList runnableList = new RunnableList(); AnimatorSet anim = new AnimatorSet(); TaskViewUtils.composeRecentsLaunchAnimator( anim, this, targets.apps, @@ -797,10 +803,10 @@ public class TaskView extends FrameLayout implements Reusable { }); anim.start(); recentsView.onTaskLaunchedInLiveTileMode(); + return runnableList; } else { return launchTaskAnimated(); } - return runnableList; } /**