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

Commit 0a959d2f authored by Tiger Huang's avatar Tiger Huang
Browse files

Remove PRIVATE_FLAG_IS_SCREEN_DECOR

Applying this flag won't make the window provide insets anymore in the
new insets system. A screen decor window should use providesInsetsTypes
to provide insets instead.

Bug: 149813814
Test: Presubmit
Change-Id: I567bfc4f2e687aa2e9d65fe8e7edda867497c324
parent 915c8155
Loading
Loading
Loading
Loading
+0 −14
Original line number Diff line number Diff line
@@ -2156,15 +2156,6 @@ public interface WindowManager extends ViewManager {
         */
        public static final int PRIVATE_FLAG_IS_ROUNDED_CORNERS_OVERLAY = 0x00100000;

        /**
         * Flag to indicate that this window should be considered a screen decoration similar to the
         * nav bar and status bar. This will cause this window to affect the window insets reported
         * to other windows when it is visible.
         * @hide
         */
        @RequiresPermission(permission.STATUS_BAR_SERVICE)
        public static final int PRIVATE_FLAG_IS_SCREEN_DECOR = 0x00400000;

        /**
         * Flag to indicate that the status bar window is in a state such that it forces showing
         * the navigation bar unless the navigation bar window is explicitly set to
@@ -2270,7 +2261,6 @@ public interface WindowManager extends ViewManager {
                PRIVATE_FLAG_SUSTAINED_PERFORMANCE_MODE,
                SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS,
                PRIVATE_FLAG_IS_ROUNDED_CORNERS_OVERLAY,
                PRIVATE_FLAG_IS_SCREEN_DECOR,
                PRIVATE_FLAG_STATUS_FORCE_SHOW_NAVIGATION,
                PRIVATE_FLAG_COLOR_SPACE_AGNOSTIC,
                PRIVATE_FLAG_USE_BLAST,
@@ -2357,10 +2347,6 @@ public interface WindowManager extends ViewManager {
                        mask = PRIVATE_FLAG_IS_ROUNDED_CORNERS_OVERLAY,
                        equals = PRIVATE_FLAG_IS_ROUNDED_CORNERS_OVERLAY,
                        name = "IS_ROUNDED_CORNERS_OVERLAY"),
                @ViewDebug.FlagToString(
                        mask = PRIVATE_FLAG_IS_SCREEN_DECOR,
                        equals = PRIVATE_FLAG_IS_SCREEN_DECOR,
                        name = "IS_SCREEN_DECOR"),
                @ViewDebug.FlagToString(
                        mask = PRIVATE_FLAG_STATUS_FORCE_SHOW_NAVIGATION,
                        equals = PRIVATE_FLAG_STATUS_FORCE_SHOW_NAVIGATION,
+3 −73
Original line number Diff line number Diff line
@@ -66,7 +66,6 @@ import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_DRAW_BA
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_SHOW_STATUS_BAR;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_INSET_PARENT_FRAME_BY_IME;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_INTERCEPT_GLOBAL_DRAG_AND_DROP;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_IS_SCREEN_DECOR;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_TRUSTED_OVERLAY;
import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION;
import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD;
@@ -279,7 +278,6 @@ public class DisplayPolicy {
    private volatile boolean mKeyguardDrawComplete;
    private volatile boolean mWindowManagerDrawComplete;

    private final ArraySet<WindowState> mScreenDecorWindows = new ArraySet<>();
    private WindowState mStatusBar = null;
    private WindowState mNotificationShade = null;
    private final int[] mStatusBarHeightForRotation = new int[4];
@@ -864,19 +862,7 @@ public class DisplayPolicy {
     * @param attrs The window layout parameters to be modified.  These values
     * are modified in-place.
     */
    public void adjustWindowParamsLw(WindowState win, WindowManager.LayoutParams attrs,
            int callingPid, int callingUid) {

        final boolean isScreenDecor = (attrs.privateFlags & PRIVATE_FLAG_IS_SCREEN_DECOR) != 0;
        if (mScreenDecorWindows.contains(win)) {
            if (!isScreenDecor) {
                // No longer has the flag set, so remove from the set.
                mScreenDecorWindows.remove(win);
            }
        } else if (isScreenDecor && hasStatusBarServicePermission(callingPid, callingUid)) {
            mScreenDecorWindows.add(win);
        }

    public void adjustWindowParamsLw(WindowState win, WindowManager.LayoutParams attrs) {
        switch (attrs.type) {
            case TYPE_SYSTEM_OVERLAY:
            case TYPE_SECURE_SYSTEM_OVERLAY:
@@ -966,11 +952,6 @@ public class DisplayPolicy {
     * WindowManagerImpl.ADD_MULTIPLE_SINGLETON
     */
    int validateAddingWindowLw(WindowManager.LayoutParams attrs, int callingPid, int callingUid) {
        if ((attrs.privateFlags & PRIVATE_FLAG_IS_SCREEN_DECOR) != 0) {
            mContext.enforcePermission(
                    android.Manifest.permission.STATUS_BAR_SERVICE, callingPid, callingUid,
                    "DisplayPolicy");
        }
        if ((attrs.privateFlags & PRIVATE_FLAG_TRUSTED_OVERLAY) != 0) {
            mContext.enforcePermission(
                    android.Manifest.permission.INTERNAL_SYSTEM_WINDOW, callingPid, callingUid,
@@ -1090,10 +1071,6 @@ public class DisplayPolicy {
     * @param attrs Information about the window to be added.
     */
    void addWindowLw(WindowState win, WindowManager.LayoutParams attrs) {
        if ((attrs.privateFlags & PRIVATE_FLAG_IS_SCREEN_DECOR) != 0) {
            mScreenDecorWindows.add(win);
        }

        switch (attrs.type) {
            case TYPE_NOTIFICATION_SHADE:
                mNotificationShade = win;
@@ -1275,7 +1252,6 @@ public class DisplayPolicy {
        if (mLastFocusedWindow == win) {
            mLastFocusedWindow = null;
        }
        mScreenDecorWindows.remove(win);
    }

    private int getStatusBarHeight(DisplayFrames displayFrames) {
@@ -1457,14 +1433,12 @@ public class DisplayPolicy {
        }

        final int fl = attrs.flags;
        final int pfl = attrs.privateFlags;
        final boolean layoutInScreenAndInsetDecor = (fl & FLAG_LAYOUT_IN_SCREEN) != 0
                && (fl & FLAG_LAYOUT_INSET_DECOR) != 0;
        final boolean screenDecor = (pfl & PRIVATE_FLAG_IS_SCREEN_DECOR) != 0;
        final DisplayFrames displayFrames = isFixedRotationTransforming
                ? windowToken.getFixedRotationTransformDisplayFrames()
                : mDisplayContent.mDisplayFrames;
        if (layoutInScreenAndInsetDecor && !screenDecor) {
        if (layoutInScreenAndInsetDecor) {
            outDisplayCutout.set(
                    displayFrames.mDisplayCutout.calculateRelativeTo(outFrame).getDisplayCutout());
        } else {
@@ -1564,7 +1538,6 @@ public class DisplayPolicy {
                    simulatedWindowFrames, barContentFrames,
                    contentFrame -> layoutStatusBar(displayFrames, contentFrame));
        }
        layoutScreenDecorWindows(displayFrames, simulatedWindowFrames);
    }

    /**
@@ -1585,7 +1558,6 @@ public class DisplayPolicy {

        layoutNavigationBar(displayFrames, uiMode, null /* simulatedContentFrame */);
        layoutStatusBar(displayFrames, null /* simulatedContentFrame */);
        layoutScreenDecorWindows(displayFrames, null /* simulatedFrames */);
    }

    void updateHideNavInputEventReceiver() {
@@ -1640,47 +1612,6 @@ public class DisplayPolicy {
        state.getSource(ITYPE_BOTTOM_DISPLAY_CUTOUT).setFrame(u.left, s.bottom, u.right, u.bottom);
    }

    /**
     * Layout the decor windows with {@link #PRIVATE_FLAG_IS_SCREEN_DECOR}.
     *
     * @param displayFrames The display frames to be layouted.
     * @param simulatedFrames Non-null if the caller only needs the result of display frames (see
     *                        {@link WindowState#mSimulatedWindowFrames}).
     */
    private void layoutScreenDecorWindows(DisplayFrames displayFrames,
            WindowFrames simulatedFrames) {
        if (mScreenDecorWindows.isEmpty()) {
            return;
        }

        sTmpRect.setEmpty();
        final int displayId = displayFrames.mDisplayId;

        for (int i = mScreenDecorWindows.size() - 1; i >= 0; --i) {
            final WindowState w = mScreenDecorWindows.valueAt(i);
            if (w.getDisplayId() != displayId || !w.isVisible()) {
                // Skip if not on the same display or not visible.
                continue;
            }

            final boolean isSimulatedLayout = simulatedFrames != null;
            if (isSimulatedLayout) {
                w.setSimulatedWindowFrames(simulatedFrames);
            }
            getRotatedWindowBounds(displayFrames, w, sTmpScreenDecorFrame);
            final WindowFrames windowFrames = w.getLayoutingWindowFrames();
            windowFrames.setFrames(sTmpScreenDecorFrame /* parentFrame */,
                    sTmpScreenDecorFrame /* displayFrame */);
            try {
                w.computeFrame(displayFrames);
            } finally {
                if (isSimulatedLayout) {
                    w.setSimulatedWindowFrames(null);
                }
            }
        }
    }

    private void layoutStatusBar(DisplayFrames displayFrames, Rect simulatedContentFrame) {
        // decide where the status bar goes ahead of time
        if (mStatusBar == null) {
@@ -1819,8 +1750,7 @@ public class DisplayPolicy {
        // We've already done the navigation bar, status bar, and all screen decor windows. If the
        // status bar can receive input, we need to layout it again to accommodate for the IME
        // window.
        if ((win == mStatusBar && !canReceiveInput(win)) || win == mNavigationBar
                || mScreenDecorWindows.contains(win)) {
        if ((win == mStatusBar && !canReceiveInput(win)) || win == mNavigationBar) {
            return;
        }
        final WindowManager.LayoutParams attrs = win.getAttrs();
+4 −4
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ import static android.provider.Settings.Global.DEVELOPMENT_IGNORE_VENDOR_DISPLAY
import static android.provider.Settings.Global.DEVELOPMENT_RENDER_SHADOWS_IN_COMPOSITOR;
import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.Display.INVALID_DISPLAY;
import static android.view.WindowManager.DISPLAY_IME_POLICY_FALLBACK_DISPLAY;
import static android.view.WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW;
import static android.view.WindowManager.LayoutParams.FIRST_SUB_WINDOW;
import static android.view.WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
@@ -78,7 +79,6 @@ import static android.view.WindowManager.LayoutParams.TYPE_VOICE_INTERACTION;
import static android.view.WindowManager.LayoutParams.TYPE_VOLUME_OVERLAY;
import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER;
import static android.view.WindowManager.REMOVE_CONTENT_MODE_UNDEFINED;
import static android.view.WindowManager.DISPLAY_IME_POLICY_FALLBACK_DISPLAY;
import static android.view.WindowManager.TRANSIT_NONE;
import static android.view.WindowManager.TRANSIT_RELAUNCH;
import static android.view.WindowManagerGlobal.ADD_OKAY;
@@ -256,9 +256,9 @@ import android.view.View;
import android.view.WindowContentFrameStats;
import android.view.WindowInsets;
import android.view.WindowManager;
import android.view.WindowManager.DisplayImePolicy;
import android.view.WindowManager.LayoutParams;
import android.view.WindowManager.RemoveContentMode;
import android.view.WindowManager.DisplayImePolicy;
import android.view.WindowManagerGlobal;
import android.view.WindowManagerPolicyConstants.PointerEventListener;
import android.window.ClientWindowFrames;
@@ -1627,7 +1627,7 @@ public class WindowManagerService extends IWindowManager.Stub
            }

            final DisplayPolicy displayPolicy = displayContent.getDisplayPolicy();
            displayPolicy.adjustWindowParamsLw(win, win.mAttrs, callingPid, callingUid);
            displayPolicy.adjustWindowParamsLw(win, win.mAttrs);
            win.updateRequestedVisibility(requestedVisibility);

            res = displayPolicy.validateAddingWindowLw(attrs, callingPid, callingUid);
@@ -2197,7 +2197,7 @@ public class WindowManagerService extends IWindowManager.Stub
            int flagChanges = 0;
            int privateFlagChanges = 0;
            if (attrs != null) {
                displayPolicy.adjustWindowParamsLw(win, attrs, pid, uid);
                displayPolicy.adjustWindowParamsLw(win, attrs);
                win.mToken.adjustWindowParams(win, attrs);
                int disableFlags =
                        (attrs.systemUiVisibility | attrs.subtreeSystemUiVisibility) & DISABLE_MASK;
+0 −2
Original line number Diff line number Diff line
@@ -65,8 +65,6 @@
                  android:turnScreenOn="true" />
        <activity android:name="com.android.server.wm.TaskStackChangedListenerTest$ResumeWhilePausingActivity"
                  android:resumeWhilePausing="true"/>
        <activity android:name="com.android.server.wm.ScreenDecorWindowTests$TestActivity"
                  android:showWhenLocked="true" android:allowEmbedded="true"/>
        <activity android:name="com.android.server.wm.ActivityLeakTests$DetectLeakActivity" />
    </application>

+1 −2
Original line number Diff line number Diff line
@@ -236,8 +236,7 @@ public class DisplayPolicyTests extends WindowTestsBase {
        final WindowState activity = createBaseApplicationWindow();
        activity.mAttrs.privateFlags |= PRIVATE_FLAG_FORCE_DRAW_BAR_BACKGROUNDS;

        policy.adjustWindowParamsLw(activity, activity.mAttrs, 0 /* callingPid */,
                0 /* callingUid */);
        policy.adjustWindowParamsLw(activity, activity.mAttrs);
    }

    private WindowState createApplicationWindow() {
Loading