diff options
author | 2022-09-02 12:36:56 +0800 | |
---|---|---|
committer | 2022-09-02 14:41:16 +0800 | |
commit | 5480b2129e55a9b00f789e9b1caa42656646634e (patch) | |
tree | 1d7f94b99afb4627da61aceea9aad8540ac56774 | |
parent | 84d5709e548182f2ab835dd6539ae9a8550b4401 (diff) |
fix validateBufferDescriptorInfo error when usage bits were 32-bits
When usage bits were 32-bits, and the bit 31 is 1, will meet the below error:
E Gralloc4: buffer descriptor contains invalid usage bits 0xffff00000000
E GraphicBufferMapper: validateBufferSize(0xb400007adcd71320) failed: 1
android_native_buffer_t define usage_deprecated as int.
For example usage_deprecated is 0x80000000,
uint64_t(0x80000000) will cast to 0xffffffff80000000, which leads to
validateBufferDescriptorInfo fail.
Add ANDROID_NATIVE_UNSIGNED_CAST(usage_deprecated) to fix this.
Test:
CtsMediaRecorderTestCases
android.media.recorder.cts.MediaRecorderTest#testProfileAvcBaselineLevel1
Bug: b/244620240
Signed-off-by: Jessie Hao <juan.hao@nxp.com>
Change-Id: I131b9dee3b2b768729218d8f7cabe0026ab89007
-rw-r--r-- | libs/ui/GraphicBuffer.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/libs/ui/GraphicBuffer.cpp b/libs/ui/GraphicBuffer.cpp index 3732fee7f2..429760ffe0 100644 --- a/libs/ui/GraphicBuffer.cpp +++ b/libs/ui/GraphicBuffer.cpp @@ -465,7 +465,7 @@ status_t GraphicBuffer::unflatten(void const*& buffer, size_t& size, int const*& if (flattenWordCount == 13) { usage = (uint64_t(buf[12]) << 32) | uint32_t(buf[6]); } else { - usage = uint64_t(usage_deprecated); + usage = uint64_t(ANDROID_NATIVE_UNSIGNED_CAST(usage_deprecated)); } native_handle* h = native_handle_create(static_cast<int>(numFds), static_cast<int>(numInts)); |