From 37df61fa8ea644efd8d4c5fd1831f45f1ebfbe9b Mon Sep 17 00:00:00 2001 From: Cody Northrop Date: Mon, 6 Mar 2023 17:02:31 -0700 Subject: [PATCH] GraphicsEnvironment: Fix ANGLE system driver selection logic When ANGLE is the system driver, we had a check that would ensure the deferlist had been applied before allowing ANGLE as the default driver. But rather than look at the deferlist, the check looked at the opt-in list size. That logic wasn't working, so the default scenario would always give you the legacy driver. To fix, check that the deferlist itself is not empty. Test: atest CtsAngleIntegrationHostTestCases (results unchanged) Test: angle_trace_test w/ ANGLE and native selected via settings Bug: b/271862350 Change-Id: I698fae2145dbfcad8657d6f62034b18bf580b6bb --- core/java/android/os/GraphicsEnvironment.java | 12 +++++++----- .../com/android/server/am/CoreSettingsObserver.java | 4 ++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/core/java/android/os/GraphicsEnvironment.java b/core/java/android/os/GraphicsEnvironment.java index fb8f84acc8f39..a52e3d49148d4 100644 --- a/core/java/android/os/GraphicsEnvironment.java +++ b/core/java/android/os/GraphicsEnvironment.java @@ -474,9 +474,8 @@ public class GraphicsEnvironment { * 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. + * if ANGLE is the system driver and Settings.Global.ANGLE_DEFERLIST 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; @@ -516,14 +515,17 @@ public class GraphicsEnvironment { contentResolver, bundle, Settings.Global.ANGLE_GL_DRIVER_SELECTION_PKGS); final List optInValues = getGlobalSettingsString( contentResolver, bundle, Settings.Global.ANGLE_GL_DRIVER_SELECTION_VALUES); + final List angleDeferlist = getGlobalSettingsString( + contentResolver, bundle, Settings.Global.ANGLE_DEFERLIST); Log.v(TAG, "Currently set values for:"); 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"); + if (mAngleIsSystemDriver && angleDeferlist.size() == 0) { + Log.v(TAG, "ANGLE deferlist (" + Settings.Global.ANGLE_DEFERLIST + ") has not been " + + "applied, defaulting to legacy driver"); return ANGLE_GL_DRIVER_TO_USE_LEGACY; } diff --git a/services/core/java/com/android/server/am/CoreSettingsObserver.java b/services/core/java/com/android/server/am/CoreSettingsObserver.java index 2e3e635c11576..ddc9e9166faa5 100644 --- a/services/core/java/com/android/server/am/CoreSettingsObserver.java +++ b/services/core/java/com/android/server/am/CoreSettingsObserver.java @@ -95,6 +95,10 @@ final class CoreSettingsObserver extends ContentObserver { Settings.Global.ANGLE_GL_DRIVER_SELECTION_VALUES, String.class); sGlobalSettingToTypeMap.put( Settings.Global.ANGLE_EGL_FEATURES, String.class); + sGlobalSettingToTypeMap.put( + Settings.Global.ANGLE_DEFERLIST, String.class); + sGlobalSettingToTypeMap.put( + Settings.Global.ANGLE_DEFERLIST_MODE, String.class); sGlobalSettingToTypeMap.put( Settings.Global.SHOW_ANGLE_IN_USE_DIALOG_BOX, String.class); sGlobalSettingToTypeMap.put(Settings.Global.ENABLE_GPU_DEBUG_LAYERS, int.class);