Do not wait for invisible activity when turning on screen

The activity may somehow keep its surface while it is invisible.
That causes its window WindowState#isVisible() still returns true
and is added to the waiting list. Because the invisible activity
won't redraw, that leads to 1s screen on timeout.

Bug: 231390641
Test: atest WindowStateTests#testRequestDrawIfNeeded
Change-Id: I0374e61641b02bc59c4edf308ec6d3f6683409c2
This commit is contained in:
Riddle Hsu
2022-05-18 22:40:21 +08:00
parent e7b17199b6
commit 2430cb4edb
2 changed files with 9 additions and 0 deletions

View File

@@ -2171,6 +2171,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
return;
}
if (mActivityRecord != null) {
if (!mActivityRecord.mVisibleRequested) return;
if (mActivityRecord.allDrawn) {
// The allDrawn of activity is reset when the visibility is changed to visible, so
// the content should be ready if allDrawn is set.

View File

@@ -673,6 +673,14 @@ public class WindowStateTests extends WindowTestsBase {
// Keyguard host window should be always contained. The drawn app or app with starting
// window are unnecessary to draw.
assertEquals(Arrays.asList(keyguardHostWindow, startingWindow), outWaitingForDrawn);
// No need to wait for a window of invisible activity even if the window has surface.
final WindowState invisibleApp = mAppWindow;
invisibleApp.mActivityRecord.mVisibleRequested = false;
invisibleApp.mActivityRecord.allDrawn = false;
outWaitingForDrawn.clear();
invisibleApp.requestDrawIfNeeded(outWaitingForDrawn);
assertTrue(outWaitingForDrawn.isEmpty());
}
@UseTestDisplay(addWindows = W_ABOVE_ACTIVITY)