drm_hwcomposer: Validate gralloc0 name for minigbm and libdrm getters
Using of incorrect gralloc0 results in a runtime issues, with logs like
"Cannot convert hal format to drm format <VALUE>" or other.
Validate gralloc name and exit gracefully in case it doesnt't match the one
we are expecting.
Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
diff --git a/bufferinfo/BufferInfoGetter.h b/bufferinfo/BufferInfoGetter.h
index 60ca985..7b088df 100644
--- a/bufferinfo/BufferInfoGetter.h
+++ b/bufferinfo/BufferInfoGetter.h
@@ -49,6 +49,10 @@
int Init();
+ virtual int ValidateGralloc() {
+ return 0;
+ }
+
int ConvertBoInfo(buffer_handle_t handle, hwc_drm_bo_t *bo) override = 0;
static std::unique_ptr<LegacyBufferInfoGetter> CreateInstance();
@@ -65,9 +69,13 @@
LegacyBufferInfoGetter::CreateInstance() { \
auto instance = std::make_unique<getter_>(); \
if (instance) { \
- int ret = instance->Init(); \
- if (ret) { \
- ALOGE("Failed to initialize the " #getter_ " getter %d", ret); \
+ int err = instance->Init(); \
+ if (err) { \
+ ALOGE("Failed to initialize the " #getter_ " getter %d", err); \
+ instance.reset(); \
+ } \
+ err = instance->ValidateGralloc(); \
+ if (err) { \
instance.reset(); \
} \
} \