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

Commit 73f4897f authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Rename game driver to updatable driver." into rvc-dev-plus-aosp am:...

Merge "Rename game driver to updatable driver." into rvc-dev-plus-aosp am: 377b7f31 am: f6d2c0ab

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12375470

Change-Id: Ib327facf7026ac4f406846128c84005478fd2d2c
parents be051117 f6d2c0ab
Loading
Loading
Loading
Loading
+55 −48
Original line number Diff line number Diff line
@@ -64,10 +64,11 @@ public class GraphicsEnvironment {
    private static final String SYSTEM_DRIVER_NAME = "system";
    private static final String SYSTEM_DRIVER_VERSION_NAME = "";
    private static final long SYSTEM_DRIVER_VERSION_CODE = 0;
    private static final String PROPERTY_GFX_DRIVER = "ro.gfx.driver.0";
    private static final String PROPERTY_GFX_DRIVER_PRODUCTION = "ro.gfx.driver.0";
    private static final String PROPERTY_GFX_DRIVER_PRERELEASE = "ro.gfx.driver.1";
    private static final String PROPERTY_GFX_DRIVER_BUILD_TIME = "ro.gfx.driver_build_time";
    private static final String METADATA_DRIVER_BUILD_TIME = "com.android.gamedriver.build_time";
    private static final String METADATA_DRIVER_BUILD_TIME =
            "com.android.graphics.updatabledriver.build_time";
    private static final String METADATA_DEVELOPER_DRIVER_ENABLE =
            "com.android.graphics.developerdriver.enable";
    private static final String METADATA_INJECT_LAYERS_ENABLE =
@@ -78,20 +79,20 @@ public class GraphicsEnvironment {
    private static final String ACTION_ANGLE_FOR_ANDROID_TOAST_MESSAGE =
            "android.app.action.ANGLE_FOR_ANDROID_TOAST_MESSAGE";
    private static final String INTENT_KEY_A4A_TOAST_MESSAGE = "A4A Toast Message";
    private static final String GAME_DRIVER_ALLOWLIST_ALL = "*";
    private static final String GAME_DRIVER_SPHAL_LIBRARIES_FILENAME = "sphal_libraries.txt";
    private static final String UPDATABLE_DRIVER_ALLOWLIST_ALL = "*";
    private static final String UPDATABLE_DRIVER_SPHAL_LIBRARIES_FILENAME = "sphal_libraries.txt";
    private static final int VULKAN_1_0 = 0x00400000;
    private static final int VULKAN_1_1 = 0x00401000;

    // GAME_DRIVER_ALL_APPS
    // UPDATABLE_DRIVER_ALL_APPS
    // 0: Default (Invalid values fallback to default as well)
    // 1: All apps use Game Driver
    // 2: All apps use Prerelease Driver
    // 1: All apps use updatable production driver
    // 2: All apps use updatable prerelease driver
    // 3: All apps use system graphics driver
    private static final int GAME_DRIVER_GLOBAL_OPT_IN_DEFAULT = 0;
    private static final int GAME_DRIVER_GLOBAL_OPT_IN_GAME_DRIVER = 1;
    private static final int GAME_DRIVER_GLOBAL_OPT_IN_PRERELEASE_DRIVER = 2;
    private static final int GAME_DRIVER_GLOBAL_OPT_IN_OFF = 3;
    private static final int UPDATABLE_DRIVER_GLOBAL_OPT_IN_DEFAULT = 0;
    private static final int UPDATABLE_DRIVER_GLOBAL_OPT_IN_PRODUCTION_DRIVER = 1;
    private static final int UPDATABLE_DRIVER_GLOBAL_OPT_IN_PRERELEASE_DRIVER = 2;
    private static final int UPDATABLE_DRIVER_GLOBAL_OPT_IN_OFF = 3;

    private ClassLoader mClassLoader;
    private String mLibrarySearchPaths;
@@ -722,14 +723,17 @@ public class GraphicsEnvironment {
     * Return the driver package name to use. Return null for system driver.
     */
    private static String chooseDriverInternal(Bundle coreSettings, ApplicationInfo ai) {
        final String gameDriver = SystemProperties.get(PROPERTY_GFX_DRIVER);
        final boolean hasGameDriver = gameDriver != null && !gameDriver.isEmpty();
        final String productionDriver = SystemProperties.get(PROPERTY_GFX_DRIVER_PRODUCTION);
        final boolean hasProductionDriver = productionDriver != null && !productionDriver.isEmpty();

        final String prereleaseDriver = SystemProperties.get(PROPERTY_GFX_DRIVER_PRERELEASE);
        final boolean hasPrereleaseDriver = prereleaseDriver != null && !prereleaseDriver.isEmpty();

        if (!hasGameDriver && !hasPrereleaseDriver) {
            if (DEBUG) Log.v(TAG, "Neither Game Driver nor prerelease driver is supported.");
        if (!hasProductionDriver && !hasPrereleaseDriver) {
            if (DEBUG) {
                Log.v(TAG,
                        "Neither updatable production driver nor prerelease driver is supported.");
            }
            return null;
        }

@@ -745,56 +749,59 @@ public class GraphicsEnvironment {
                (ai.metaData != null && ai.metaData.getBoolean(METADATA_DEVELOPER_DRIVER_ENABLE))
                || isDebuggable();

        // Priority for Game Driver settings global on confliction (Higher priority comes first):
        // 1. GAME_DRIVER_ALL_APPS
        // 2. GAME_DRIVER_OPT_OUT_APPS
        // 3. GAME_DRIVER_PRERELEASE_OPT_IN_APPS
        // 4. GAME_DRIVER_OPT_IN_APPS
        // 5. GAME_DRIVER_DENYLIST
        // 6. GAME_DRIVER_ALLOWLIST
        switch (coreSettings.getInt(Settings.Global.GAME_DRIVER_ALL_APPS, 0)) {
            case GAME_DRIVER_GLOBAL_OPT_IN_OFF:
                if (DEBUG) Log.v(TAG, "Game Driver is turned off on this device.");
        // Priority of updatable driver settings on confliction (Higher priority comes first):
        // 1. UPDATABLE_DRIVER_ALL_APPS
        // 2. UPDATABLE_DRIVER_PRODUCTION_OPT_OUT_APPS
        // 3. UPDATABLE_DRIVER_PRERELEASE_OPT_IN_APPS
        // 4. UPDATABLE_DRIVER_PRODUCTION_OPT_IN_APPS
        // 5. UPDATABLE_DRIVER_PRODUCTION_DENYLIST
        // 6. UPDATABLE_DRIVER_PRODUCTION_ALLOWLIST
        switch (coreSettings.getInt(Settings.Global.UPDATABLE_DRIVER_ALL_APPS, 0)) {
            case UPDATABLE_DRIVER_GLOBAL_OPT_IN_OFF:
                if (DEBUG) Log.v(TAG, "updatable driver is turned off on this device.");
                return null;
            case GAME_DRIVER_GLOBAL_OPT_IN_GAME_DRIVER:
                if (DEBUG) Log.v(TAG, "All apps opt in to use Game Driver.");
                return hasGameDriver ? gameDriver : null;
            case GAME_DRIVER_GLOBAL_OPT_IN_PRERELEASE_DRIVER:
                if (DEBUG) Log.v(TAG, "All apps opt in to use prerelease driver.");
            case UPDATABLE_DRIVER_GLOBAL_OPT_IN_PRODUCTION_DRIVER:
                if (DEBUG) Log.v(TAG, "All apps opt in to use updatable production driver.");
                return hasProductionDriver ? productionDriver : null;
            case UPDATABLE_DRIVER_GLOBAL_OPT_IN_PRERELEASE_DRIVER:
                if (DEBUG) Log.v(TAG, "All apps opt in to use updatable prerelease driver.");
                return hasPrereleaseDriver && enablePrereleaseDriver ? prereleaseDriver : null;
            case GAME_DRIVER_GLOBAL_OPT_IN_DEFAULT:
            case UPDATABLE_DRIVER_GLOBAL_OPT_IN_DEFAULT:
            default:
                break;
        }

        final String appPackageName = ai.packageName;
        if (getGlobalSettingsString(null, coreSettings, Settings.Global.GAME_DRIVER_OPT_OUT_APPS)
        if (getGlobalSettingsString(null, coreSettings,
                                    Settings.Global.UPDATABLE_DRIVER_PRODUCTION_OPT_OUT_APPS)
                        .contains(appPackageName)) {
            if (DEBUG) Log.v(TAG, "App opts out for Game Driver.");
            if (DEBUG) Log.v(TAG, "App opts out for updatable production driver.");
            return null;
        }

        if (getGlobalSettingsString(
                    null, coreSettings, Settings.Global.GAME_DRIVER_PRERELEASE_OPT_IN_APPS)
                    null, coreSettings, Settings.Global.UPDATABLE_DRIVER_PRERELEASE_OPT_IN_APPS)
                        .contains(appPackageName)) {
            if (DEBUG) Log.v(TAG, "App opts in for prerelease Game Driver.");
            if (DEBUG) Log.v(TAG, "App opts in for updatable prerelease driver.");
            return hasPrereleaseDriver && enablePrereleaseDriver ? prereleaseDriver : null;
        }

        // Early return here since the rest logic is only for Game Driver.
        if (!hasGameDriver) {
            if (DEBUG) Log.v(TAG, "Game Driver is not supported on the device.");
        // Early return here since the rest logic is only for updatable production Driver.
        if (!hasProductionDriver) {
            if (DEBUG) Log.v(TAG, "Updatable production driver is not supported on the device.");
            return null;
        }

        final boolean isOptIn =
                getGlobalSettingsString(null, coreSettings, Settings.Global.GAME_DRIVER_OPT_IN_APPS)
                getGlobalSettingsString(null, coreSettings,
                                        Settings.Global.UPDATABLE_DRIVER_PRODUCTION_OPT_IN_APPS)
                        .contains(appPackageName);
        final List<String> allowlist =
                getGlobalSettingsString(null, coreSettings, Settings.Global.GAME_DRIVER_ALLOWLIST);
        if (!isOptIn && allowlist.indexOf(GAME_DRIVER_ALLOWLIST_ALL) != 0
                getGlobalSettingsString(null, coreSettings,
                                        Settings.Global.UPDATABLE_DRIVER_PRODUCTION_ALLOWLIST);
        if (!isOptIn && allowlist.indexOf(UPDATABLE_DRIVER_ALLOWLIST_ALL) != 0
                && !allowlist.contains(appPackageName)) {
            if (DEBUG) Log.v(TAG, "App is not on the allowlist for Game Driver.");
            if (DEBUG) Log.v(TAG, "App is not on the allowlist for updatable production driver.");
            return null;
        }

@@ -802,13 +809,13 @@ public class GraphicsEnvironment {
        // terminate early if it's on the denylist and fallback to system driver.
        if (!isOptIn
                && getGlobalSettingsString(
                        null, coreSettings, Settings.Global.GAME_DRIVER_DENYLIST)
                        null, coreSettings, Settings.Global.UPDATABLE_DRIVER_PRODUCTION_DENYLIST)
                           .contains(appPackageName)) {
            if (DEBUG) Log.v(TAG, "App is on the denylist for Game Driver.");
            if (DEBUG) Log.v(TAG, "App is on the denylist for updatable production driver.");
            return null;
        }

        return gameDriver;
        return productionDriver;
    }

    /**
@@ -873,7 +880,7 @@ public class GraphicsEnvironment {

        final String driverBuildTime = driverAppInfo.metaData.getString(METADATA_DRIVER_BUILD_TIME);
        if (driverBuildTime == null || driverBuildTime.isEmpty()) {
            throw new IllegalArgumentException("com.android.gamedriver.build_time is not set");
            Log.v(TAG, "com.android.graphics.updatabledriver.build_time is not set");
        }
        // driver_build_time in the meta-data is in "L<Unix epoch timestamp>" format. e.g. L123456.
        // Long.parseLong will throw if the meta-data "driver_build_time" is not set properly.
@@ -901,7 +908,7 @@ public class GraphicsEnvironment {
            final Context driverContext =
                    context.createPackageContext(driverPackageName, Context.CONTEXT_RESTRICTED);
            final BufferedReader reader = new BufferedReader(new InputStreamReader(
                    driverContext.getAssets().open(GAME_DRIVER_SPHAL_LIBRARIES_FILENAME)));
                    driverContext.getAssets().open(UPDATABLE_DRIVER_SPHAL_LIBRARIES_FILENAME)));
            final ArrayList<String> assetStrings = new ArrayList<>();
            for (String assetString; (assetString = reader.readLine()) != null;) {
                assetStrings.add(assetString);
@@ -913,7 +920,7 @@ public class GraphicsEnvironment {
            }
        } catch (IOException e) {
            if (DEBUG) {
                Log.w(TAG, "Failed to load '" + GAME_DRIVER_SPHAL_LIBRARIES_FILENAME + "'");
                Log.w(TAG, "Failed to load '" + UPDATABLE_DRIVER_SPHAL_LIBRARIES_FILENAME + "'");
            }
        }
        return "";
+27 −19
Original line number Diff line number Diff line
@@ -12280,63 +12280,71 @@ public final class Settings {
                "show_angle_in_use_dialog_box";
        /**
         * Game Driver global preference for all Apps.
         * Updatable driver global preference for all Apps.
         * 0 = Default
         * 1 = All Apps use Game Driver
         * 2 = All Apps use system graphics driver
         * 1 = All Apps use updatable production driver
         * 2 = All apps use updatable prerelease driver
         * 3 = All Apps use system graphics driver
         * @hide
         */
        public static final String GAME_DRIVER_ALL_APPS = "game_driver_all_apps";
        public static final String UPDATABLE_DRIVER_ALL_APPS = "updatable_driver_all_apps";
        /**
         * List of Apps selected to use Game Driver.
         * List of Apps selected to use updatable production driver.
         * i.e. <pkg1>,<pkg2>,...,<pkgN>
         * @hide
         */
        public static final String GAME_DRIVER_OPT_IN_APPS = "game_driver_opt_in_apps";
        public static final String UPDATABLE_DRIVER_PRODUCTION_OPT_IN_APPS =
                "updatable_driver_production_opt_in_apps";
        /**
         * List of Apps selected to use prerelease Game Driver.
         * List of Apps selected to use updatable prerelease driver.
         * i.e. <pkg1>,<pkg2>,...,<pkgN>
         * @hide
         */
        public static final String GAME_DRIVER_PRERELEASE_OPT_IN_APPS =
                "game_driver_prerelease_opt_in_apps";
        public static final String UPDATABLE_DRIVER_PRERELEASE_OPT_IN_APPS =
                "updatable_driver_prerelease_opt_in_apps";
        /**
         * List of Apps selected not to use Game Driver.
         * List of Apps selected not to use updatable production driver.
         * i.e. <pkg1>,<pkg2>,...,<pkgN>
         * @hide
         */
        public static final String GAME_DRIVER_OPT_OUT_APPS = "game_driver_opt_out_apps";
        public static final String UPDATABLE_DRIVER_PRODUCTION_OPT_OUT_APPS =
                "updatable_driver_production_opt_out_apps";
        /**
         * Apps on the denylist that are forbidden to use Game Driver.
         * Apps on the denylist that are forbidden to use updatable production driver.
         * @hide
         */
        public static final String GAME_DRIVER_DENYLIST = "game_driver_denylist";
        public static final String UPDATABLE_DRIVER_PRODUCTION_DENYLIST =
                "updatable_driver_production_denylist";
        /**
         * List of denylists, each denylist is a denylist for a specific version of Game Driver.
         * List of denylists, each denylist is a denylist for a specific version of
         * updatable production driver.
         * @hide
         */
        public static final String GAME_DRIVER_DENYLISTS = "game_driver_denylists";
        public static final String UPDATABLE_DRIVER_PRODUCTION_DENYLISTS =
                "updatable_driver_production_denylists";
        /**
         * Apps on the allowlist that are allowed to use Game Driver.
         * Apps on the allowlist that are allowed to use updatable production driver.
         * The string is a list of application package names, seperated by comma.
         * i.e. <apk1>,<apk2>,...,<apkN>
         * @hide
         */
        public static final String GAME_DRIVER_ALLOWLIST = "game_driver_allowlist";
        public static final String UPDATABLE_DRIVER_PRODUCTION_ALLOWLIST =
                "updatable_driver_production_allowlist";
        /**
         * List of libraries in sphal accessible by Game Driver
         * List of libraries in sphal accessible by updatable driver
         * The string is a list of library names, separated by colon.
         * i.e. <lib1>:<lib2>:...:<libN>
         * @hide
         */
        public static final String GAME_DRIVER_SPHAL_LIBRARIES = "game_driver_sphal_libraries";
        public static final String UPDATABLE_DRIVER_SPHAL_LIBRARIES =
                "updatable_driver_sphal_libraries";
        /**
         * Ordered GPU debug layer list for Vulkan
+2 −2
Original line number Diff line number Diff line
@@ -2310,10 +2310,10 @@ enum PageId {
    // OS: Q
    ZEN_CUSTOM_SETTINGS_DIALOG = 1612;

    // OPEN: Settings > Developer Options > Game Driver Preferences
    // OPEN: Settings > Developer Options > Graphics Driver Preferences
    // CATEGORY: SETTINGS
    // OS: Q
    SETTINGS_GAME_DRIVER_DASHBOARD = 1613;
    SETTINGS_GRAPHICS_DRIVER_DASHBOARD = 1613;

    // OPEN: Settings > Accessibility > Vibration > Ring vibration
    // CATEGORY: SETTINGS
+20 −19
Original line number Diff line number Diff line
@@ -433,35 +433,36 @@ message GlobalSettingsProto {
        // Ordered GPU debug layer list for GLES
        // i.e. <layer1>:<layer2>:...:<layerN>
        optional SettingProto debug_layers_gles = 7;
        // Game Driver - global preference for all Apps
        // Updatable Driver - global preference for all Apps
        // 0 = Default
        // 1 = All Apps use Game Driver
        // 2 = All Apps use system graphics driver
        optional SettingProto game_driver_all_apps = 8;
        // Game Driver - List of Apps selected to use Game Driver
        // 1 = All Apps use updatable production driver
        // 2 = All apps use updatable prerelease driver
        // 3 = All Apps use system graphics driver
        optional SettingProto updatable_driver_all_apps = 8;
        // Updatable Driver - List of Apps selected to use updatable production driver
        // i.e. <pkg1>,<pkg2>,...,<pkgN>
        optional SettingProto game_driver_opt_in_apps = 9;
        // Game Driver - List of Apps selected not to use Game Driver
        optional SettingProto updatable_driver_production_opt_in_apps = 9;
        // Updatable Driver - List of Apps selected not to use updatable production driver
        // i.e. <pkg1>,<pkg2>,...,<pkgN>
        optional SettingProto game_driver_opt_out_apps = 10;
        // Game Driver - List of Apps that are forbidden to use Game Driver
        optional SettingProto game_driver_denylist = 11;
        // Game Driver - List of Apps that are allowed to use Game Driver
        optional SettingProto game_driver_allowlist = 12;
        optional SettingProto updatable_driver_production_opt_out_apps = 10;
        // Updatable Driver - List of Apps that are forbidden to use updatable production driver
        optional SettingProto updatable_driver_production_denylist = 11;
        // Updatable Driver - List of Apps that are allowed to use updatable production driver
        optional SettingProto updatable_driver_production_allowlist = 12;
        // ANGLE - List of Apps that can check ANGLE rules
        optional SettingProto angle_allowlist = 13;
        // Game Driver - List of denylists, each denylist is a denylist for
        // a specific Game Driver version
        optional SettingProto game_driver_denylists = 14;
        // Updatable Driver - List of denylists, each denylist is a denylist for
        // a specific updatable production driver version
        optional SettingProto updatable_driver_production_denylists = 14;
        // ANGLE - Show a dialog box when ANGLE is selected for the currently running PKG
        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;
        // Updatable Driver - List of libraries in sphal accessible by updatable driver
        optional SettingProto updatable_driver_sphal_libraries = 16;
        // ANGLE - External package containing ANGLE libraries
        optional SettingProto angle_debug_package = 17;
        // Game Driver - List of Apps selected to use prerelease Game Driver
        // Updatable Driver - List of Apps selected to use updatable prerelease driver
        // i.e. <pkg1>,<pkg2>,...,<pkgN>
        optional SettingProto game_driver_prerelease_opt_in_apps = 18;
        optional SettingProto updatable_driver_prerelease_opt_in_apps = 18;
    }
    optional Gpu gpu = 59;

+16 −16
Original line number Diff line number Diff line
@@ -773,29 +773,29 @@ class SettingsProtoDumpUtil {
                Settings.Global.GPU_DEBUG_LAYERS_GLES,
                GlobalSettingsProto.Gpu.DEBUG_LAYERS_GLES);
        dumpSetting(s, p,
                Settings.Global.GAME_DRIVER_ALL_APPS,
                GlobalSettingsProto.Gpu.GAME_DRIVER_ALL_APPS);
                Settings.Global.UPDATABLE_DRIVER_ALL_APPS,
                GlobalSettingsProto.Gpu.UPDATABLE_DRIVER_ALL_APPS);
        dumpSetting(s, p,
                Settings.Global.GAME_DRIVER_OPT_IN_APPS,
                GlobalSettingsProto.Gpu.GAME_DRIVER_OPT_IN_APPS);
                Settings.Global.UPDATABLE_DRIVER_PRODUCTION_OPT_IN_APPS,
                GlobalSettingsProto.Gpu.UPDATABLE_DRIVER_PRODUCTION_OPT_IN_APPS);
        dumpSetting(s, p,
                Settings.Global.GAME_DRIVER_PRERELEASE_OPT_IN_APPS,
                GlobalSettingsProto.Gpu.GAME_DRIVER_PRERELEASE_OPT_IN_APPS);
                Settings.Global.UPDATABLE_DRIVER_PRERELEASE_OPT_IN_APPS,
                GlobalSettingsProto.Gpu.UPDATABLE_DRIVER_PRERELEASE_OPT_IN_APPS);
        dumpSetting(s, p,
                Settings.Global.GAME_DRIVER_OPT_OUT_APPS,
                GlobalSettingsProto.Gpu.GAME_DRIVER_OPT_OUT_APPS);
                Settings.Global.UPDATABLE_DRIVER_PRODUCTION_OPT_OUT_APPS,
                GlobalSettingsProto.Gpu.UPDATABLE_DRIVER_PRODUCTION_OPT_OUT_APPS);
        dumpSetting(s, p,
                Settings.Global.GAME_DRIVER_DENYLIST,
                GlobalSettingsProto.Gpu.GAME_DRIVER_DENYLIST);
                Settings.Global.UPDATABLE_DRIVER_PRODUCTION_DENYLIST,
                GlobalSettingsProto.Gpu.UPDATABLE_DRIVER_PRODUCTION_DENYLIST);
        dumpSetting(s, p,
                Settings.Global.GAME_DRIVER_ALLOWLIST,
                GlobalSettingsProto.Gpu.GAME_DRIVER_ALLOWLIST);
                Settings.Global.UPDATABLE_DRIVER_PRODUCTION_ALLOWLIST,
                GlobalSettingsProto.Gpu.UPDATABLE_DRIVER_PRODUCTION_ALLOWLIST);
        dumpSetting(s, p,
                Settings.Global.GAME_DRIVER_DENYLISTS,
                GlobalSettingsProto.Gpu.GAME_DRIVER_DENYLISTS);
                Settings.Global.UPDATABLE_DRIVER_PRODUCTION_DENYLISTS,
                GlobalSettingsProto.Gpu.UPDATABLE_DRIVER_PRODUCTION_DENYLISTS);
        dumpSetting(s, p,
                Settings.Global.GAME_DRIVER_SPHAL_LIBRARIES,
                GlobalSettingsProto.Gpu.GAME_DRIVER_SPHAL_LIBRARIES);
                Settings.Global.UPDATABLE_DRIVER_SPHAL_LIBRARIES,
                GlobalSettingsProto.Gpu.UPDATABLE_DRIVER_SPHAL_LIBRARIES);
        p.end(gpuToken);

        final long hdmiToken = p.start(GlobalSettingsProto.HDMI);
Loading