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

Commit 089d45de authored by Jorim Jaggi's avatar Jorim Jaggi Committed by Android (Google) Code Review
Browse files

Merge "Fix snapshots for dialogs" into oc-dr1-dev

parents 5898d521 e6c6ecb2
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -2591,5 +2591,16 @@ public interface WindowManager extends ViewManager {
            encoder.addProperty("type", type);
            encoder.addProperty("flags", flags);
        }

        /**
         * @hide
         * @return True if the layout parameters will cause the window to cover the full screen;
         *         false otherwise.
         */
        public boolean isFullscreen() {
            return x == 0 && y == 0
                    && width == WindowManager.LayoutParams.MATCH_PARENT
                    && height == WindowManager.LayoutParams.MATCH_PARENT;
        }
    }
}
+2 −8
Original line number Diff line number Diff line
@@ -5417,7 +5417,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            // represent should be hidden or if we should hide the lockscreen. For attached app
            // windows we defer the decision to the window it is attached to.
            if (appWindow && attached == null) {
                if (isFullscreen(attrs) && StackId.normallyFullscreenWindows(stackId)) {
                if (attrs.isFullscreen() && StackId.normallyFullscreenWindows(stackId)) {
                    if (DEBUG_LAYOUT) Slog.v(TAG, "Fullscreen window: " + win);
                    mTopFullscreenOpaqueWindowState = win;
                    if (mTopFullscreenOpaqueOrDimmingWindowState == null) {
@@ -5456,7 +5456,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        // separately, because both the "real fullscreen" opaque window and the one for the docked
        // stack can control View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR.
        if (mTopDockedOpaqueWindowState == null && affectsSystemUi && appWindow && attached == null
                && isFullscreen(attrs) && stackId == DOCKED_STACK_ID) {
                && attrs.isFullscreen() && stackId == DOCKED_STACK_ID) {
            mTopDockedOpaqueWindowState = win;
            if (mTopDockedOpaqueOrDimmingWindowState == null) {
                mTopDockedOpaqueOrDimmingWindowState = win;
@@ -5481,12 +5481,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        }
    }

    private boolean isFullscreen(WindowManager.LayoutParams attrs) {
        return attrs.x == 0 && attrs.y == 0
                && attrs.width == WindowManager.LayoutParams.MATCH_PARENT
                && attrs.height == WindowManager.LayoutParams.MATCH_PARENT;
    }

    /** {@inheritDoc} */
    @Override
    public int finishPostLayoutPolicyLw() {
+7 −7
Original line number Diff line number Diff line
@@ -2992,14 +2992,14 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
                // Don't include wallpaper in bounds calculation
                if (!w.mIsWallpaper && !mutableIncludeFullDisplay.value) {
                    if (includeDecor) {
                        final TaskStack stack = w.getStack();
                        if (stack != null) {
                            stack.getBounds(frame);
                        }
                        final Task task = w.getTask();
                        if (task != null) {
                            task.getBounds(frame);
                        } else {

                        // We want to screenshot with the exact bounds of the surface of the app. Thus,
                        // intersect it with the frame.
                        frame.intersect(w.mFrame);
                            // No task bounds? Too bad! Ain't no screenshot then.
                            return true;
                        }
                    } else {
                        final Rect wf = w.mFrame;
                        final Rect cr = w.mContentInsets;
+11 −0
Original line number Diff line number Diff line
@@ -624,6 +624,17 @@ class Task extends WindowContainer<AppWindowToken> implements DimLayer.DimLayerU
        return token != null ? token.findMainWindow() : null;
    }

    AppWindowToken getTopFullscreenAppToken() {
        for (int i = mChildren.size() - 1; i >= 0; i--) {
            final AppWindowToken token = mChildren.get(i);
            final WindowState win = token.findMainWindow();
            if (win != null && win.mAttrs.isFullscreen()) {
                return token;
            }
        }
        return null;
    }

    AppWindowToken getTopVisibleAppToken() {
        for (int i = mChildren.size() - 1; i >= 0; i--) {
            final AppWindowToken token = mChildren.get(i);
+27 −19
Original line number Diff line number Diff line
@@ -151,14 +151,27 @@ class TaskSnapshotSurface implements StartingSurface {
        final int currentOrientation;
        synchronized (service.mWindowMap) {
            final WindowState mainWindow = token.findMainWindow();
            if (mainWindow == null) {
            final Task task = token.getTask();
            if (task == null) {
                Slog.w(TAG, "TaskSnapshotSurface.create: Failed to find task for token="
                        + token);
                return null;
            }
            final AppWindowToken topFullscreenToken = token.getTask().getTopFullscreenAppToken();
            if (topFullscreenToken == null) {
                Slog.w(TAG, "TaskSnapshotSurface.create: Failed to find top fullscreen for task="
                        + task);
                return null;
            }
            final WindowState topFullscreenWindow = topFullscreenToken.findMainWindow();
            if (mainWindow == null || topFullscreenWindow == null) {
                Slog.w(TAG, "TaskSnapshotSurface.create: Failed to find main window for token="
                        + token);
                return null;
            }
            sysUiVis = mainWindow.getSystemUiVisibility();
            windowFlags = mainWindow.getAttrs().flags;
            windowPrivateFlags = mainWindow.getAttrs().privateFlags;
            sysUiVis = topFullscreenWindow.getSystemUiVisibility();
            windowFlags = topFullscreenWindow.getAttrs().flags;
            windowPrivateFlags = topFullscreenWindow.getAttrs().privateFlags;

            layoutParams.dimAmount = mainWindow.getAttrs().dimAmount;
            layoutParams.type = TYPE_APPLICATION_STARTING;
@@ -172,8 +185,6 @@ class TaskSnapshotSurface implements StartingSurface {
            layoutParams.width = LayoutParams.MATCH_PARENT;
            layoutParams.height = LayoutParams.MATCH_PARENT;
            layoutParams.systemUiVisibility = sysUiVis;
            final Task task = token.getTask();
            if (task != null) {
            layoutParams.setTitle(String.format(TITLE_FORMAT, task.mTaskId));

            final TaskDescription taskDescription = task.getTaskDescription();
@@ -184,10 +195,7 @@ class TaskSnapshotSurface implements StartingSurface {
            }
            taskBounds = new Rect();
            task.getBounds(taskBounds);
            } else {
                taskBounds = null;
            }
            currentOrientation = mainWindow.getConfiguration().orientation;
            currentOrientation = topFullscreenWindow.getConfiguration().orientation;
        }
        try {
            final int res = session.addToDisplay(window, window.mSeq, layoutParams,