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

Commit 04e70437 authored by Cody Northrop's avatar Cody Northrop
Browse files

Pass ANGLE rules file descriptor through JNI

We are now loading the json rules from ANGLE's APK, passing
that through to the loader via a file descriptor.

Bug: 80239516
Test: Manual build, ensure we can inspect rules from modified APK
Test: cts-tradefed run singleCommand cts -m CtsAngleIntegrationHostTestCases
Change-Id: I9387d8b4a40cd035c40db9466a13666b262c5724
(cherry picked from commit eeffc9df36d117ec35ea5aaf9d62b8fea733b298)
parent 6d082efa
Loading
Loading
Loading
Loading
+31 −1
Original line number Diff line number Diff line
@@ -68,7 +68,9 @@ 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 std::string appPref, 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(),
              path.c_str());
@@ -94,6 +96,13 @@ void GraphicsEnv::setAngleInfo(const std::string path, const std::string appName
    }

    mAngleDeveloperOptIn = developerOptIn;

    ALOGV("setting ANGLE rules file descriptor to '%i'", rulesFd);
    mAngleRulesFd = rulesFd;
    ALOGV("setting ANGLE rules offset to '%li'", rulesOffset);
    mAngleRulesOffset = rulesOffset;
    ALOGV("setting ANGLE rules length to '%li'", rulesLength);
    mAngleRulesLength = rulesLength;
}

void GraphicsEnv::setLayerPaths(NativeLoaderNamespace* appNamespace, const std::string layerPaths) {
@@ -124,6 +133,18 @@ const char* GraphicsEnv::getAngleAppPref() {
    return mAngleAppPref.c_str();
}

int GraphicsEnv::getAngleRulesFd() {
    return mAngleRulesFd;
}

long GraphicsEnv::getAngleRulesOffset() {
    return mAngleRulesOffset;
}

long GraphicsEnv::getAngleRulesLength() {
    return mAngleRulesLength;
}

const std::string GraphicsEnv::getLayerPaths(){
    return mLayerPaths;
}
@@ -192,6 +213,15 @@ bool android_getAngleDeveloperOptIn() {
const char* android_getAngleAppPref() {
    return android::GraphicsEnv::getInstance().getAngleAppPref();
}
int android_getAngleRulesFd() {
   return android::GraphicsEnv::getInstance().getAngleRulesFd();
}
long android_getAngleRulesOffset() {
   return android::GraphicsEnv::getInstance().getAngleRulesOffset();
}
long android_getAngleRulesLength() {
   return android::GraphicsEnv::getInstance().getAngleRulesLength();
}
const char* android_getLayerPaths() {
    return android::GraphicsEnv::getInstance().getLayerPaths().c_str();
}
+11 −1
Original line number Diff line number Diff line
@@ -45,11 +45,15 @@ public:
    // 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);
                      bool devOptIn, const int rulesFd, const long rulesOffset,
                      const long rulesLength);
    android_namespace_t* getAngleNamespace();
    const char* getAngleAppName();
    const char* getAngleAppPref();
    bool getAngleDeveloperOptIn();
    int getAngleRulesFd();
    long getAngleRulesOffset();
    long getAngleRulesLength();

    void setLayerPaths(NativeLoaderNamespace* appNamespace, const std::string layerPaths);
    NativeLoaderNamespace* getAppNamespace();
@@ -66,6 +70,9 @@ private:
    std::string mAngleAppName;
    std::string mAngleAppPref;
    bool mAngleDeveloperOptIn;
    int mAngleRulesFd;
    long mAngleRulesOffset;
    long mAngleRulesLength;
    std::string mDebugLayers;
    std::string mLayerPaths;
    android_namespace_t* mDriverNamespace = nullptr;
@@ -92,6 +99,9 @@ extern "C" {
    const char* android_getAngleAppName();
    const char* android_getAngleAppPref();
    bool android_getAngleDeveloperOptIn();
    int android_getAngleRulesFd();
    long android_getAngleRulesOffset();
    long android_getAngleRulesLength();
    const char* android_getLayerPaths();
    const char* android_getDebugLayers();
}
+3 −0
Original line number Diff line number Diff line
@@ -523,6 +523,9 @@ static void* load_angle(const char* kind, android_namespace_t* ns, egl_connectio
    const char* app_name = android_getAngleAppName();
    const char* app_pref = android_getAngleAppPref();
    bool developer_opt_in = android_getAngleDeveloperOptIn();
    const int rules_fd = android_getAngleRulesFd();
    const long rules_offset = android_getAngleRulesOffset();
    const long rules_length = android_getAngleRulesLength();

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