Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 84bc3d7b authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Use opaque window as reference to show snapshot starting window

A fully transparent window won't display any content on screen.
It also cannot affect insets appearance (system ui flags) so it
should not affect creating starting window. Otherwise the status
bar color may be wrong when the starting window is showing.

Bug: 140811348
Test: atest AppWindowTokenTests#testGetTopFullscreenOpaqueWindow
Test: 1. Click quick search box on launcher.
      2. Dismiss the search view.
      3. Turn off screen and unlock.
      4. Check the text color of status bar.

Change-Id: I54f837295a32d3ab6bb54d2d69aa50d8f50b0fa9
parent f06d584d
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
@@ -335,13 +335,6 @@ public interface WindowManagerPolicy extends WindowManagerPolicyConstants {
         */
        boolean isAnimatingLw();

        /**
         * @return Whether the window can affect SystemUI flags, meaning that SystemUI (system bars,
         *         for example) will be  affected by the flags specified in this window. This is the
         *         case when the surface is on screen but not exiting.
         */
        boolean canAffectSystemUiFlags();

        /**
         * Is this window considered to be gone for purposes of layout?
         */
+3 −3
Original line number Diff line number Diff line
@@ -5576,12 +5576,12 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A

    /**
     * @return The to top most child window for which {@link LayoutParams#isFullscreen()} returns
     *         true.
     *         true and isn't fully transparent.
     */
    WindowState getTopFullscreenWindow() {
    WindowState getTopFullscreenOpaqueWindow() {
        for (int i = mChildren.size() - 1; i >= 0; i--) {
            final WindowState win = mChildren.get(i);
            if (win != null && win.mAttrs.isFullscreen()) {
            if (win != null && win.mAttrs.isFullscreen() && !win.isFullyTransparent()) {
                return win;
            }
        }
+5 −5
Original line number Diff line number Diff line
@@ -511,16 +511,16 @@ class TaskSnapshotController {
    }

    /**
     * @return The SystemUI visibility flags for the top fullscreen window in the given
     * @return The SystemUI visibility flags for the top fullscreen opaque window in the given
     *         {@param task}.
     */
    private int getSystemUiVisibility(Task task) {
        final ActivityRecord topFullscreenActivity = task.getTopFullscreenActivity();
        final WindowState topFullscreenWindow = topFullscreenActivity != null
                ? topFullscreenActivity.getTopFullscreenWindow()
        final WindowState topFullscreenOpaqueWindow = topFullscreenActivity != null
                ? topFullscreenActivity.getTopFullscreenOpaqueWindow()
                : null;
        if (topFullscreenWindow != null) {
            return topFullscreenWindow.getSystemUiVisibility();
        if (topFullscreenOpaqueWindow != null) {
            return topFullscreenOpaqueWindow.getSystemUiVisibility();
        }
        return 0;
    }
+8 −8
Original line number Diff line number Diff line
@@ -155,7 +155,7 @@ class TaskSnapshotSurface implements StartingSurface {
        final MergedConfiguration tmpMergedConfiguration = new MergedConfiguration();
        final TaskDescription taskDescription = new TaskDescription();
        taskDescription.setBackgroundColor(WHITE);
        final WindowState topFullscreenWindow;
        final WindowState topFullscreenOpaqueWindow;
        final int sysUiVis;
        final int windowFlags;
        final int windowPrivateFlags;
@@ -175,15 +175,15 @@ class TaskSnapshotSurface implements StartingSurface {
                        + task);
                return null;
            }
            topFullscreenWindow = topFullscreenActivity.getTopFullscreenWindow();
            if (mainWindow == null || topFullscreenWindow == null) {
            topFullscreenOpaqueWindow = topFullscreenActivity.getTopFullscreenOpaqueWindow();
            if (mainWindow == null || topFullscreenOpaqueWindow == null) {
                Slog.w(TAG, "TaskSnapshotSurface.create: Failed to find main window for activity="
                        + activity);
                return null;
            }
            sysUiVis = topFullscreenWindow.getSystemUiVisibility();
            windowFlags = topFullscreenWindow.getAttrs().flags;
            windowPrivateFlags = topFullscreenWindow.getAttrs().privateFlags;
            sysUiVis = topFullscreenOpaqueWindow.getSystemUiVisibility();
            windowFlags = topFullscreenOpaqueWindow.getAttrs().flags;
            windowPrivateFlags = topFullscreenOpaqueWindow.getAttrs().privateFlags;

            layoutParams.packageName = mainWindow.getAttrs().packageName;
            layoutParams.windowAnimations = mainWindow.getAttrs().windowAnimations;
@@ -206,7 +206,7 @@ class TaskSnapshotSurface implements StartingSurface {
            }
            taskBounds = new Rect();
            task.getBounds(taskBounds);
            currentOrientation = topFullscreenWindow.getConfiguration().orientation;
            currentOrientation = topFullscreenOpaqueWindow.getConfiguration().orientation;
        }
        try {
            final int res = session.addToDisplay(window, window.mSeq, layoutParams,
@@ -222,7 +222,7 @@ class TaskSnapshotSurface implements StartingSurface {
        final TaskSnapshotSurface snapshotSurface = new TaskSnapshotSurface(service, window,
                surfaceControl, snapshot, layoutParams.getTitle(), taskDescription, sysUiVis,
                windowFlags, windowPrivateFlags, taskBounds,
                currentOrientation, topFullscreenWindow.getClientInsetsState());
                currentOrientation, topFullscreenOpaqueWindow.getClientInsetsState());
        window.setOuter(snapshotSurface);
        try {
            session.relayout(window, window.mSeq, layoutParams, -1, -1, View.VISIBLE, 0, -1,
+11 −5
Original line number Diff line number Diff line
@@ -1642,11 +1642,17 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
                && (parentAndClientVisible || isAnimating(TRANSITION | PARENTS));
    }

    // TODO: Another visibility method that was added late in the release to minimize risk.
    @Override
    public boolean canAffectSystemUiFlags() {
        final boolean translucent = mAttrs.alpha == 0.0f;
        if (translucent) {
    boolean isFullyTransparent() {
        return mAttrs.alpha == 0f;
    }

    /**
     * @return Whether the window can affect SystemUI flags, meaning that SystemUI (system bars,
     *         for example) will be  affected by the flags specified in this window. This is the
     *         case when the surface is on screen but not exiting.
     */
    boolean canAffectSystemUiFlags() {
        if (isFullyTransparent()) {
            return false;
        }
        if (mActivityRecord == null) {
Loading