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

Commit eb0ca8e5 authored by Cody Northrop's avatar Cody Northrop Committed by Courtney Goeltzenleuchter
Browse files

Pass more ANGLE info from runtime

In order to facilitate ANGLE selection logic in the backend, we need to
start sending more information from GraphicsEnvironment.  This includes
the application name, whether the developer opted in, and the list can
be expanded.  We also have to send the ANGLE namespace unconditionally
in case the application opts in programmatically.

Bug: 80239516
Test: Manual build, booted clean, ensured developer opt-in still works.
Change-Id: I3b8f99942999de6a3188d2e61355dcd244f9191e
(cherry picked from commit 261dfbd814bf62caaee11e6ebe4e2e61e28f4919)
parent 1846187a
Loading
Loading
Loading
Loading
+28 −25
Original line number Diff line number Diff line
@@ -133,7 +133,7 @@ public class GraphicsEnvironment {
    }

    /**
     * Selectively enable ANGLE for applications
     * Pass ANGLE details down to trigger enable logic
     */
    private static void setupAngle(Context context) {

@@ -143,12 +143,16 @@ public class GraphicsEnvironment {

        String packageName = context.getPackageName();

        // Only provide an ANGLE namespace if the package name matches setting
        boolean optIn = false;

        if ((angleEnabledApp != null && packageName != null)
                && (!angleEnabledApp.isEmpty() && !packageName.isEmpty())
                && angleEnabledApp.equals(packageName)) {

            if (DEBUG) Log.v(TAG, "ANGLE enabled for " + packageName);
            if (DEBUG) Log.v(TAG, packageName + " opted in for ANGLE via Developer Setting");

            optIn = true;
        }

        ApplicationInfo angleInfo;

@@ -173,9 +177,8 @@ public class GraphicsEnvironment {

        if (DEBUG) Log.v(TAG, "ANGLE package libs: " + paths);

            // Providing any path will trigger namespace creation
            setAnglePath(paths);
        }
        // Further opt-in logic is handled in native, so pass relevant info down
        setAngleInfo(paths, packageName, optIn);
    }

    /**
@@ -266,5 +269,5 @@ public class GraphicsEnvironment {
    private static native void setLayerPaths(ClassLoader classLoader, String layerPaths);
    private static native void setDebugLayers(String layers);
    private static native void setDriverPath(String path);
    private static native void setAnglePath(String path);
    private static native void setAngleInfo(String path, String appPackage, boolean optIn);
}
+4 −3
Original line number Diff line number Diff line
@@ -28,9 +28,10 @@ void setDriverPath(JNIEnv* env, jobject clazz, jstring path) {
    android::GraphicsEnv::getInstance().setDriverPath(pathChars.c_str());
}

void setAnglePath(JNIEnv* env, jobject clazz, jstring path) {
void setAngleInfo_native(JNIEnv* env, jobject clazz, jstring path, jstring appName, jboolean optIn) {
    ScopedUtfChars pathChars(env, path);
    android::GraphicsEnv::getInstance().setAnglePath(pathChars.c_str());
    ScopedUtfChars appNameChars(env, appName);
    android::GraphicsEnv::getInstance().setAngleInfo(pathChars.c_str(), appNameChars.c_str(), optIn);
}

void setLayerPaths_native(JNIEnv* env, jobject clazz, jobject classLoader, jstring layerPaths) {
@@ -49,7 +50,7 @@ void setDebugLayers_native(JNIEnv* env, jobject clazz, jstring layers) {

const JNINativeMethod g_methods[] = {
    { "setDriverPath", "(Ljava/lang/String;)V", reinterpret_cast<void*>(setDriverPath) },
    { "setAnglePath", "(Ljava/lang/String;)V", reinterpret_cast<void*>(setAnglePath) },
    { "setAngleInfo", "(Ljava/lang/String;Ljava/lang/String;Z)V", reinterpret_cast<void*>(setAngleInfo_native) },
    { "setLayerPaths", "(Ljava/lang/ClassLoader;Ljava/lang/String;)V", reinterpret_cast<void*>(setLayerPaths_native) },
    { "setDebugLayers", "(Ljava/lang/String;)V", reinterpret_cast<void*>(setDebugLayers_native) },
};