From ff9a4ee1c1127c3ec3078916e8403281314bb32f Mon Sep 17 00:00:00 2001 From: Yiwei Zhang Date: Wed, 12 Jun 2019 14:10:17 -0700 Subject: [PATCH] Game Driver: add support to apply prerelease driver for all apps Bug: 134881329 Test: Manual test with prerelease driver and Settings UI. Change-Id: I5f198b0845e9e6431066d44ef623f62e1f5c588a --- core/java/android/os/GraphicsEnvironment.java | 30 +++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/core/java/android/os/GraphicsEnvironment.java b/core/java/android/os/GraphicsEnvironment.java index 833bb8f6f7900..e0436ef8e3fc4 100644 --- a/core/java/android/os/GraphicsEnvironment.java +++ b/core/java/android/os/GraphicsEnvironment.java @@ -78,10 +78,12 @@ public class GraphicsEnvironment { // GAME_DRIVER_ALL_APPS // 0: Default (Invalid values fallback to default as well) // 1: All apps use Game Driver - // 2: All apps use system graphics driver + // 2: All apps use 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_ALL = 1; - private static final int GAME_DRIVER_GLOBAL_OPT_IN_NONE = 2; + 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 ClassLoader mClassLoader; private String mLayerPath; @@ -714,15 +716,19 @@ public class GraphicsEnvironment { // 4. GAME_DRIVER_OPT_IN_APPS // 5. GAME_DRIVER_BLACKLIST // 6. GAME_DRIVER_WHITELIST - final int globalOptIn = coreSettings.getInt(Settings.Global.GAME_DRIVER_ALL_APPS, 0); - if (globalOptIn == GAME_DRIVER_GLOBAL_OPT_IN_NONE) { - if (DEBUG) Log.v(TAG, "Game Driver is turned off on this device."); - return null; - } - - if (globalOptIn == GAME_DRIVER_GLOBAL_OPT_IN_ALL) { - if (DEBUG) Log.v(TAG, "All apps opt in to use Game Driver."); - return hasGameDriver ? gameDriver : null; + 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."); + 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."); + return hasPrereleaseDriver ? prereleaseDriver : null; + case GAME_DRIVER_GLOBAL_OPT_IN_DEFAULT: + default: + break; } final String appPackageName = ai.packageName;