Fix a missing case in unloading system driver
When app requests to use ANGLE on devices without an
ANGLE apk installed, but the device has preloaded native
GLES driver, the current should_unload_system_driver()
function does not recognize that we should unload the preloaded
GLES driver, and load the ANGLE driver from system parition.
This CL adds this missed check in should_unload_system_driver()
Bug: b/333483712
Test: atest android.angle.cts.CtsAngleDeveloperOptionHostTest
Result: https://android-build.corp.google.com/abtd/run/L47700030003349338/
Change-Id: I4460eed9f05ee0e19ddb6e4d2a3375701414c458
diff --git a/opengl/libs/EGL/Loader.cpp b/opengl/libs/EGL/Loader.cpp
index af0bcff..ec7b190 100644
--- a/opengl/libs/EGL/Loader.cpp
+++ b/opengl/libs/EGL/Loader.cpp
@@ -184,6 +184,14 @@
}
}
+ // Return true if app requests to use ANGLE, but ANGLE is not loaded.
+ // Difference with the case above is on devices that don't have an ANGLE apk installed,
+ // ANGLE namespace is not set. In that case if ANGLE in system partition is not loaded,
+ // we should unload the system driver first, and then load ANGLE from system partition.
+ if (!cnx->angleLoaded && android::GraphicsEnv::getInstance().shouldUseAngle()) {
+ return true;
+ }
+
// Return true if native GLES drivers should be used and ANGLE is already loaded.
if (android::GraphicsEnv::getInstance().shouldUseNativeDriver() && cnx->angleLoaded) {
return true;