Fix 5x and 6P crash when using HWC2to1adapter
Angler and Bullhead crash when a SolidColor layer is used in
combination with HWC2to1Adapter. This is due to assumptions in
the HWC1 code (non-null handle field = valid pointer). This
assumption is incorrect with a background layer because it will
set the field backgroundcolor...which occupies the same location
as handle field in hwc_layer_1_t.
This patch detects whether the HWC supports BACKGROUND layer and
sets backgroundcolor/handle accordingly to HWC assumption.
Test: Manual on Angler and Bullhead.
Change-Id: Ic5c3366a4a8989f3a82b6367258bad8af25d3990
diff --git a/services/surfaceflinger/DisplayHardware/HWC2On1Adapter.h b/services/surfaceflinger/DisplayHardware/HWC2On1Adapter.h
index 047e3aa..daa988c 100644
--- a/services/surfaceflinger/DisplayHardware/HWC2On1Adapter.h
+++ b/services/surfaceflinger/DisplayHardware/HWC2On1Adapter.h
@@ -63,6 +63,10 @@
getAdapter(device)->doGetCapabilities(outCount, outCapabilities);
}
+ bool supportsBackgroundColor() {
+ return mHwc1SupportsBackgroundColor;
+ }
+
// getFunction
hwc2_function_pointer_t doGetFunction(HWC2::FunctionDescriptor descriptor);
@@ -576,6 +580,7 @@
size_t mHwc1Id;
bool mHasUnsupportedDataspace;
bool mHasUnsupportedPlaneAlpha;
+ bool mHasUnsupportedBackgroundColor;
};
template <typename ...Args>
@@ -656,6 +661,7 @@
struct hwc_composer_device_1* const mHwc1Device;
const uint8_t mHwc1MinorVersion;
bool mHwc1SupportsVirtualDisplays;
+ bool mHwc1SupportsBackgroundColor;
class Callbacks;
const std::unique_ptr<Callbacks> mHwc1Callbacks;