From aad20f216d03e49dbace41e51e7bb6df23f676b7 Mon Sep 17 00:00:00 2001 From: Peiyong Lin Date: Mon, 7 Aug 2023 21:25:23 +0000 Subject: [PATCH] Unconditionally enable ANGLE developer option UI. Bug: b/283781993 Test: atest CtsAngleIntegrationHostTestCases -c Test: atest SettingsRoboTests:GraphicsDriverEnableAngleAsSystemDriverControllerTest Change-Id: I7f491151cc26dc10ccdb2900cfa81ff09c23b184 --- ...erEnableAngleAsSystemDriverController.java | 38 +++++-------------- ...ableAngleAsSystemDriverControllerTest.java | 26 +------------ ...ngleAsSystemDriverControllerJUnitTest.java | 36 ++---------------- 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 482858fd779..e75ab1a53c4 100644 --- a/src/com/android/settings/development/graphicsdriver/GraphicsDriverEnableAngleAsSystemDriverController.java +++ b/src/com/android/settings/development/graphicsdriver/GraphicsDriverEnableAngleAsSystemDriverController.java @@ -51,9 +51,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"; @@ -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); - ((TwoStatePreference) mPreference).setChecked(isAngle); - } else { - mPreference.setEnabled(false); - ((TwoStatePreference) 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); + ((TwoStatePreference) 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 - ((TwoStatePreference) mPreference).setChecked(false); - } + // 2) set the persist.graphics.egl empty string + GraphicsEnvironment.getInstance().toggleAngleAsSystemDriver(false); + // 3) reset the switch + ((TwoStatePreference) 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 686df7a4dc2..e623eb80107 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; @@ -83,7 +82,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). @@ -100,7 +98,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). @@ -116,30 +113,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); @@ -147,7 +128,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(""); @@ -155,14 +135,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()))