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
This commit is contained in:
Vishnu Nair
2018-12-07 09:45:41 -08:00
parent c1ea10447f
commit cb122ec8a5

View File

@@ -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;
}
}
/**