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

Commit cb122ec8 authored by Vishnu Nair's avatar Vishnu Nair
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
parent c1ea1044
Loading
Loading
Loading
Loading
+17 −4
Original line number Diff line number Diff line
@@ -530,9 +530,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;
        }
@@ -547,13 +547,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}.
         *
@@ -564,6 +572,11 @@ public class SurfaceControl implements Parcelable {
            mFlags = flags;
            return this;
        }

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

    /**