From 25b270c0f83e96fd33cd5c43dd077bc28905e73b Mon Sep 17 00:00:00 2001 From: Yuxin Hu Date: Wed, 19 Apr 2023 02:40:13 +0000 Subject: [PATCH] Add developer option switch to set ANGLE as the default system driver This change adds a new developer option switch called "Enable ANGLE". It defaults to off. User can choose to toggle it on and off, and the value of the system property "persist.graphics.egl" is changed accordingly: switch off: persist.graphics.egl="" switch on: persist.graphics.egl="angle" When user toggles the switch, a reboot window is popped up asking user to reboot now to make the change takes effect. If user chooses to cancel the reboot, the switch is toggled back. This enforces that a reboot is required whenever the "persis.graphics.egl" value changes. Upon reboot, we will load either ANGLE or native GLES driver as the system driver, based on the value of "persist.graphics.egl". The switch is disabled if ANGLE is not installed in /vendor partition. We use the system property "ro.gfx.angle.supported" as an indicator. We set the two conditions together in angle.mk file. Any device mk file that inherits angle.mk file will result in ANGLE libs installed in /vendor and "ro.gfx.angle.supported" set to true. Bug: b/270994705 Test: m; flash and check Pixel 7 boots fine atest SettingsRoboTests:GraphicsDriverEnableAngleAsSystemDriverControllerTest Change-Id: I565eff614472bb6ba50742e7dfa49b50dca2809f --- res/values/strings.xml | 7 + res/xml/development_settings.xml | 5 + .../DesktopModePreferenceController.java | 7 - .../DevelopmentSettingsDashboardFragment.java | 2 + .../FreeformWindowsPreferenceController.java | 7 - .../RebootConfirmationDialogFragment.java | 23 ++- .../RebootConfirmationDialogHost.java | 17 +- ...erEnableAngleAsSystemDriverController.java | 139 +++++++++++++++ ...ableAngleAsSystemDriverControllerTest.java | 164 ++++++++++++++++++ 9 files changed, 351 insertions(+), 20 deletions(-) create mode 100644 src/com/android/settings/development/graphicsdriver/GraphicsDriverEnableAngleAsSystemDriverController.java create mode 100644 tests/robotests/src/com/android/settings/development/graphicsdriver/GraphicsDriverEnableAngleAsSystemDriverControllerTest.java diff --git a/res/values/strings.xml b/res/values/strings.xml index e02d2a75762..10fd86ffc41 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -10440,6 +10440,13 @@ @string/graphics_driver_app_preference_system + + Enable ANGLE + + Enable ANGLE as system OpenGL ES driver + + A reboot is required to change the system OpenGL ES driver + App Compatibility Changes diff --git a/res/xml/development_settings.xml b/res/xml/development_settings.xml index b5ce57eb605..eb17fbf0828 100644 --- a/res/xml/development_settings.xml +++ b/res/xml/development_settings.xml @@ -243,6 +243,11 @@ android:title="@string/enable_gpu_debug_layers" android:summary="@string/enable_gpu_debug_layers_summary" /> + +