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

Commit 044757be authored by Yuxin Hu's avatar Yuxin Hu
Browse files

Add new API to toggle ANGLE as the default system GLES driver

Bug: b/270994705
Test: Verify Pixel 7 can boot fine.
adb shell getprop persist.graphics.egl
is returning the right value with switch set on and off.

Change-Id: Ic6fd03c334492fd42fadc11549688030772fac97
parent bc76b268
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -212,6 +212,13 @@ public class GraphicsEnvironment {
        Trace.traceEnd(Trace.TRACE_TAG_GRAPHICS);
    }

    /**
     * Switch the system to use ANGLE as the default GLES driver.
     */
    public void toggleAngleAsSystemDriver(boolean enabled) {
        nativeToggleAngleAsSystemDriver(enabled);
    }

    /**
     * Query to determine if the Game Mode has enabled ANGLE.
     */
@@ -992,6 +999,7 @@ public class GraphicsEnvironment {
            String appPackage, boolean angleIsSystemDriver, String legacyDriverName);
    private static native boolean getShouldUseAngle(String packageName);
    private static native boolean setInjectLayersPrSetDumpable();
    private static native void nativeToggleAngleAsSystemDriver(boolean enabled);

    /**
     * Hint for GraphicsEnvironment that an activity is launching on the process.
+6 −0
Original line number Diff line number Diff line
@@ -122,6 +122,10 @@ void hintActivityLaunch_native(JNIEnv* env, jobject clazz) {
    android::GraphicsEnv::getInstance().hintActivityLaunch();
}

void nativeToggleAngleAsSystemDriver_native(JNIEnv* env, jobject clazz, jboolean enabled) {
    android::GraphicsEnv::getInstance().nativeToggleAngleAsSystemDriver(enabled);
}

const JNINativeMethod g_methods[] = {
        {"isDebuggable", "()Z", reinterpret_cast<void*>(isDebuggable_native)},
        {"setDriverPathAndSphalLibraries", "(Ljava/lang/String;Ljava/lang/String;)V",
@@ -143,6 +147,8 @@ const JNINativeMethod g_methods[] = {
        {"setDebugLayersGLES", "(Ljava/lang/String;)V",
         reinterpret_cast<void*>(setDebugLayersGLES_native)},
        {"hintActivityLaunch", "()V", reinterpret_cast<void*>(hintActivityLaunch_native)},
        {"nativeToggleAngleAsSystemDriver", "(Z)V",
         reinterpret_cast<void*>(nativeToggleAngleAsSystemDriver_native)},
};

const char* const kGraphicsEnvironmentName = "android/os/GraphicsEnvironment";
+7 −0
Original line number Diff line number Diff line
@@ -7629,6 +7629,13 @@
    <permission android:name="android.permission.LOG_FOREGROUND_RESOURCE_USE"
                android:protectionLevel="signature|module" />

    <!-- @hide Allows the settings app to access GPU service APIs".
        <p>Not for use by third-party applications.
        <p>Protection level: signature
    -->
    <permission android:name="android.permission.ACCESS_GPU_SERVICE"
                android:protectionLevel="signature" />

    <!-- @hide Allows an application to get type of any provider uri.
         <p>Not for use by third-party applications.
         <p>Protection level: signature