Revert "Load the gralloc module at library load"

am: 5efa773cc1

Change-Id: Ib4b3dc414a2ea10aa21cebdb828c9508edc80492
This commit is contained in:
Jesse Hall 2017-06-19 21:08:36 +00:00 committed by android-build-merger
commit 5652960deb

View file

@ -293,31 +293,20 @@ Return<void> GrallocMapper::unlock(void* buffer, unlock_cb hidl_cb) {
return Void();
}
namespace {
// Load the gralloc module when this shared library is loaded, rather than
// waiting until HIDL_FETCH_IMapper is called. This allows it (and its
// dependencies) to be loaded by Zygote, reducing app startup time and sharing
// pages dirtied during library load between all apps.
struct GrallocModule {
const hw_module_t* module;
GrallocModule() : module(nullptr) {
int err = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module);
ALOGE_IF(err, "failed to get gralloc module: %s (%d)", strerror(-err),
err);
}
};
GrallocModule gGralloc;
} // namespace
IMapper* HIDL_FETCH_IMapper(const char* /* name */) {
if (!gGralloc.module) return nullptr;
const hw_module_t* module = nullptr;
int err = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module);
if (err) {
ALOGE("failed to get gralloc module");
return nullptr;
}
uint8_t major = (gGralloc.module->module_api_version >> 8) & 0xff;
uint8_t major = (module->module_api_version >> 8) & 0xff;
switch (major) {
case 1:
return new Gralloc1Mapper(gGralloc.module);
return new Gralloc1Mapper(module);
case 0:
return new Gralloc0Mapper(gGralloc.module);
return new Gralloc0Mapper(module);
default:
ALOGE("unknown gralloc module major version %d", major);
return nullptr;