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

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

ANGLE: Allow libs from debug package

Add a new setting that allows a developer to specify where
to load ANGLE libraries from, rather than the default location.
This is only allowed for apps that are dumpable, i.e. can have
libraries injected.  That includes debuggable, profileable,
and root.

To use the new setting:

  adb shell settings put global angle_debug_package <package>

This allows a developer to build an APK directly from Chromium
and use it with a production build of Android. It will override
pre-installed system packages and updates.

Note: Use of ANGLE Developer Options UI will cease to function
until the debug package is uninstalled.

Bug: 80239516
Test: Apply setting, see new ANGLE used
Test: cts-tradefed run singleCommand cts -m CtsAngleIntegrationHostTestCases

Change-Id: Ib3b1fb52c0eb669e7ea931959a73aba2bd15bedf
parent 38d503fe
Loading
Loading
Loading
Loading
+36 −5
Original line number Diff line number Diff line
@@ -336,6 +336,25 @@ public class GraphicsEnvironment {
        return resolveInfos.get(0).activityInfo.packageName;
    }

    /**
     * Check for ANGLE debug package, but only for apps that can load them (dumpable)
     */
    private String getAngleDebugPackage(Context context, Bundle coreSettings) {
        final boolean appIsDebuggable = isDebuggable(context);
        final boolean appIsProfileable = isProfileable(context);
        final boolean deviceIsDebuggable = getCanLoadSystemLibraries() == 1;
        if (appIsDebuggable || appIsProfileable || deviceIsDebuggable) {

            String debugPackage =
                    coreSettings.getString(Settings.Global.GLOBAL_SETTINGS_ANGLE_DEBUG_PACKAGE);

            if ((debugPackage != null) && (!debugPackage.isEmpty())) {
                return debugPackage;
            }
        }
        return "";
    }

    /**
     * Attempt to setup ANGLE with a temporary rules file.
     * True: Temporary rules file was loaded.
@@ -502,12 +521,24 @@ public class GraphicsEnvironment {
        }

        final ApplicationInfo angleInfo;
        String angleDebugPackage = getAngleDebugPackage(context, bundle);
        if (!angleDebugPackage.isEmpty()) {
            Log.i(TAG, "ANGLE debug package enabled: " + angleDebugPackage);
            try {
                // Note the debug package does not have to be pre-installed
                angleInfo = pm.getApplicationInfo(angleDebugPackage, 0);
            } catch (PackageManager.NameNotFoundException e) {
                Log.w(TAG, "ANGLE debug package '" + angleDebugPackage + "' not installed");
                return false;
            }
        } else {
            try {
                angleInfo = pm.getApplicationInfo(anglePkgName, PackageManager.MATCH_SYSTEM_ONLY);
            } catch (PackageManager.NameNotFoundException e) {
                Log.w(TAG, "ANGLE package '" + anglePkgName + "' not installed");
                return false;
            }
        }

        final String abi = chooseAbi(angleInfo);

+8 −0
Original line number Diff line number Diff line
@@ -12452,6 +12452,14 @@ public final class Settings {
         */
        public static final String GPU_DEBUG_APP = "gpu_debug_app";
        /**
         * Package containing ANGLE libraries other than system, which are only available
         * to dumpable apps that opt-in.
         * @hide
         */
        public static final String GLOBAL_SETTINGS_ANGLE_DEBUG_PACKAGE =
                "angle_debug_package";
        /**
         * Force all PKGs to use ANGLE, regardless of any other settings
         * The value is a boolean (1 or 0).
+2 −0
Original line number Diff line number Diff line
@@ -455,6 +455,8 @@ message GlobalSettingsProto {
        optional SettingProto show_angle_in_use_dialog = 15;
        // Game Driver - List of libraries in sphal accessible by Game Driver
        optional SettingProto game_driver_sphal_libraries = 16;
        // ANGLE - External package containing ANGLE libraries
        optional SettingProto angle_debug_package = 17;
    }
    optional Gpu gpu = 59;

+1 −0
Original line number Diff line number Diff line
@@ -488,6 +488,7 @@ public class SettingsBackupTest {
                    Settings.Global.GPU_DEBUG_APP,
                    Settings.Global.GPU_DEBUG_LAYERS,
                    Settings.Global.GPU_DEBUG_LAYERS_GLES,
                    Settings.Global.GLOBAL_SETTINGS_ANGLE_DEBUG_PACKAGE,
                    Settings.Global.GLOBAL_SETTINGS_ANGLE_GL_DRIVER_ALL_ANGLE,
                    Settings.Global.GLOBAL_SETTINGS_ANGLE_GL_DRIVER_SELECTION_PKGS,
                    Settings.Global.GLOBAL_SETTINGS_ANGLE_GL_DRIVER_SELECTION_VALUES,
+3 −0
Original line number Diff line number Diff line
@@ -685,6 +685,9 @@ class SettingsProtoDumpUtil {
        dumpSetting(s, p,
                Settings.Global.GPU_DEBUG_LAYERS,
                GlobalSettingsProto.Gpu.DEBUG_LAYERS);
        dumpSetting(s, p,
                Settings.Global.GLOBAL_SETTINGS_ANGLE_DEBUG_PACKAGE,
                GlobalSettingsProto.Gpu.ANGLE_DEBUG_PACKAGE);
        dumpSetting(s, p,
                Settings.Global.GLOBAL_SETTINGS_ANGLE_GL_DRIVER_ALL_ANGLE,
                GlobalSettingsProto.Gpu.ANGLE_GL_DRIVER_ALL_ANGLE);
Loading