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

Commit e8dc19c8 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Merge cherrypicks of ['googleplex-android-review.googlesource.com/24119261']...

Merge cherrypicks of ['googleplex-android-review.googlesource.com/24119261'] into sparse-10504857-L83800000962051456.
SPARSE_CHANGE: Ib05368a94911049d4055c55da974f79e25dbc367

Change-Id: Ic24183f101bf1867d7d30735e6ea332c9d2493c7
parents 9bf11f66 4c768d26
Loading
Loading
Loading
Loading
+10 −11
Original line number Diff line number Diff line
@@ -512,7 +512,7 @@ bool GraphicsEnv::shouldUseAngle() {
    return mShouldUseAngle;
}

void GraphicsEnv::setAngleInfo(const std::string& path, const bool shouldUseSystemAngle,
void GraphicsEnv::setAngleInfo(const std::string& path, const bool useSystemAngle,
                               const std::string& packageName,
                               const std::vector<std::string> eglFeatures) {
    if (mShouldUseAngle) {
@@ -530,7 +530,7 @@ void GraphicsEnv::setAngleInfo(const std::string& path, const bool shouldUseSyst
    ALOGV("setting app package name to '%s'", packageName.c_str());
    mPackageName = std::move(packageName);
    mShouldUseAngle = true;
    mShouldUseSystemAngle = shouldUseSystemAngle;
    mUseSystemAngle = useSystemAngle;
}

std::string& GraphicsEnv::getPackageName() {
@@ -548,7 +548,7 @@ android_namespace_t* GraphicsEnv::getAngleNamespace() {
        return mAngleNamespace;
    }

    if (mAnglePath.empty() && !mShouldUseSystemAngle) {
    if (mAnglePath.empty() && !mUseSystemAngle) {
        ALOGV("mAnglePath is empty and not using system ANGLE, abort creating ANGLE namespace");
        return nullptr;
    }
@@ -566,19 +566,18 @@ android_namespace_t* GraphicsEnv::getAngleNamespace() {
    // are properly inherited.
    mAngleNamespace =
            android_create_namespace("ANGLE",
                                     mShouldUseSystemAngle ? defaultLibraryPaths
                                     mUseSystemAngle ? defaultLibraryPaths
                                                     : mAnglePath.c_str(), // ld_library_path
                                     mShouldUseSystemAngle
                                             ? defaultLibraryPaths
                                     mUseSystemAngle ? defaultLibraryPaths
                                                     : mAnglePath.c_str(), // default_library_path
                                     ANDROID_NAMESPACE_TYPE_SHARED_ISOLATED,
                                     nullptr, // permitted_when_isolated_path
                                     mShouldUseSystemAngle ? android_get_exported_namespace("sphal")
                                     mUseSystemAngle ? android_get_exported_namespace("sphal")
                                                     : nullptr); // parent

    ALOGD_IF(!mAngleNamespace, "Could not create ANGLE namespace from default");

    if (!mShouldUseSystemAngle) {
    if (!mUseSystemAngle) {
        return mAngleNamespace;
    }

+1 −2
Original line number Diff line number Diff line
@@ -117,7 +117,6 @@ public:
    const std::vector<std::string>& getAngleEglFeatures();
    // Set the persist.graphics.egl system property value.
    void nativeToggleAngleAsSystemDriver(bool enabled);
    bool shouldUseSystemAngle();

    /*
     * Apis for debug layer
@@ -174,7 +173,7 @@ private:
    // Whether ANGLE should be used.
    bool mShouldUseAngle = false;
    // Whether loader should load system ANGLE.
    bool mShouldUseSystemAngle = false;
    bool mUseSystemAngle = false;
    // ANGLE namespace.
    android_namespace_t* mAngleNamespace = nullptr;

+10 −15
Original line number Diff line number Diff line
@@ -161,13 +161,8 @@ static bool should_unload_system_driver(egl_connection_t* cnx) {
    // Return true if ANGLE namespace is set.
    android_namespace_t* ns = android::GraphicsEnv::getInstance().getAngleNamespace();
    if (ns) {
        // Unless the default GLES driver is ANGLE and the process should use system ANGLE, since
        // the intended GLES driver is already loaded.
        // This should be updated in a later patch that cleans up namespaces
        if (!(cnx->angleLoaded && android::GraphicsEnv::getInstance().shouldUseSystemAngle())) {
        return true;
    }
    }

    // Return true if updated driver namespace is set.
    ns = android::GraphicsEnv::getInstance().getDriverNamespace();
@@ -211,17 +206,17 @@ void Loader::unload_system_driver(egl_connection_t* cnx) {
            do_android_unload_sphal_library(hnd->dso[0]);
        }
        cnx->dso = nullptr;
        cnx->angleLoaded = false;
    }

    cnx->systemDriverUnloaded = true;
}

void* Loader::open(egl_connection_t* cnx) {
void* Loader::open(egl_connection_t* cnx)
{
    ATRACE_CALL();
    const nsecs_t openTime = systemTime();

    if (cnx->dso && should_unload_system_driver(cnx)) {
    if (should_unload_system_driver(cnx)) {
        unload_system_driver(cnx);
    }

@@ -230,12 +225,8 @@ void* Loader::open(egl_connection_t* cnx) {
        return cnx->dso;
    }

    driver_t* hnd = nullptr;
    // Firstly, try to load ANGLE driver, if ANGLE should be loaded and fail, abort.
    if (android::GraphicsEnv::getInstance().shouldUseAngle()) {
        hnd = attempt_to_load_angle(cnx);
        LOG_ALWAYS_FATAL_IF(!hnd, "Failed to load ANGLE.");
    }
    // Firstly, try to load ANGLE driver.
    driver_t* hnd = attempt_to_load_angle(cnx);

    if (!hnd) {
        // Secondly, try to load from driver apk.
@@ -550,6 +541,10 @@ static void* load_updated_driver(const char* kind, android_namespace_t* ns) {
Loader::driver_t* Loader::attempt_to_load_angle(egl_connection_t* cnx) {
    ATRACE_CALL();

    if (!android::GraphicsEnv::getInstance().shouldUseAngle()) {
        return nullptr;
    }

    android_namespace_t* ns = android::GraphicsEnv::getInstance().getAngleNamespace();
    if (!ns) {
        return nullptr;