Consolidate ActivityRecord#completeFinishing 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: 139111132 Test: atest TransitionSelectionTests Change-Id: If1907d71135158bafea69881205f351ab666025e
This commit is contained in:
@@ -1844,9 +1844,14 @@ final class ActivityRecord extends ConfigurationContainer {
|
||||
final ActivityRecord next = getDisplay().topRunningActivity(
|
||||
true /* considerKeyguardState */);
|
||||
final boolean isVisible = visible || nowVisible;
|
||||
// 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 destroy immediately.
|
||||
final boolean isNextNotYetVisible = next != null && (!next.nowVisible || !next.visible);
|
||||
final ActivityStack stack = getActivityStack();
|
||||
final boolean notFocusedStack = stack != mRootActivityContainer.getTopDisplayFocusedStack();
|
||||
if (isVisible && next != null && !next.nowVisible) {
|
||||
if (isVisible && isNextNotYetVisible) {
|
||||
addToStopping(false /* scheduleIdle */, false /* idleDelayed */,
|
||||
"completeFinishing");
|
||||
if (DEBUG_STATES) {
|
||||
|
||||
@@ -1032,6 +1032,7 @@ public class ActivityRecordTests extends ActivityTestsBase {
|
||||
// simulates finishing in non-focused stack in split-screen.
|
||||
final ActivityStack stack = new StackBuilder(mRootActivityContainer).build();
|
||||
stack.getChildAt(0).getChildAt(0).nowVisible = true;
|
||||
stack.getChildAt(0).getChildAt(0).visible = true;
|
||||
|
||||
topActivity.completeFinishing("test");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user