diff options
author | Peiyong Lin <lpy@google.com> | 2023-08-07 21:25:23 +0000 |
---|---|---|
committer | Peiyong Lin <lpy@google.com> | 2023-11-15 18:16:46 +0000 |
commit | 8fc1391a75334599dda64a88eafc5ec747fefeef (patch) | |
tree | 0d22eef5848f71709170655efd1dfc786abd290b | |
parent | 5a9826b8442b649df8bb74da7b68513ce503b39a (diff) | |
download | Settings-8fc1391a75334599dda64a88eafc5ec747fefeef.tar.gz |
Unconditionally enable ANGLE developer option UI.
Bug: b/283781993
Test: atest CtsAngleIntegrationHostTestCases -c
Test: atest SettingsRoboTests:GraphicsDriverEnableAngleAsSystemDriverControllerTest
Change-Id: I7f491151cc26dc10ccdb2900cfa81ff09c23b184
Merged-In: I7f491151cc26dc10ccdb2900cfa81ff09c23b184
3 files changed, 14 insertions, 86 deletions
diff --git a/src/com/android/settings/development/graphicsdriver/GraphicsDriverEnableAngleAsSystemDriverController.java b/src/com/android/settings/development/graphicsdriver/GraphicsDriverEnableAngleAsSystemDriverController.java index 992136c9b70..42c7de14518 100644 --- a/src/com/android/settings/development/graphicsdriver/GraphicsDriverEnableAngleAsSystemDriverController.java +++ b/src/com/android/settings/development/graphicsdriver/GraphicsDriverEnableAngleAsSystemDriverController.java @@ -52,9 +52,6 @@ public class GraphicsDriverEnableAngleAsSystemDriverController private boolean mShouldToggleSwitchBackOnRebootDialogDismiss; @VisibleForTesting - static final String PROPERTY_RO_GFX_ANGLE_SUPPORTED = "ro.gfx.angle.supported"; - - @VisibleForTesting static final String PROPERTY_PERSISTENT_GRAPHICS_EGL = "persist.graphics.egl"; @VisibleForTesting @@ -97,11 +94,6 @@ public class GraphicsDriverEnableAngleAsSystemDriverController return mSystemProperties.getBoolean(PROPERTY_DEBUG_ANGLE_DEVELOPER_OPTION, false); } - private boolean isAngleSupported() { - return TextUtils.equals( - mSystemProperties.get(PROPERTY_RO_GFX_ANGLE_SUPPORTED, ""), "true"); - } - @VisibleForTesting GraphicsDriverEnableAngleAsSystemDriverController( Context context, DevelopmentSettingsDashboardFragment fragment, Injector injector) { @@ -145,10 +137,6 @@ public class GraphicsDriverEnableAngleAsSystemDriverController /** Return the default value of "persist.graphics.egl" */ public boolean isDefaultValue() { - if (!isAngleSupported()) { - return true; - } - final String currentGlesDriver = mSystemProperties.get(PROPERTY_PERSISTENT_GRAPHICS_EGL, ""); // default value of "persist.graphics.egl" is "" @@ -158,17 +146,11 @@ public class GraphicsDriverEnableAngleAsSystemDriverController @Override public void updateState(Preference preference) { super.updateState(preference); - if (isAngleSupported()) { - // set switch on if "persist.graphics.egl" is "angle" and angle is built in /vendor - // set switch off otherwise. - final String currentGlesDriver = - mSystemProperties.get(PROPERTY_PERSISTENT_GRAPHICS_EGL, ""); - final boolean isAngle = TextUtils.equals(ANGLE_DRIVER_SUFFIX, currentGlesDriver); - ((SwitchPreference) mPreference).setChecked(isAngle); - } else { - mPreference.setEnabled(false); - ((SwitchPreference) mPreference).setChecked(false); - } + // set switch on if "persist.graphics.egl" is "angle". + final String currentGlesDriver = + mSystemProperties.get(PROPERTY_PERSISTENT_GRAPHICS_EGL, ""); + final boolean isAngle = TextUtils.equals(ANGLE_DRIVER_SUFFIX, currentGlesDriver); + ((SwitchPreference) mPreference).setChecked(isAngle); // Disable the developer option toggle UI if ANGLE is disabled, this means next time the // debug property needs to be set to true again to enable ANGLE. If ANGLE is enabled, don't @@ -182,12 +164,10 @@ public class GraphicsDriverEnableAngleAsSystemDriverController protected void onDeveloperOptionsSwitchDisabled() { // 1) disable the switch super.onDeveloperOptionsSwitchDisabled(); - if (isAngleSupported()) { - // 2) set the persist.graphics.egl empty string - GraphicsEnvironment.getInstance().toggleAngleAsSystemDriver(false); - // 3) reset the switch - ((SwitchPreference) mPreference).setChecked(false); - } + // 2) set the persist.graphics.egl empty string + GraphicsEnvironment.getInstance().toggleAngleAsSystemDriver(false); + // 3) reset the switch + ((SwitchPreference) mPreference).setChecked(false); } void toggleSwitchBack() { diff --git a/tests/robotests/src/com/android/settings/development/graphicsdriver/GraphicsDriverEnableAngleAsSystemDriverControllerTest.java b/tests/robotests/src/com/android/settings/development/graphicsdriver/GraphicsDriverEnableAngleAsSystemDriverControllerTest.java index 249acf5e539..e069a0b769a 100644 --- a/tests/robotests/src/com/android/settings/development/graphicsdriver/GraphicsDriverEnableAngleAsSystemDriverControllerTest.java +++ b/tests/robotests/src/com/android/settings/development/graphicsdriver/GraphicsDriverEnableAngleAsSystemDriverControllerTest.java @@ -19,7 +19,6 @@ package com.android.settings.development.graphicsdriver; import static com.android.settings.development.graphicsdriver.GraphicsDriverEnableAngleAsSystemDriverController.ANGLE_DRIVER_SUFFIX; import static com.android.settings.development.graphicsdriver.GraphicsDriverEnableAngleAsSystemDriverController.PROPERTY_DEBUG_ANGLE_DEVELOPER_OPTION; import static com.android.settings.development.graphicsdriver.GraphicsDriverEnableAngleAsSystemDriverController.PROPERTY_PERSISTENT_GRAPHICS_EGL; -import static com.android.settings.development.graphicsdriver.GraphicsDriverEnableAngleAsSystemDriverController.PROPERTY_RO_GFX_ANGLE_SUPPORTED; import static com.google.common.truth.Truth.assertThat; @@ -79,7 +78,6 @@ public class GraphicsDriverEnableAngleAsSystemDriverControllerTest { @Test public void onPreferenceChange_switchOn_shouldEnableAngleAsSystemDriver() { - ShadowSystemProperties.override(PROPERTY_RO_GFX_ANGLE_SUPPORTED, "true"); // since GraphicsEnvironment is mocked in Robolectric test environment, // we will override the system property persist.graphics.egl as if it is changed by // mGraphicsEnvironment.toggleAngleAsSystemDriver(true). @@ -96,7 +94,6 @@ public class GraphicsDriverEnableAngleAsSystemDriverControllerTest { @Test public void onPreferenceChange_switchOff_shouldDisableAngleAsSystemDriver() { - ShadowSystemProperties.override(PROPERTY_RO_GFX_ANGLE_SUPPORTED, "true"); // since GraphicsEnvironment is mocked in Robolectric test environment, // we will override the system property persist.graphics.egl as if it is changed by // mGraphicsEnvironment.toggleAngleAsSystemDriver(false). @@ -112,30 +109,14 @@ public class GraphicsDriverEnableAngleAsSystemDriverControllerTest { } @Test - public void updateState_angleNotSupported_preferenceShouldNotBeChecked() { - ShadowSystemProperties.override(PROPERTY_RO_GFX_ANGLE_SUPPORTED, ""); - mController.updateState(mPreference); - verify(mPreference).setChecked(false); - } - - @Test - public void updateState_angleNotSupported_preferenceShouldNotBeEnabled() { - ShadowSystemProperties.override(PROPERTY_RO_GFX_ANGLE_SUPPORTED, ""); - mController.updateState(mPreference); - verify(mPreference).setEnabled(false); - } - - @Test - public void updateState_angleSupported_angleUsed_preferenceShouldBeChecked() { - ShadowSystemProperties.override(PROPERTY_RO_GFX_ANGLE_SUPPORTED, "true"); + public void updateState_angleUsed_preferenceShouldBeChecked() { ShadowSystemProperties.override(PROPERTY_PERSISTENT_GRAPHICS_EGL, ANGLE_DRIVER_SUFFIX); mController.updateState(mPreference); verify(mPreference).setChecked(true); } @Test - public void updateState_angleSupported_angleNotUsed_preferenceShouldNotBeChecked() { - ShadowSystemProperties.override(PROPERTY_RO_GFX_ANGLE_SUPPORTED, "true"); + public void updateState_angleNotUsed_preferenceShouldNotBeChecked() { ShadowSystemProperties.override(PROPERTY_PERSISTENT_GRAPHICS_EGL, ""); mController.updateState(mPreference); verify(mPreference).setChecked(false); @@ -143,7 +124,6 @@ public class GraphicsDriverEnableAngleAsSystemDriverControllerTest { @Test public void onDeveloperOptionSwitchDisabled_shouldDisableAngleAsSystemDriver() { - ShadowSystemProperties.override(PROPERTY_RO_GFX_ANGLE_SUPPORTED, "true"); mController.onDeveloperOptionsSwitchDisabled(); final String systemEGLDriver = SystemProperties.get(PROPERTY_PERSISTENT_GRAPHICS_EGL); assertThat(systemEGLDriver).isEqualTo(""); @@ -151,14 +131,12 @@ public class GraphicsDriverEnableAngleAsSystemDriverControllerTest { @Test public void onDeveloperOptionSwitchDisabled_preferenceShouldNotBeChecked() { - ShadowSystemProperties.override(PROPERTY_RO_GFX_ANGLE_SUPPORTED, "true"); mController.onDeveloperOptionsSwitchDisabled(); verify(mPreference).setChecked(false); } @Test public void onDeveloperOptionsSwitchDisabled_preferenceShouldNotBeEnabled() { - ShadowSystemProperties.override(PROPERTY_RO_GFX_ANGLE_SUPPORTED, "true"); mController.onDeveloperOptionsSwitchDisabled(); verify(mPreference).setEnabled(false); } diff --git a/tests/unit/src/com/android/settings/development/graphicsdriver/GraphicsDriverEnableAngleAsSystemDriverControllerJUnitTest.java b/tests/unit/src/com/android/settings/development/graphicsdriver/GraphicsDriverEnableAngleAsSystemDriverControllerJUnitTest.java index a402d919f99..8304e5d6083 100644 --- a/tests/unit/src/com/android/settings/development/graphicsdriver/GraphicsDriverEnableAngleAsSystemDriverControllerJUnitTest.java +++ b/tests/unit/src/com/android/settings/development/graphicsdriver/GraphicsDriverEnableAngleAsSystemDriverControllerJUnitTest.java @@ -20,7 +20,6 @@ import static com.android.settings.development.graphicsdriver.GraphicsDriverEnab import static com.android.settings.development.graphicsdriver.GraphicsDriverEnableAngleAsSystemDriverController.Injector; import static com.android.settings.development.graphicsdriver.GraphicsDriverEnableAngleAsSystemDriverController.PROPERTY_DEBUG_ANGLE_DEVELOPER_OPTION; import static com.android.settings.development.graphicsdriver.GraphicsDriverEnableAngleAsSystemDriverController.PROPERTY_PERSISTENT_GRAPHICS_EGL; -import static com.android.settings.development.graphicsdriver.GraphicsDriverEnableAngleAsSystemDriverController.PROPERTY_RO_GFX_ANGLE_SUPPORTED; import static com.google.common.truth.Truth.assertThat; @@ -181,31 +180,13 @@ public class GraphicsDriverEnableAngleAsSystemDriverControllerJUnitTest { } @Test - public void updateState_angleNotSupported_PreferenceShouldDisabled() { - when(mSystemPropertiesMock.get(eq(PROPERTY_RO_GFX_ANGLE_SUPPORTED), any())).thenReturn(""); - mController.updateState(mPreference); - assertThat(mPreference.isEnabled()).isFalse(); - } - - @Test - public void updateState_angleNotSupported_PreferenceShouldNotBeChecked() { - when(mSystemPropertiesMock.get(eq(PROPERTY_RO_GFX_ANGLE_SUPPORTED), any())).thenReturn(""); - mController.updateState(mPreference); - assertThat(mPreference.isChecked()).isFalse(); - } - - @Test - public void updateState_angleSupported_PreferenceShouldEnabled() { - when(mSystemPropertiesMock.get(eq(PROPERTY_RO_GFX_ANGLE_SUPPORTED), any())) - .thenReturn("true"); + public void updateState_PreferenceShouldEnabled() { mController.updateState(mPreference); assertThat(mPreference.isEnabled()).isTrue(); } @Test - public void updateState_angleSupported_angleIsSystemGLESDriver_PreferenceShouldBeChecked() { - when(mSystemPropertiesMock.get(eq(PROPERTY_RO_GFX_ANGLE_SUPPORTED), any())) - .thenReturn("true"); + public void updateState_angleIsSystemGLESDriver_PreferenceShouldBeChecked() { when(mSystemPropertiesMock.get(eq(PROPERTY_PERSISTENT_GRAPHICS_EGL), any())) .thenReturn(ANGLE_DRIVER_SUFFIX); mController.updateState(mPreference); @@ -213,10 +194,7 @@ public class GraphicsDriverEnableAngleAsSystemDriverControllerJUnitTest { } @Test - public void - updateState_angleSupported_angleIsNotSystemGLESDriver_PreferenceShouldNotBeChecked() { - when(mSystemPropertiesMock.get(eq(PROPERTY_RO_GFX_ANGLE_SUPPORTED), any())) - .thenReturn("true"); + public void updateState_angleIsNotSystemGLESDriver_PreferenceShouldNotBeChecked() { when(mSystemPropertiesMock.get(eq(PROPERTY_PERSISTENT_GRAPHICS_EGL), any())).thenReturn(""); mController.updateState(mPreference); assertThat(mPreference.isChecked()).isFalse(); @@ -232,8 +210,6 @@ public class GraphicsDriverEnableAngleAsSystemDriverControllerJUnitTest { // Test that onDeveloperOptionSwitchDisabled, // persist.graphics.egl updates to "" - when(mSystemPropertiesMock.get(eq(PROPERTY_RO_GFX_ANGLE_SUPPORTED), any())) - .thenReturn("true"); mController.onDeveloperOptionsSwitchDisabled(); propertyChangeSignal1.wait(100); final String systemEGLDriver = SystemProperties.get(PROPERTY_PERSISTENT_GRAPHICS_EGL); @@ -245,16 +221,12 @@ public class GraphicsDriverEnableAngleAsSystemDriverControllerJUnitTest { @Test public void onDeveloperOptionSwitchDisabled_PreferenceShouldNotBeChecked() { - when(mSystemPropertiesMock.get(eq(PROPERTY_RO_GFX_ANGLE_SUPPORTED), any())) - .thenReturn("true"); mController.onDeveloperOptionsSwitchDisabled(); assertThat(mPreference.isChecked()).isFalse(); } @Test public void onDeveloperOptionSwitchDisabled_PreferenceShouldDisabled() { - when(mSystemPropertiesMock.get(eq(PROPERTY_RO_GFX_ANGLE_SUPPORTED), any())) - .thenReturn("true"); mController.onDeveloperOptionsSwitchDisabled(); assertThat(mPreference.isEnabled()).isFalse(); } @@ -480,8 +452,6 @@ public class GraphicsDriverEnableAngleAsSystemDriverControllerJUnitTest { // Test that when debug.graphics.angle.developeroption.enable is false: when(mSystemPropertiesMock.getBoolean(eq(PROPERTY_DEBUG_ANGLE_DEVELOPER_OPTION), anyBoolean())).thenReturn(false); - when(mSystemPropertiesMock.get(eq(PROPERTY_RO_GFX_ANGLE_SUPPORTED), any())) - .thenReturn("true"); // 1. "Enable ANGLE" switch is on, the switch should be enabled. when(mSystemPropertiesMock.get(eq(PROPERTY_PERSISTENT_GRAPHICS_EGL), any())) |