From cb122ec8a59f5ccd1fba5b0d24584ffed58c2539 Mon Sep 17 00:00:00 2001 From: Vishnu Nair Date: Fri, 7 Dec 2018 09:45:41 -0800 Subject: [PATCH] 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 --- core/java/android/view/SurfaceControl.java | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/core/java/android/view/SurfaceControl.java b/core/java/android/view/SurfaceControl.java index 66f16d57c8289..1dbe166899dc8 100644 --- a/core/java/android/view/SurfaceControl.java +++ b/core/java/android/view/SurfaceControl.java @@ -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; + } } /**