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

Commit 3f0e1f9e authored by Vishnu Nair's avatar Vishnu Nair Committed by Hung-ying Tyan
Browse files

DO NOT MERGE: WM: Restrict SC Builder to set a single surface type

When building a surface control, only allow a single surface type to be set, clearing any
previously set types so the surface creating flags remain valid.

Test: reboot device, rotate the screen, enter and exit multi window, check the UI is normal Dump SF layer and check the container layer is set successfully

Bug: 111164627

Change-Id: Ifc022881ee7fec0561a39ce647868d5b43cb49d9
(cherry picked from cb122ec8)
parent d57240cb
Loading
Loading
Loading
Loading
+17 −4
Original line number Diff line number Diff line
@@ -528,9 +528,9 @@ public class SurfaceControl implements Parcelable {
         */
        public Builder setColorLayer(boolean isColorLayer) {
            if (isColorLayer) {
                mFlags |= FX_SURFACE_DIM;
                setFlags(FX_SURFACE_DIM, FX_SURFACE_MASK);
            } else {
                mFlags &= ~FX_SURFACE_DIM;
                setBufferLayer();
            }
            return this;
        }
@@ -545,13 +545,21 @@ public class SurfaceControl implements Parcelable {
         */
        public Builder setContainerLayer(boolean isContainerLayer) {
            if (isContainerLayer) {
                mFlags |= FX_SURFACE_CONTAINER;
                setFlags(FX_SURFACE_CONTAINER, FX_SURFACE_MASK);
            } else {
                mFlags &= ~FX_SURFACE_CONTAINER;
                setBufferLayer();
            }
            return this;
        }

        /**
         * Indicates whether a buffer layer is to be constructed.
         *
         */
        public Builder setBufferLayer() {
            return setFlags(FX_SURFACE_NORMAL, FX_SURFACE_MASK);
        }

        /**
         * Set 'Surface creation flags' such as {@link HIDDEN}, {@link SECURE}.
         *
@@ -562,6 +570,11 @@ public class SurfaceControl implements Parcelable {
            mFlags = flags;
            return this;
        }

        private Builder setFlags(int flags, int mask) {
            mFlags = (mFlags & ~mask) | flags;
            return this;
        }
    }

    /**