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

Commit f0874d35 authored by Cody Northrop's avatar Cody Northrop
Browse files

Remove app preference from ANGLE logic

* Since we no longer plan to allow apps to specify a preference,
  remove the JNI plumbing.
* Also remove any uses and helpers sending it to ANGLE.

Bug: 80239516
Test: Manual build, ensure rules are followed
Test: cts-tradefed run singleCommand cts -m CtsAngleIntegrationHostTestCases
Change-Id: I080203fe9dc7d4935341aae8bfdb5e5e143e46cd
parent 4a307b67
Loading
Loading
Loading
Loading
+1 −15
Original line number Diff line number Diff line
@@ -68,8 +68,7 @@ void GraphicsEnv::setDriverPath(const std::string path) {
}

void GraphicsEnv::setAngleInfo(const std::string path, const std::string appName,
                               const std::string appPref, bool developerOptIn,
                               const int rulesFd, const long rulesOffset,
                               bool developerOptIn, const int rulesFd, const long rulesOffset,
                               const long rulesLength) {
    if (!mAnglePath.empty()) {
        ALOGV("ignoring attempt to change ANGLE path from '%s' to '%s'", mAnglePath.c_str(),
@@ -87,14 +86,6 @@ void GraphicsEnv::setAngleInfo(const std::string path, const std::string appName
        mAngleAppName = appName;
    }

    if (!mAngleAppPref.empty()) {
        ALOGV("ignoring attempt to change ANGLE application opt-in from '%s' to '%s'",
              mAngleAppPref.c_str(), appPref.c_str());
    } else {
        ALOGV("setting ANGLE application opt-in to '%s'", appPref.c_str());
        mAngleAppPref = appPref;
    }

    mAngleDeveloperOptIn = developerOptIn;

    ALOGV("setting ANGLE rules file descriptor to '%i'", rulesFd);
@@ -128,11 +119,6 @@ bool GraphicsEnv::getAngleDeveloperOptIn() {
    return mAngleDeveloperOptIn;
}

const char* GraphicsEnv::getAngleAppPref() {
    if (mAngleAppPref.empty()) return nullptr;
    return mAngleAppPref.c_str();
}

int GraphicsEnv::getAngleRulesFd() {
    return mAngleRulesFd;
}
+2 −4
Original line number Diff line number Diff line
@@ -44,9 +44,8 @@ public:
    // (libraries must be stored uncompressed and page aligned); such elements
    // in the search path must have a '!' after the zip filename, e.g.
    //     /system/app/ANGLEPrebuilt/ANGLEPrebuilt.apk!/lib/arm64-v8a
    void setAngleInfo(const std::string path, const std::string appName, const std::string appPref,
                      bool devOptIn, const int rulesFd, const long rulesOffset,
                      const long rulesLength);
    void setAngleInfo(const std::string path, const std::string appName, bool devOptIn,
                      const int rulesFd, const long rulesOffset, const long rulesLength);
    android_namespace_t* getAngleNamespace();
    const char* getAngleAppName();
    const char* getAngleAppPref();
@@ -70,7 +69,6 @@ private:
    std::string mDriverPath;
    std::string mAnglePath;
    std::string mAngleAppName;
    std::string mAngleAppPref;
    bool mAngleDeveloperOptIn;
    int mAngleRulesFd;
    long mAngleRulesOffset;
+2 −18
Original line number Diff line number Diff line
@@ -522,18 +522,6 @@ static void* load_angle_from_namespace(const char* kind, android_namespace_t* ns
    return nullptr;
}

static ANGLEPreference getAnglePref(const char* app_pref) {
    if (app_pref == nullptr)
        return ANGLE_NO_PREFERENCE;

    if (strcmp(app_pref, "angle") == 0) {
        return ANGLE_PREFER_ANGLE;
    } else if (strcmp(app_pref, "native") == 0) {
        return ANGLE_PREFER_NATIVE;
    }
    return ANGLE_NO_PREFERENCE;
}

static void* load_angle(const char* kind, android_namespace_t* ns, egl_connection_t* cnx) {
    // Only attempt to load ANGLE libs
    if (strcmp(kind, "EGL") != 0 && strcmp(kind, "GLESv2") != 0 && strcmp(kind, "GLESv1_CM") != 0)
@@ -543,15 +531,13 @@ static void* load_angle(const char* kind, android_namespace_t* ns, egl_connectio
    char prop[PROPERTY_VALUE_MAX];

    const char* app_name = android::GraphicsEnv::getInstance().getAngleAppName();
    const char* app_pref = android::GraphicsEnv::getInstance().getAngleAppPref();
    bool developer_opt_in = android::GraphicsEnv::getInstance().getAngleDeveloperOptIn();
    const int rules_fd = android::GraphicsEnv::getInstance().getAngleRulesFd();
    const long rules_offset = android::GraphicsEnv::getInstance().getAngleRulesOffset();
    const long rules_length = android::GraphicsEnv::getInstance().getAngleRulesLength();

    // Determine whether or not to use ANGLE:
    ANGLEPreference developer_option = developer_opt_in ? ANGLE_PREFER_ANGLE : ANGLE_NO_PREFERENCE;
    bool use_angle = (developer_option == ANGLE_PREFER_ANGLE);
    bool use_angle = developer_opt_in;

    if (use_angle) {
        ALOGV("User set \"Developer Options\" to force the use of ANGLE");
@@ -604,10 +590,8 @@ static void* load_angle(const char* kind, android_namespace_t* ns, egl_connectio
                fpANGLEUseForApplication ANGLEUseForApplication =
                        (fpANGLEUseForApplication)dlsym(cnx->featureSo, "ANGLEUseForApplication");
                if (ANGLEUseForApplication) {
                    ANGLEPreference app_preference =
                            getAnglePref(android::GraphicsEnv::getInstance().getAngleAppPref());
                    use_angle = (ANGLEUseForApplication)(app_name_str.c_str(), manufacturer, model,
                                                         developer_option, app_preference);
                                                         developer_option, ANGLE_NO_PREFERENCE);
                    ALOGV("Result of opt-in/out logic is %s", use_angle ? "true" : "false");
                } else {
                    ALOGW("Cannot find ANGLEUseForApplication in library");