From 6d189b71a2eb4479bda70ab3e476cb2edd43c968 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Mon, 27 Feb 2023 14:19:12 -0800 Subject: [PATCH] graphics: improve preloading for IMapper default impl When GraphicBufferMapper::preloadHal dlopens the default impl, make sure the gralloc module is also dlopen'ed. Bug: 269664560 Test: android.view.cts.PixelCopyTest#testVideoProducer on grunt Change-Id: I57418338d5212fb9a2c1ea82eba63d855f69ff32 --- graphics/mapper/2.0/default/passthrough.cpp | 8 ++++++++ graphics/mapper/2.1/default/passthrough.cpp | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/graphics/mapper/2.0/default/passthrough.cpp b/graphics/mapper/2.0/default/passthrough.cpp index e18b88fb84..93d6d99063 100644 --- a/graphics/mapper/2.0/default/passthrough.cpp +++ b/graphics/mapper/2.0/default/passthrough.cpp @@ -19,6 +19,14 @@ using android::hardware::graphics::mapper::V2_0::IMapper; using android::hardware::graphics::mapper::V2_0::passthrough::GrallocLoader; +// Preload the gralloc module such that GraphicBufferMapper::preloadHal is +// meaningful +class GrallocPreloader { +public: + GrallocPreloader() { GrallocLoader::loadModule(); } +}; +static GrallocPreloader sGrallocPreloader; + extern "C" IMapper* HIDL_FETCH_IMapper(const char* /*name*/) { return GrallocLoader::load(); } diff --git a/graphics/mapper/2.1/default/passthrough.cpp b/graphics/mapper/2.1/default/passthrough.cpp index c7f0cf5632..c99c98460e 100644 --- a/graphics/mapper/2.1/default/passthrough.cpp +++ b/graphics/mapper/2.1/default/passthrough.cpp @@ -19,6 +19,14 @@ using android::hardware::graphics::mapper::V2_1::IMapper; using android::hardware::graphics::mapper::V2_1::passthrough::GrallocLoader; +// Preload the gralloc module such that GraphicBufferMapper::preloadHal is +// meaningful +class GrallocPreloader { +public: + GrallocPreloader() { GrallocLoader::loadModule(); } +}; +static GrallocPreloader sGrallocPreloader; + extern "C" IMapper* HIDL_FETCH_IMapper(const char* /*name*/) { return GrallocLoader::load(); }