Skip transition only when transferring starting from visible activity

Otherwise if the starting window is transferring when it is added but
not yet drawn, the first opening transition will be skipped.

Bug: 196636209
Test: ActivityRecordTests#testTransferStartingWindow,
     testTransferStartingWindowFromFinishingActivity

Change-Id: I1047944351e574cfd88fa1eb879d3b9bc55440c3
This commit is contained in:
Riddle Hsu
2021-08-23 12:13:12 -06:00
parent ca7eb3f9ad
commit 0e1d1e76e9
2 changed files with 9 additions and 3 deletions

View File

@@ -3914,7 +3914,9 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
if (tStartingWindow != null && fromActivity.mStartingSurface != null) {
// In this case, the starting icon has already been displayed, so start
// letting windows get shown immediately without any more transitions.
getDisplayContent().mSkipAppTransitionAnimation = true;
if (fromActivity.mVisible) {
mDisplayContent.mSkipAppTransitionAnimation = true;
}
ProtoLog.v(WM_DEBUG_STARTING_WINDOW, "Moving existing starting %s"
+ " from %s to %s", tStartingWindow, fromActivity, this);

View File

@@ -2509,8 +2509,10 @@ public class ActivityRecordTests extends WindowTestsBase {
@Test
public void testTransferStartingWindow() {
registerTestStartingWindowOrganizer();
final ActivityRecord activity1 = new ActivityBuilder(mAtm).setCreateTask(true).build();
final ActivityRecord activity2 = new ActivityBuilder(mAtm).setCreateTask(true).build();
final ActivityRecord activity1 = new ActivityBuilder(mAtm).setCreateTask(true)
.setVisible(false).build();
final ActivityRecord activity2 = new ActivityBuilder(mAtm).setCreateTask(true)
.setVisible(false).build();
activity1.addStartingWindow(mPackageName,
android.R.style.Theme, null, "Test", 0, 0, 0, 0, null, true, true, false, true,
false, false);
@@ -2519,6 +2521,7 @@ public class ActivityRecordTests extends WindowTestsBase {
android.R.style.Theme, null, "Test", 0, 0, 0, 0, activity1,
true, true, false, true, false, false);
waitUntilHandlersIdle();
assertFalse(mDisplayContent.mSkipAppTransitionAnimation);
assertNoStartingWindow(activity1);
assertHasStartingWindow(activity2);
}
@@ -2626,6 +2629,7 @@ public class ActivityRecordTests extends WindowTestsBase {
false /* newTask */, false /* isTaskSwitch */, null /* options */,
null /* sourceRecord */);
assertTrue(mDisplayContent.mSkipAppTransitionAnimation);
assertNull(middle.mStartingWindow);
assertHasStartingWindow(top);
assertTrue(top.isVisible());