Merge cherrypicks of [16730784] into sc-v2-release.

Change-Id: I55aea6fa65ff68210634113f8ad895fd8781e078
This commit is contained in:
Android Build Coastguard Worker
2022-02-01 00:43:56 +00:00
2 changed files with 36 additions and 8 deletions

View File

@@ -6913,7 +6913,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
@Override
void prepareSurfaces() {
final boolean show = isVisible() || isAnimating(TRANSITION | PARENTS,
final boolean show = isVisible() || isAnimating(PARENTS,
ANIMATION_TYPE_APP_TRANSITION | ANIMATION_TYPE_RECENTS);
if (mSurfaceControl != null) {

View File

@@ -80,7 +80,6 @@ import static com.android.server.wm.ActivityRecord.State.RESUMED;
import static com.android.server.wm.ActivityRecord.State.STARTED;
import static com.android.server.wm.ActivityRecord.State.STOPPED;
import static com.android.server.wm.ActivityRecord.State.STOPPING;
import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_APP_TRANSITION;
import static com.android.server.wm.TaskFragment.TASK_FRAGMENT_VISIBILITY_INVISIBLE;
import static com.android.server.wm.TaskFragment.TASK_FRAGMENT_VISIBILITY_VISIBLE;
import static com.android.server.wm.TaskFragment.TASK_FRAGMENT_VISIBILITY_VISIBLE_BEHIND_TRANSLUCENT;
@@ -3124,7 +3123,7 @@ public class ActivityRecordTests extends WindowTestsBase {
}
@Test
public void testInClosingAnimation_doNotHideSurface() {
public void testInClosingAnimation_visibilityNotCommitted_doNotHideSurface() {
final WindowState app = createWindow(null, TYPE_APPLICATION, "app");
makeWindowVisibleAndDrawn(app);
@@ -3133,16 +3132,45 @@ public class ActivityRecordTests extends WindowTestsBase {
mDisplayContent.mClosingApps.add(app.mActivityRecord);
mDisplayContent.prepareAppTransition(TRANSIT_CLOSE);
// Update visibility and call to remove window
app.mActivityRecord.commitVisibility(false, false);
// Remove window during transition, so it is requested to hide, but won't be committed until
// the transition is finished.
app.mActivityRecord.onRemovedFromDisplay();
assertTrue(mDisplayContent.mClosingApps.contains(app.mActivityRecord));
assertFalse(app.mActivityRecord.isVisibleRequested());
assertTrue(app.mActivityRecord.isVisible());
assertTrue(app.mActivityRecord.isSurfaceShowing());
// Start transition.
app.mActivityRecord.prepareSurfaces();
// Because the app is waiting for transition, it should not hide the surface.
assertTrue(app.mActivityRecord.isSurfaceShowing());
}
// Ensure onAnimationFinished will callback when the closing animation is finished.
verify(app.mActivityRecord).onAnimationFinished(eq(ANIMATION_TYPE_APP_TRANSITION),
eq(null));
@Test
public void testInClosingAnimation_visibilityCommitted_hideSurface() {
final WindowState app = createWindow(null, TYPE_APPLICATION, "app");
makeWindowVisibleAndDrawn(app);
// Put the activity in close transition.
mDisplayContent.mOpeningApps.clear();
mDisplayContent.mClosingApps.add(app.mActivityRecord);
mDisplayContent.prepareAppTransition(TRANSIT_CLOSE);
// Commit visibility before start transition.
app.mActivityRecord.commitVisibility(false, false);
assertFalse(app.mActivityRecord.isVisibleRequested());
assertFalse(app.mActivityRecord.isVisible());
assertTrue(app.mActivityRecord.isSurfaceShowing());
// Start transition.
app.mActivityRecord.prepareSurfaces();
// Because the app visibility has been committed before the transition start, it should hide
// the surface.
assertFalse(app.mActivityRecord.isSurfaceShowing());
}
private void assertHasStartingWindow(ActivityRecord atoken) {