gralloc: Move validation of non-blob/gpu_data_buffer down to libui
AIDL gralloc implementations may choose to support this combination.
Existing implementations of HIDL gralloc 2/3/4 do not support it,
and do not reliably reject it due to having been previously protected
by validation at the AHardwareBuffer layer.
Move the check down to the gralloc layer, and defer to the HAL only
in the AIDL case.
Bug: b/195944622
Test: build; real CTS/VTS to land soon after.
Change-Id: I7b0b9de005a9b0f564915f9c71cc8aea3ef0618a
diff --git a/libs/ui/Gralloc2.cpp b/libs/ui/Gralloc2.cpp
index 040a62b..f23f10a 100644
--- a/libs/ui/Gralloc2.cpp
+++ b/libs/ui/Gralloc2.cpp
@@ -110,6 +110,15 @@
descriptorInfo->usage & ~validUsageBits);
return BAD_VALUE;
}
+
+ // Gralloc2 implementations never understand non-BLOB with GPU_DATA_BUFFER
+ // and do not reliably reject it.
+ if (descriptorInfo->usage & BufferUsage::GPU_DATA_BUFFER &&
+ descriptorInfo->format != hardware::graphics::common::V1_1::PixelFormat::BLOB) {
+ ALOGE("gralloc2 does not support non-BLOB pixel formats with GPU_DATA_BUFFER usage");
+ return BAD_VALUE;
+ }
+
return NO_ERROR;
}