summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2022-01-21 06:17:10 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-02-14 23:13:10 +0000
commit3db7cd137e8e342d7eb6aa6f04fea03088ac7976 (patch)
treef06c75fc368b7e96b83473f59edbecb81b285f7f
parentab5f39bdc08f4469f1c759b7dcd0fd7cf56654fb (diff)
Add fallback for missing remote animation callbacks
- In some cases WM won't callback the remote animation callbacks (neither start nor cancel) and Launcher never finishes executing the pending command (preventing the subsequent commands from running). For the time being, just cancel the current state to allow the commands to be processed. Bug: 194011186 Test: Mash on overview and home buttons with a 3p launcher Signed-off-by: Winson Chung <winsonc@google.com> Change-Id: I1b1296fab316b979f441ebb474d1475e3fa68f95 Merged-In: I1b1296fab316b979f441ebb474d1475e3fa68f95 (cherry picked from commit bb530e9058e085bb1668a42ed9dc81f079af6304) Merged-In:I1b1296fab316b979f441ebb474d1475e3fa68f95
-rw-r--r--quickstep/src/com/android/quickstep/OverviewCommandHelper.java9
-rw-r--r--quickstep/src/com/android/quickstep/RecentsActivity.java19
-rw-r--r--quickstep/src/com/android/quickstep/TouchInteractionService.java3
3 files changed, 31 insertions, 0 deletions
diff --git a/quickstep/src/com/android/quickstep/OverviewCommandHelper.java b/quickstep/src/com/android/quickstep/OverviewCommandHelper.java
index 75e8dd1f7a..17baa3ad91 100644
--- a/quickstep/src/com/android/quickstep/OverviewCommandHelper.java
+++ b/quickstep/src/com/android/quickstep/OverviewCommandHelper.java
@@ -38,6 +38,7 @@ import com.android.quickstep.views.TaskView;
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 @@ public class OverviewCommandHelper {
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 103f350c0f..1dc49339b6 100644
--- a/quickstep/src/com/android/quickstep/RecentsActivity.java
+++ b/quickstep/src/com/android/quickstep/RecentsActivity.java
@@ -99,6 +99,7 @@ public final class RecentsActivity extends StatefulActivity<RecentsState> {
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;
@@ -115,6 +116,11 @@ public final class RecentsActivity extends StatefulActivity<RecentsState> {
// 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.
*/
@@ -219,6 +225,16 @@ public final class RecentsActivity extends StatefulActivity<RecentsState> {
// 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)) {
@@ -233,6 +249,7 @@ public final class RecentsActivity extends StatefulActivity<RecentsState> {
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());
@@ -242,6 +259,7 @@ public final class RecentsActivity extends StatefulActivity<RecentsState> {
@Override
public void onAnimationCancelled() {
+ mHandler.removeCallbacks(mAnimationStartTimeoutRunnable);
onEndCallback.executeAllAndDestroy();
}
};
@@ -256,6 +274,7 @@ public final class RecentsActivity extends StatefulActivity<RecentsState> {
ActivityOptionsCompat.makeRemoteAnimation(adapterCompat),
onEndCallback);
activityOptions.options.setSplashscreenStyle(SplashScreen.SPLASH_SCREEN_STYLE_ICON);
+ 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 539239d36a..1f6a974c23 100644
--- a/quickstep/src/com/android/quickstep/TouchInteractionService.java
+++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java
@@ -967,6 +967,9 @@ public class TouchInteractionService extends Service
if (mOverviewComponentObserver != null) {
mOverviewComponentObserver.dump(pw);
}
+ if (mOverviewCommandHelper != null) {
+ mOverviewCommandHelper.dump(pw);
+ }
if (mGestureState != null) {
mGestureState.dump(pw);
}