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

Commit f3920d46 authored by Yuxin Hu's avatar Yuxin Hu
Browse files

Allow queryAngleChoice when ANGLE is system driver but is overridden

If ro.hardware.egl is set to "angle", but persist.graphics.egl is
set to a value that is not "angle", we should still allow egl loader to
load driver specified by persist.graphics.egl. Instead of skipping
queryAngleChoice() and always setup ANGLE when ro.hardware.egl is set to
"angle", we should proceed with queryAngleChoice(), and check what
ANGLE_GL_DRIVER_CHOICE_DEFAULT and ANGLE_GL_DRIVER_CHOICE_NATIVE
actually points to. If they still point to "angle", proceed with
setupAngleFromApk() || setupAngleFromSystem(). If they point to
"non-angle", early out and skip setupAngleFromAok() ||
setupAngleFromSystem().

Flag: android.os.query_angle_choice_flag
Test: make, flash and boot
Bug: b/408439360
Bug: b/409589250
Change-Id: I4f711aace7de1ef81ae4367dc5e3b5bfd946f97c
parent 1efa2137
Loading
Loading
Loading
Loading
+36 −11
Original line number Diff line number Diff line
@@ -80,6 +80,7 @@ public class GraphicsEnvironment {

    /// System properties related to EGL
    private static final String PROPERTY_RO_HARDWARE_EGL = "ro.hardware.egl";
    private static final String PROPERTY_PERSIST_GRAPHICS_EGL = "persist.graphics.egl";

    // Metadata flags within the <application> tag in the AndroidManifest.xml file.
    private static final String METADATA_DRIVER_BUILD_TIME =
@@ -550,12 +551,8 @@ public class GraphicsEnvironment {
    }

    /**
     * If ANGLE is not the system driver, determine whether ANGLE should be used, and if so, pass
     * Determine whether ANGLE should be used, and if so, pass
     * down the necessary details to the C++ GraphicsEnv class via GraphicsEnv::setAngleInfo().
     * <p>
     * If ANGLE is the system driver or the various flags indicate it should be used, attempt to
     * set up ANGLE from the APK first, so the updatable libraries are used. If APK setup fails,
     * attempt to set up the system ANGLE. Return false if both fail.
     *
     * @param context - Context of the application.
     * @param bundle - Bundle of the application.
@@ -567,7 +564,34 @@ public class GraphicsEnvironment {
    private boolean setupAngle(Context context, Bundle bundle, PackageManager packageManager,
            String packageName) {
        final String eglDriverName = SystemProperties.get(PROPERTY_RO_HARDWARE_EGL);
        final String overrideDriverName = SystemProperties.get(PROPERTY_PERSIST_GRAPHICS_EGL);

        if (android.os.Flags.queryAngleChoiceFlag()) {
            final String angleChoice = queryAngleChoice(context, bundle, packageName);
            if (angleChoice.equals(ANGLE_GL_DRIVER_CHOICE_DEFAULT)) {
                // Check if DEFAULT driver is angle.
                // If DEFAULT driver is angle, we need to proceed with
                // setupAngleFromApk || setupAngleFromSystem for ANGLE run-time feature flag setup
                // First check persist.graphics.egl, then check ro.hardware.egl
                if (overrideDriverName != null) {
                    if (!overrideDriverName.equals(ANGLE_DRIVER_NAME)) {
                        return false;
                    }
                } else if (!eglDriverName.equals(ANGLE_DRIVER_NAME)) {
                    return false;
                }
            }
            if (angleChoice.equals(ANGLE_GL_DRIVER_CHOICE_NATIVE)) {
                // Check if NATIVE driver pointed by ro.hardware.egl is angle.
                // If it is angle, we need to proceed with
                // setupAngleFromApk || setupAngleFromSystem for ANGLE run-time feature flag setup
                if (!eglDriverName.equals(ANGLE_DRIVER_NAME)) {
                    nativeSetAngleInfo("", true, packageName, null);
                    return false;
                }
            }
        } else {
            // TODO: Remove the else chunk when the flag is enabled
            // The ANGLE choice only makes sense if ANGLE is not the system driver.
            if (!eglDriverName.equals(ANGLE_DRIVER_NAME)) {
                final String angleChoice = queryAngleChoice(context, bundle, packageName);
@@ -579,10 +603,11 @@ public class GraphicsEnvironment {
                    return false;
                }
            }
        }

        // If we reach here, it means either:
        // 1. system driver is not ANGLE, but ANGLE is requested.
        // 2. system driver is ANGLE.
        // 2. system driver is ANGLE, and no other driver is requested.
        // In both cases, setup ANGLE info. We attempt to setup the APK first, so
        // updated/development libraries are used if the APK is present, falling back to the system
        // libraries otherwise.
+7 −0
Original line number Diff line number Diff line
@@ -321,6 +321,13 @@ flag {
    bug: "345802719"
}

flag {
    name: "query_angle_choice_flag"
    namespace: "gpu"
    description: "Allow query angle choice when ro.hardware.egl is angle and persist.graphics.egl is non-angle"
    bug: "408439360"
}

flag {
    name: "remove_app_profiler_pss_collection"
    is_exported: true