From c785301bd30e0eaa8ab4a43b0a28ffcf3c232ef5 Mon Sep 17 00:00:00 2001 From: Hirokazu Honda Date: Mon, 21 Jul 2025 21:29:34 -0700 Subject: [PATCH] cros_gralloc: Map GRALLOC_USAGE_PROTECTED to BO_USE_PROTECTED on API 35+ Bug: 433330646 Test: allocate a buffer with GRALLOC_USAGE_PROTECTED usage Flag: EXEMPT: desktop-only change Change-Id: I9a47dbb13655b141bfeaa9820632428647e7419b --- cros_gralloc/cros_gralloc_helpers.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cros_gralloc/cros_gralloc_helpers.cc b/cros_gralloc/cros_gralloc_helpers.cc index 90bb6a1..230bb35 100644 --- a/cros_gralloc/cros_gralloc_helpers.cc +++ b/cros_gralloc/cros_gralloc_helpers.cc @@ -140,8 +140,13 @@ uint64_t cros_gralloc_convert_usage(uint64_t usage) * usb monitors (evdi/udl). It's complicated so ignore it. */ handle_usage(&usage, GRALLOC_USAGE_EXTERNAL_DISP, &use_flags, BO_USE_NONE); - /* Map PROTECTED to linear until real HW protection is available on Android. */ + +#if ANDROID_API_LEVEL >= 35 + handle_usage(&usage, GRALLOC_USAGE_PROTECTED, &use_flags, BO_USE_PROTECTED); +#else handle_usage(&usage, GRALLOC_USAGE_PROTECTED, &use_flags, BO_USE_LINEAR); +#endif + handle_usage(&usage, GRALLOC_USAGE_CURSOR, &use_flags, BO_USE_CURSOR); /* HACK: See b/30054495 for BO_USE_SW_READ_OFTEN. */ handle_usage(&usage, GRALLOC_USAGE_HW_VIDEO_ENCODER, &use_flags,