From db3ed6e69797afa5735b5d7a3b0d0f788a522284 Mon Sep 17 00:00:00 2001 From: Peiyong Lin Date: Thu, 9 Jan 2020 18:43:27 -0800 Subject: Don't fall back to system driver when driver apk fails. Previously when driver apk fails to load, the loader falls back to load system driver. However, this provides no indication of driver apk failure and hence users that intend to use driver apk may end up working against the system driver. BUG: b/147459984 Test: Verified by forcing to use a dummy apk Change-Id: I3befc0d6c1f143dc53eab3762b7ff19c702e8cda --- libs/graphicsenv/GraphicsEnv.cpp | 4 ++++ libs/graphicsenv/include/graphicsenv/GraphicsEnv.h | 1 + opengl/libs/EGL/Loader.cpp | 5 +++++ 3 files changed, 10 insertions(+) diff --git a/libs/graphicsenv/GraphicsEnv.cpp b/libs/graphicsenv/GraphicsEnv.cpp index f07c23132d..befabee66d 100644 --- a/libs/graphicsenv/GraphicsEnv.cpp +++ b/libs/graphicsenv/GraphicsEnv.cpp @@ -611,6 +611,10 @@ android_namespace_t* GraphicsEnv::getDriverNamespace() { return mDriverNamespace; } +std::string GraphicsEnv::getDriverPath() const { + return mDriverPath; +} + android_namespace_t* GraphicsEnv::getAngleNamespace() { std::lock_guard lock(mNamespaceMutex); diff --git a/libs/graphicsenv/include/graphicsenv/GraphicsEnv.h b/libs/graphicsenv/include/graphicsenv/GraphicsEnv.h index 2219074ec0..22a2332589 100644 --- a/libs/graphicsenv/include/graphicsenv/GraphicsEnv.h +++ b/libs/graphicsenv/include/graphicsenv/GraphicsEnv.h @@ -58,6 +58,7 @@ public: void setDriverPathAndSphalLibraries(const std::string path, const std::string sphalLibraries); // Get the updatable driver namespace. android_namespace_t* getDriverNamespace(); + std::string getDriverPath() const; /* * Apis for GpuStats diff --git a/opengl/libs/EGL/Loader.cpp b/opengl/libs/EGL/Loader.cpp index e1432608c9..06944bb5c6 100644 --- a/opengl/libs/EGL/Loader.cpp +++ b/opengl/libs/EGL/Loader.cpp @@ -238,6 +238,11 @@ void* Loader::open(egl_connection_t* cnx) bool failToLoadFromDriverSuffixProperty = false; if (!hnd) { + // If updated driver apk is set but fail to load, abort here. + if (android::GraphicsEnv::getInstance().getDriverNamespace()) { + LOG_ALWAYS_FATAL("couldn't find an OpenGL ES implementation from %s", + android::GraphicsEnv::getInstance().getDriverPath().c_str()); + } // Finally, try to load system driver, start by searching for the library name appended by // the system properties of the GLES userspace driver in both locations. // i.e.: -- cgit v1.2.3-59-g8ed1b