From cb1e7a968d161837938ed03d49227d9109fdd688 Mon Sep 17 00:00:00 2001 From: Ian Elliott Date: Fri, 26 Aug 2022 21:50:37 -0600 Subject: [PATCH] Defer to Legacy driver if ANGLE deferlist hasn't been initialized ANGLE's deferlist is populated by the GUI code in the ANGLE APK. This code is not immediately run upon first-boot of a newly-flashed device. This change puts a default deferlist into the GraphicsEnvironment class, which will be used if the deferlist has not yet been processed. Bug: 241757590 Test: Manually test and inspect logcat output Change-Id: I12f355e891dfa466be37da5282af7a9586066c93 --- core/java/android/os/GraphicsEnvironment.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/core/java/android/os/GraphicsEnvironment.java b/core/java/android/os/GraphicsEnvironment.java index 43a6be5df202e..fb8f84acc8f39 100644 --- a/core/java/android/os/GraphicsEnvironment.java +++ b/core/java/android/os/GraphicsEnvironment.java @@ -469,7 +469,15 @@ public class GraphicsEnvironment { * 2) The per-application switch (i.e. Settings.Global.ANGLE_GL_DRIVER_SELECTION_PKGS and * Settings.Global.ANGLE_GL_DRIVER_SELECTION_VALUES; which corresponds to the * “angle_gl_driver_selection_pkgs” and “angle_gl_driver_selection_values” settings); if it - * forces a choice; otherwise ... + * forces a choice; + * - Workaround Note: ANGLE and Vulkan currently have issues with applications that use YUV + * target functionality. The ANGLE broadcast receiver code will apply a "deferlist" at + * the first boot of a newly-flashed device. However, there is a gap in time between + * when applications can start and when the deferlist is applied. For now, assume that + * if ANGLE is the system driver and Settings.Global.ANGLE_GL_DRIVER_SELECTION_PKGS is + * empty, that the deferlist has not yet been applied. In this case, select the Legacy + * driver. + * otherwise ... * 3) Use ANGLE if isAngleEnabledByGameMode() returns true; otherwise ... * 4) The global switch (i.e. use the system driver, whether ANGLE or legacy; * a.k.a. mAngleIsSystemDriver, which is set by the device’s “ro.hardware.egl” property) @@ -509,9 +517,16 @@ public class GraphicsEnvironment { final List optInValues = getGlobalSettingsString( contentResolver, bundle, Settings.Global.ANGLE_GL_DRIVER_SELECTION_VALUES); Log.v(TAG, "Currently set values for:"); - Log.v(TAG, " angle_gl_driver_selection_pkgs = " + optInPackages); + Log.v(TAG, " angle_gl_driver_selection_pkgs =" + optInPackages); Log.v(TAG, " angle_gl_driver_selection_values =" + optInValues); + // If ANGLE is the system driver AND the deferlist has not yet been applied, select the + // Legacy driver + if (mAngleIsSystemDriver && optInPackages.size() <= 1) { + Log.v(TAG, "Ignoring angle_gl_driver_selection_* until deferlist has been applied"); + return ANGLE_GL_DRIVER_TO_USE_LEGACY; + } + // Make sure we have good settings to use if (optInPackages.size() != optInValues.size()) { Log.w(TAG,