From ccda7bc725f5ad883fef28781637737420c3a623 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Thu, 3 Jun 2021 13:19:50 -0700 Subject: [PATCH] Workaround for apps to stop before removing the task - With live tile enabled, the race between destroying the task and killing the process is more evident since the app may not get stopped at all. For now, when dismissing, defer removing the task until we've finished the recents animation to allow the app to be stopped accordingly Bug: 184899234 Test: Dismiss the task from overview, check that the app gets lifecycle events Change-Id: Ib3ea479643d65859fe4cd580b4c347b87130a69d --- .../android/quickstep/RecentsActivity.java | 3 +- .../android/quickstep/views/RecentsView.java | 30 +++++++++++++------ 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/quickstep/src/com/android/quickstep/RecentsActivity.java b/quickstep/src/com/android/quickstep/RecentsActivity.java index 0e9e3ad029..d43bb24a1e 100644 --- a/quickstep/src/com/android/quickstep/RecentsActivity.java +++ b/quickstep/src/com/android/quickstep/RecentsActivity.java @@ -350,8 +350,7 @@ public final class RecentsActivity extends StatefulActivity { public void startHome() { if (LIVE_TILE.get()) { RecentsView recentsView = getOverviewPanel(); - recentsView.switchToScreenshot(() -> recentsView.finishRecentsAnimation(true, - this::startHomeInternal)); + recentsView.switchToScreenshotAndFinishAnimationToRecents(this::startHomeInternal); } else { startHomeInternal(); } diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index 17d1afc168..166fd80970 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -176,6 +176,10 @@ public abstract class RecentsView CONTENT_ALPHA = new FloatProperty("contentAlpha") { @Override @@ -2423,8 +2427,11 @@ public abstract class RecentsView ActivityManagerWrapper.getInstance() - .removeTask(dismissedTaskId)); + switchToScreenshotAndFinishAnimationToRecents(() -> { + UI_HELPER_EXECUTOR.getHandler().postDelayed(() -> + ActivityManagerWrapper.getInstance().removeTask( + dismissedTaskId), REMOVE_TASK_WAIT_FOR_APP_STOP_MS); + }); mActivity.getStatsLogManager().logger() .withItemInfo(dismissedTaskView.getItemInfo()) .log(LAUNCHER_TASK_DISMISS_SWIPE_UP); @@ -2529,10 +2536,13 @@ public abstract class RecentsView { if (isSuccess) { // Remove all the task views now - UI_HELPER_EXECUTOR.execute( - ActivityManagerWrapper.getInstance()::removeAllRecentTasks); - removeTasksViewsAndClearAllButton(); - startHome(); + switchToScreenshotAndFinishAnimationToRecents(() -> { + UI_HELPER_EXECUTOR.getHandler().postDelayed( + ActivityManagerWrapper.getInstance()::removeAllRecentTasks, + REMOVE_TASK_WAIT_FOR_APP_STOP_MS); + removeTasksViewsAndClearAllButton(); + startHome(); + }); } mPendingAnimation = null; }); @@ -2687,9 +2697,7 @@ public abstract class RecentsView finishRecentsAnimation(true /* toRecents */, - this::updateRecentsRotation)); + switchToScreenshotAndFinishAnimationToRecents(this::updateRecentsRotation); mEnableDrawingLiveTile = false; } else { updateRecentsRotation(); @@ -3687,6 +3695,10 @@ public abstract class RecentsView finishRecentsAnimation(true /* toRecents */, onFinishRunnable)); + } + /** * Switch the current running task view to static snapshot mode, * capturing the snapshot at the same time.