Use top fullscreen window to inherit SystemUI flags

The top fullscreen window of an app token is the one we use for
determining SystemUI flags normally. Thus, when showing the
snapshot, we need to inherit the flags from the same window.

Test: Open event in Calendar, go home, reopen Calendar app,
observe no status bar icon color change.
Test: go/wm-smoke

Change-Id: I96678000339617c8fc51e72c0f6e2e167f542491
Fixes: 62871307
This commit is contained in:
Jorim Jaggi
2017-08-17 13:41:11 +02:00
parent e33e796d26
commit 87fdbcbecb
3 changed files with 34 additions and 1 deletions

View File

@@ -62,6 +62,7 @@ import android.util.Slog;
import android.view.IApplicationToken;
import android.view.SurfaceControl;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;
import android.view.WindowManagerPolicy.StartingSurface;
import com.android.internal.util.ToBooleanFunction;
@@ -470,6 +471,20 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree
return delayed;
}
/**
* @return The to top most child window for which {@link LayoutParams#isFullscreen()} returns
* true.
*/
WindowState getTopFullscreenWindow() {
for (int i = mChildren.size() - 1; i >= 0; i--) {
final WindowState win = mChildren.get(i);
if (win != null && win.mAttrs.isFullscreen()) {
return win;
}
}
return null;
}
WindowState findMainWindow() {
WindowState candidate = null;
int j = mChildren.size();

View File

@@ -162,7 +162,7 @@ class TaskSnapshotSurface implements StartingSurface {
+ task);
return null;
}
final WindowState topFullscreenWindow = topFullscreenToken.findMainWindow();
final WindowState topFullscreenWindow = topFullscreenToken.getTopFullscreenWindow();
if (mainWindow == null || topFullscreenWindow == null) {
Slog.w(TAG, "TaskSnapshotSurface.create: Failed to find main window for token="
+ token);

View File

@@ -96,6 +96,24 @@ public class AppWindowTokenTests extends WindowTestsBase {
token.removeImmediately();
}
@Test
public void testGetTopFullscreenWindow() throws Exception {
final WindowTestUtils.TestAppWindowToken token =
new WindowTestUtils.TestAppWindowToken(mDisplayContent);
assertNull(token.getTopFullscreenWindow());
final WindowState window1 = createWindow(null, TYPE_BASE_APPLICATION, token, "window1");
final WindowState window11 = createWindow(null, TYPE_APPLICATION, token, "window11");
final WindowState window12 = createWindow(null, TYPE_APPLICATION, token, "window12");
assertEquals(window12, token.getTopFullscreenWindow());
window12.mAttrs.width = 500;
assertEquals(window11, token.getTopFullscreenWindow());
window11.mAttrs.width = 500;
assertEquals(window1, token.getTopFullscreenWindow());
token.removeImmediately();
}
@Test
public void testLandscapeSeascapeRotationByApp() throws Exception {
// Some plumbing to get the service ready for rotation updates.