Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5480b212 authored by Jessie Hao's avatar Jessie Hao
Browse files

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: default avatarJessie Hao <juan.hao@nxp.com>
Change-Id: I131b9dee3b2b768729218d8f7cabe0026ab89007
parent 84d5709e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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));