summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author wilsonshih <wilsonshih@google.com> 2019-10-22 20:42:40 +0800
committer wilsonshih <wilsonshih@google.com> 2019-10-30 20:30:13 +0800
commitd528106fbca5867b75daef355f38609584dd5ee4 (patch)
tree458fcb864f86cc7c94567eb44da71c1650d96c58
parent90dfd6b00928209a2ca4cf067df496b65e39d44a (diff)
Consolidate ActivityStack#finishCurrentActivityLocked checking
This CL is to fix a bug that found in TransitionSelectionTests#testCloseTask_BothWallpaper_SlowStop may flaky because when TopActivity launched & call finish(), the activity will destroy too soon before BottomActivity resume & idle. When TopActivity launched, suppose BottomActivity's nowVisible state should be false because both activities are fullscreen activity & TopActivity should cover BottomActivity. After TopActivity called finish(), normally the activity should wait for BottomActivity visible and then destroy, and this test is to verify if TRANSIT_WALLPAPER_INTRA_CLOSE state will coming when opening & closing animation target with wallpaper theme are animating case. But the flakiness may happen if device is in low-performance stage, when TopActivity launched, system calls setClientHidden for BottomActivity's all windows to update its viewVisibility but can't update in time, and then the next relayoutWindow comes, mis-detected BottomActivity's Floating child window as drawn state, so that can't update BottomActivity's nowVisible state as invisible with onWindowsGone(). So when TopActivity called finish(), TopActivity will soon going to destroy state since BottomActivity is still in nowVisible state. The fix is to add isNextNotYetVisible, if the next activity the nowVisible or visible is not yet true, which means we need to add the current finishing activity into stopping list and destory until the next activity idle. Bug: 140088359 Test: atest TransitionSelectionTests Change-Id: If1907d71135158bafea69881205f351ab666025e Merged-In: If1907d71135158bafea69881205f351ab666025e
-rw-r--r--services/core/java/com/android/server/wm/ActivityStack.java10
1 files changed, 7 insertions, 3 deletions
diff --git a/services/core/java/com/android/server/wm/ActivityStack.java b/services/core/java/com/android/server/wm/ActivityStack.java
index 6bed46226b42..80fe30d1f80c 100644
--- a/services/core/java/com/android/server/wm/ActivityStack.java
+++ b/services/core/java/com/android/server/wm/ActivityStack.java
@@ -4096,9 +4096,13 @@ class ActivityStack extends ConfigurationContainer {
final ActivityDisplay display = getDisplay();
final ActivityRecord next = display.topRunningActivity(true /* considerKeyguardState */);
final boolean isFloating = r.getConfiguration().windowConfiguration.tasksAreFloating();
-
- if (mode == FINISH_AFTER_VISIBLE && (r.visible || r.nowVisible)
- && next != null && !next.nowVisible && !isFloating) {
+ // isNextNotYetVisible is to check if the next activity is invisible, or it has been
+ // requested to be invisible but its windows haven't reported as invisible. If so, it
+ // implied that the current finishing activity should be added into stopping list rather
+ // than destroying it immediately.
+ final boolean isNextNotYetVisible = next != null && (!next.nowVisible || !next.visible);
+ if (mode == FINISH_AFTER_VISIBLE && (r.visible || r.nowVisible) && isNextNotYetVisible
+ && !isFloating) {
if (!mStackSupervisor.mStoppingActivities.contains(r)) {
addToStopping(r, false /* scheduleIdle */, false /* idleDelayed */,
"finishCurrentActivityLocked");