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
This commit is contained in:
Cody Northrop
2023-03-06 17:02:31 -07:00
parent 9ab308c675
commit 37df61fa8e
2 changed files with 11 additions and 5 deletions

View File

@@ -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<String> optInValues = getGlobalSettingsString(
contentResolver, bundle, Settings.Global.ANGLE_GL_DRIVER_SELECTION_VALUES);
final List<String> 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;
}

View File

@@ -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);