Loading core/java/android/os/GraphicsEnvironment.java +27 −22 Original line number Diff line number Diff line Loading @@ -37,8 +37,6 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.HashSet; import java.util.Set; /** @hide */ public class GraphicsEnvironment { Loading Loading @@ -70,7 +68,7 @@ public class GraphicsEnvironment { public void setup(Context context, Bundle coreSettings) { setupGpuLayers(context, coreSettings); setupAngle(context, coreSettings); chooseDriver(context); chooseDriver(context, coreSettings); } /** Loading Loading @@ -312,11 +310,12 @@ public class GraphicsEnvironment { /** * Choose whether the current process should use the builtin or an updated driver. */ private static void chooseDriver(Context context) { private static void chooseDriver(Context context, Bundle coreSettings) { String driverPackageName = SystemProperties.get(PROPERTY_GFX_DRIVER); if (driverPackageName == null || driverPackageName.isEmpty()) { return; } // To minimize risk of driver updates crippling the device beyond user repair, never use an // updated driver for privileged or non-updated system apps. Presumably pre-installed apps // were tested thoroughly with the pre-installed driver. Loading @@ -325,12 +324,16 @@ public class GraphicsEnvironment { if (DEBUG) Log.v(TAG, "ignoring driver package for privileged/non-updated system app"); return; } Set<String> whitelist = loadWhitelist(context, driverPackageName); // Empty whitelist implies no updatable graphics driver. Typically, the pre-installed // updatable graphics driver is supposed to be a place holder and contains no graphics // driver and whitelist. if (whitelist == null || whitelist.isEmpty()) { String applicationPackageName = context.getPackageName(); String devOptInApplicationName = coreSettings.getString( Settings.Global.UPDATED_GFX_DRIVER_DEV_OPT_IN_APP); boolean devOptIn = applicationPackageName.equals(devOptInApplicationName); boolean whitelisted = onWhitelist(context, driverPackageName, ai.packageName); if (!devOptIn && !whitelisted) { if (DEBUG) { Log.w(TAG, applicationPackageName + " is not on the whitelist."); } return; } Loading @@ -342,12 +345,6 @@ public class GraphicsEnvironment { Log.w(TAG, "driver package '" + driverPackageName + "' not installed"); return; } if (!whitelist.contains(context.getPackageName())) { if (DEBUG) { Log.w(TAG, context.getPackageName() + " is not on the whitelist."); } return; } // O drivers are restricted to the sphal linker namespace, so don't try to use // packages unless they declare they're compatible with that restriction. Loading Loading @@ -413,10 +410,18 @@ public class GraphicsEnvironment { return null; } private static Set<String> loadWhitelist(Context context, String driverPackageName) { private static boolean onWhitelist(Context context, String driverPackageName, String applicationPackageName) { String whitelistName = SystemProperties.get(PROPERTY_GFX_DRIVER_WHITELIST); // Empty whitelist implies no updatable graphics driver. Typically, the pre-installed // updatable graphics driver is supposed to be a place holder and contains no graphics // driver and whitelist. if (whitelistName == null || whitelistName.isEmpty()) { return null; if (DEBUG) { Log.w(TAG, "No whitelist found."); } return false; } try { Context driverContext = context.createPackageContext(driverPackageName, Loading @@ -424,11 +429,11 @@ public class GraphicsEnvironment { AssetManager assets = driverContext.getAssets(); InputStream stream = assets.open(whitelistName); BufferedReader reader = new BufferedReader(new InputStreamReader(stream)); Set<String> whitelist = new HashSet<>(); for (String line; (line = reader.readLine()) != null; ) { whitelist.add(line); for (String packageName; (packageName = reader.readLine()) != null; ) { if (packageName.equals(applicationPackageName)) { return true; } } return whitelist; } catch (PackageManager.NameNotFoundException e) { if (DEBUG) { Log.w(TAG, "driver package '" + driverPackageName + "' not installed"); Loading @@ -438,7 +443,7 @@ public class GraphicsEnvironment { Log.w(TAG, "Failed to load whitelist driver package, abort."); } } return null; return false; } private static native int getCanLoadSystemLibraries(); Loading core/java/android/provider/Settings.java +7 −0 Original line number Diff line number Diff line Loading @@ -11758,6 +11758,13 @@ public final class Settings { */ public static final String ANGLE_ENABLED_APP = "angle_enabled_app"; /** * App that is selected to use updated graphics driver. * @hide */ public static final String UPDATED_GFX_DRIVER_DEV_OPT_IN_APP = "updated_gfx_driver_dev_opt_in_app"; /** * Ordered GPU debug layer list for Vulkan * i.e. <layer1>:<layer2>:...:<layerN> Loading core/proto/android/providers/settings/global.proto +3 −0 Original line number Diff line number Diff line Loading @@ -405,6 +405,9 @@ message GlobalSettingsProto { // Ordered GPU debug layer list for GLES // i.e. <layer1>:<layer2>:...:<layerN> optional SettingProto debug_layers_gles = 5; // App opt in to load updated graphics driver instead of // native graphcis driver through developer options. optional SettingProto updated_gfx_driver_dev_opt_in_app = 6; } optional Gpu gpu = 59; Loading core/tests/coretests/src/android/provider/SettingsBackupTest.java +1 −0 Original line number Diff line number Diff line Loading @@ -457,6 +457,7 @@ public class SettingsBackupTest { Settings.Global.GPU_DEBUG_LAYERS, Settings.Global.GPU_DEBUG_LAYERS_GLES, Settings.Global.ANGLE_ENABLED_APP, Settings.Global.UPDATED_GFX_DRIVER_DEV_OPT_IN_APP, Settings.Global.GPU_DEBUG_LAYER_APP, Settings.Global.ENABLE_GNSS_RAW_MEAS_FULL_TRACKING, Settings.Global.INSTALL_CARRIER_APP_NOTIFICATION_PERSISTENT, Loading packages/SettingsLib/res/values/strings.xml +3 −0 Original line number Diff line number Diff line Loading @@ -1130,4 +1130,7 @@ <!-- The notice header of Third-party licenses. not translatable --> <string name="notice_header" translatable="false"></string> <!-- UI debug setting: opt in to use updated graphics driver? [CHAR LIMIT=100] --> <string name="updated_gfx_driver_dev_opt_in_app_summary">Opt in app to use updated graphcis driver in developement</string> </resources> Loading
core/java/android/os/GraphicsEnvironment.java +27 −22 Original line number Diff line number Diff line Loading @@ -37,8 +37,6 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.HashSet; import java.util.Set; /** @hide */ public class GraphicsEnvironment { Loading Loading @@ -70,7 +68,7 @@ public class GraphicsEnvironment { public void setup(Context context, Bundle coreSettings) { setupGpuLayers(context, coreSettings); setupAngle(context, coreSettings); chooseDriver(context); chooseDriver(context, coreSettings); } /** Loading Loading @@ -312,11 +310,12 @@ public class GraphicsEnvironment { /** * Choose whether the current process should use the builtin or an updated driver. */ private static void chooseDriver(Context context) { private static void chooseDriver(Context context, Bundle coreSettings) { String driverPackageName = SystemProperties.get(PROPERTY_GFX_DRIVER); if (driverPackageName == null || driverPackageName.isEmpty()) { return; } // To minimize risk of driver updates crippling the device beyond user repair, never use an // updated driver for privileged or non-updated system apps. Presumably pre-installed apps // were tested thoroughly with the pre-installed driver. Loading @@ -325,12 +324,16 @@ public class GraphicsEnvironment { if (DEBUG) Log.v(TAG, "ignoring driver package for privileged/non-updated system app"); return; } Set<String> whitelist = loadWhitelist(context, driverPackageName); // Empty whitelist implies no updatable graphics driver. Typically, the pre-installed // updatable graphics driver is supposed to be a place holder and contains no graphics // driver and whitelist. if (whitelist == null || whitelist.isEmpty()) { String applicationPackageName = context.getPackageName(); String devOptInApplicationName = coreSettings.getString( Settings.Global.UPDATED_GFX_DRIVER_DEV_OPT_IN_APP); boolean devOptIn = applicationPackageName.equals(devOptInApplicationName); boolean whitelisted = onWhitelist(context, driverPackageName, ai.packageName); if (!devOptIn && !whitelisted) { if (DEBUG) { Log.w(TAG, applicationPackageName + " is not on the whitelist."); } return; } Loading @@ -342,12 +345,6 @@ public class GraphicsEnvironment { Log.w(TAG, "driver package '" + driverPackageName + "' not installed"); return; } if (!whitelist.contains(context.getPackageName())) { if (DEBUG) { Log.w(TAG, context.getPackageName() + " is not on the whitelist."); } return; } // O drivers are restricted to the sphal linker namespace, so don't try to use // packages unless they declare they're compatible with that restriction. Loading Loading @@ -413,10 +410,18 @@ public class GraphicsEnvironment { return null; } private static Set<String> loadWhitelist(Context context, String driverPackageName) { private static boolean onWhitelist(Context context, String driverPackageName, String applicationPackageName) { String whitelistName = SystemProperties.get(PROPERTY_GFX_DRIVER_WHITELIST); // Empty whitelist implies no updatable graphics driver. Typically, the pre-installed // updatable graphics driver is supposed to be a place holder and contains no graphics // driver and whitelist. if (whitelistName == null || whitelistName.isEmpty()) { return null; if (DEBUG) { Log.w(TAG, "No whitelist found."); } return false; } try { Context driverContext = context.createPackageContext(driverPackageName, Loading @@ -424,11 +429,11 @@ public class GraphicsEnvironment { AssetManager assets = driverContext.getAssets(); InputStream stream = assets.open(whitelistName); BufferedReader reader = new BufferedReader(new InputStreamReader(stream)); Set<String> whitelist = new HashSet<>(); for (String line; (line = reader.readLine()) != null; ) { whitelist.add(line); for (String packageName; (packageName = reader.readLine()) != null; ) { if (packageName.equals(applicationPackageName)) { return true; } } return whitelist; } catch (PackageManager.NameNotFoundException e) { if (DEBUG) { Log.w(TAG, "driver package '" + driverPackageName + "' not installed"); Loading @@ -438,7 +443,7 @@ public class GraphicsEnvironment { Log.w(TAG, "Failed to load whitelist driver package, abort."); } } return null; return false; } private static native int getCanLoadSystemLibraries(); Loading
core/java/android/provider/Settings.java +7 −0 Original line number Diff line number Diff line Loading @@ -11758,6 +11758,13 @@ public final class Settings { */ public static final String ANGLE_ENABLED_APP = "angle_enabled_app"; /** * App that is selected to use updated graphics driver. * @hide */ public static final String UPDATED_GFX_DRIVER_DEV_OPT_IN_APP = "updated_gfx_driver_dev_opt_in_app"; /** * Ordered GPU debug layer list for Vulkan * i.e. <layer1>:<layer2>:...:<layerN> Loading
core/proto/android/providers/settings/global.proto +3 −0 Original line number Diff line number Diff line Loading @@ -405,6 +405,9 @@ message GlobalSettingsProto { // Ordered GPU debug layer list for GLES // i.e. <layer1>:<layer2>:...:<layerN> optional SettingProto debug_layers_gles = 5; // App opt in to load updated graphics driver instead of // native graphcis driver through developer options. optional SettingProto updated_gfx_driver_dev_opt_in_app = 6; } optional Gpu gpu = 59; Loading
core/tests/coretests/src/android/provider/SettingsBackupTest.java +1 −0 Original line number Diff line number Diff line Loading @@ -457,6 +457,7 @@ public class SettingsBackupTest { Settings.Global.GPU_DEBUG_LAYERS, Settings.Global.GPU_DEBUG_LAYERS_GLES, Settings.Global.ANGLE_ENABLED_APP, Settings.Global.UPDATED_GFX_DRIVER_DEV_OPT_IN_APP, Settings.Global.GPU_DEBUG_LAYER_APP, Settings.Global.ENABLE_GNSS_RAW_MEAS_FULL_TRACKING, Settings.Global.INSTALL_CARRIER_APP_NOTIFICATION_PERSISTENT, Loading
packages/SettingsLib/res/values/strings.xml +3 −0 Original line number Diff line number Diff line Loading @@ -1130,4 +1130,7 @@ <!-- The notice header of Third-party licenses. not translatable --> <string name="notice_header" translatable="false"></string> <!-- UI debug setting: opt in to use updated graphics driver? [CHAR LIMIT=100] --> <string name="updated_gfx_driver_dev_opt_in_app_summary">Opt in app to use updated graphcis driver in developement</string> </resources>