Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 98db8e0c authored by Peiyong Lin's avatar Peiyong Lin
Browse files

Do not allow wildcard matching in GL loader.

Previously when ro.hardware.egl and ro.board.platform were not set, the
loader would attempt to load the exact GLES drivers, and if it failed,
it would attempt to use wildcard matching to find the GLES drivers.

However, ro.hardware.egl must be set to point to the GLES drivers and
hence wildcard matching should be disallowed. This patch makes sure the
GL loader no longer uses that path if a device is launched in Android 14
and beyond.

Bug: b/277100371
Test: boot
Test: atest CtsAngleIntegrationHostTestCases
Change-Id: Ie9221ba37947c7462de8321819543a4c67979f67
parent 1f428c8a
Loading
Loading
Loading
Loading
+21 −24
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@

#include <android-base/properties.h>
#include <android/dlext.h>
#include <cutils/properties.h>
#include <dirent.h>
#include <dlfcn.h>
#include <graphicsenv/GraphicsEnv.h>
@@ -236,13 +237,7 @@ void* Loader::open(egl_connection_t* cnx)
            LOG_ALWAYS_FATAL("couldn't find an OpenGL ES implementation from %s",
                             android::GraphicsEnv::getInstance().getDriverPath().c_str());
        }
        // Finally, try to load system driver.  If ANGLE is the system driver
        // (i.e. we are forcing the legacy system driver instead of ANGLE), use
        // the driver suffix that was passed down from above.
        if (shouldForceLegacyDriver) {
            std::string suffix = android::GraphicsEnv::getInstance().getLegacySuffix();
            hnd = attempt_to_load_system_driver(cnx, suffix.c_str(), true);
        } else {
        // 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.:
@@ -261,7 +256,6 @@ void* Loader::open(egl_connection_t* cnx)
            }
        }
    }
    }

    if (!hnd) {
        // Can't find graphics driver by appending system properties, now search for the exact name
@@ -272,7 +266,10 @@ void* Loader::open(egl_connection_t* cnx)
        hnd = attempt_to_load_system_driver(cnx, nullptr, true);
    }

    if (!hnd && !failToLoadFromDriverSuffixProperty) {
    if (!hnd && !failToLoadFromDriverSuffixProperty &&
        property_get_int32("ro.vendor.api_level", 0) < __ANDROID_API_U__) {
        // Still can't find the graphics drivers with the exact name. This time try to use wildcard
        // matching if the device is launched before Android 14.
        hnd = attempt_to_load_system_driver(cnx, nullptr, false);
    }