Unconditionally enable ANGLE developer option UI.

Bug: b/283781993
Test: atest CtsAngleIntegrationHostTestCases -c
Test: atest SettingsRoboTests:GraphicsDriverEnableAngleAsSystemDriverControllerTest
Change-Id: I7f491151cc26dc10ccdb2900cfa81ff09c23b184
This commit is contained in:
Peiyong Lin
2023-08-07 21:25:23 +00:00
parent 2bf233e30b
commit aad20f216d
3 changed files with 14 additions and 86 deletions

View File

@@ -51,9 +51,6 @@ public class GraphicsDriverEnableAngleAsSystemDriverController
private boolean mShouldToggleSwitchBackOnRebootDialogDismiss; private boolean mShouldToggleSwitchBackOnRebootDialogDismiss;
@VisibleForTesting
static final String PROPERTY_RO_GFX_ANGLE_SUPPORTED = "ro.gfx.angle.supported";
@VisibleForTesting @VisibleForTesting
static final String PROPERTY_PERSISTENT_GRAPHICS_EGL = "persist.graphics.egl"; 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); return mSystemProperties.getBoolean(PROPERTY_DEBUG_ANGLE_DEVELOPER_OPTION, false);
} }
private boolean isAngleSupported() {
return TextUtils.equals(
mSystemProperties.get(PROPERTY_RO_GFX_ANGLE_SUPPORTED, ""), "true");
}
@VisibleForTesting @VisibleForTesting
GraphicsDriverEnableAngleAsSystemDriverController( GraphicsDriverEnableAngleAsSystemDriverController(
Context context, DevelopmentSettingsDashboardFragment fragment, Injector injector) { Context context, DevelopmentSettingsDashboardFragment fragment, Injector injector) {
@@ -145,10 +137,6 @@ public class GraphicsDriverEnableAngleAsSystemDriverController
/** Return the default value of "persist.graphics.egl" */ /** Return the default value of "persist.graphics.egl" */
public boolean isDefaultValue() { public boolean isDefaultValue() {
if (!isAngleSupported()) {
return true;
}
final String currentGlesDriver = final String currentGlesDriver =
mSystemProperties.get(PROPERTY_PERSISTENT_GRAPHICS_EGL, ""); mSystemProperties.get(PROPERTY_PERSISTENT_GRAPHICS_EGL, "");
// default value of "persist.graphics.egl" is "" // default value of "persist.graphics.egl" is ""
@@ -158,17 +146,11 @@ public class GraphicsDriverEnableAngleAsSystemDriverController
@Override @Override
public void updateState(Preference preference) { public void updateState(Preference preference) {
super.updateState(preference); super.updateState(preference);
if (isAngleSupported()) { // set switch on if "persist.graphics.egl" is "angle".
// set switch on if "persist.graphics.egl" is "angle" and angle is built in /vendor final String currentGlesDriver =
// set switch off otherwise. mSystemProperties.get(PROPERTY_PERSISTENT_GRAPHICS_EGL, "");
final String currentGlesDriver = final boolean isAngle = TextUtils.equals(ANGLE_DRIVER_SUFFIX, currentGlesDriver);
mSystemProperties.get(PROPERTY_PERSISTENT_GRAPHICS_EGL, ""); ((TwoStatePreference) mPreference).setChecked(isAngle);
final boolean isAngle = TextUtils.equals(ANGLE_DRIVER_SUFFIX, currentGlesDriver);
((TwoStatePreference) mPreference).setChecked(isAngle);
} else {
mPreference.setEnabled(false);
((TwoStatePreference) mPreference).setChecked(false);
}
// Disable the developer option toggle UI if ANGLE is disabled, this means next time the // 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 // 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() { protected void onDeveloperOptionsSwitchDisabled() {
// 1) disable the switch // 1) disable the switch
super.onDeveloperOptionsSwitchDisabled(); super.onDeveloperOptionsSwitchDisabled();
if (isAngleSupported()) { // 2) set the persist.graphics.egl empty string
// 2) set the persist.graphics.egl empty string GraphicsEnvironment.getInstance().toggleAngleAsSystemDriver(false);
GraphicsEnvironment.getInstance().toggleAngleAsSystemDriver(false); // 3) reset the switch
// 3) reset the switch ((TwoStatePreference) mPreference).setChecked(false);
((TwoStatePreference) mPreference).setChecked(false);
}
} }
void toggleSwitchBack() { void toggleSwitchBack() {

View File

@@ -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.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_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_PERSISTENT_GRAPHICS_EGL;
import static com.android.settings.development.graphicsdriver.GraphicsDriverEnableAngleAsSystemDriverController.PROPERTY_RO_GFX_ANGLE_SUPPORTED;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
@@ -83,7 +82,6 @@ public class GraphicsDriverEnableAngleAsSystemDriverControllerTest {
@Test @Test
public void onPreferenceChange_switchOn_shouldEnableAngleAsSystemDriver() { public void onPreferenceChange_switchOn_shouldEnableAngleAsSystemDriver() {
ShadowSystemProperties.override(PROPERTY_RO_GFX_ANGLE_SUPPORTED, "true");
// since GraphicsEnvironment is mocked in Robolectric test environment, // since GraphicsEnvironment is mocked in Robolectric test environment,
// we will override the system property persist.graphics.egl as if it is changed by // we will override the system property persist.graphics.egl as if it is changed by
// mGraphicsEnvironment.toggleAngleAsSystemDriver(true). // mGraphicsEnvironment.toggleAngleAsSystemDriver(true).
@@ -100,7 +98,6 @@ public class GraphicsDriverEnableAngleAsSystemDriverControllerTest {
@Test @Test
public void onPreferenceChange_switchOff_shouldDisableAngleAsSystemDriver() { public void onPreferenceChange_switchOff_shouldDisableAngleAsSystemDriver() {
ShadowSystemProperties.override(PROPERTY_RO_GFX_ANGLE_SUPPORTED, "true");
// since GraphicsEnvironment is mocked in Robolectric test environment, // since GraphicsEnvironment is mocked in Robolectric test environment,
// we will override the system property persist.graphics.egl as if it is changed by // we will override the system property persist.graphics.egl as if it is changed by
// mGraphicsEnvironment.toggleAngleAsSystemDriver(false). // mGraphicsEnvironment.toggleAngleAsSystemDriver(false).
@@ -116,30 +113,14 @@ public class GraphicsDriverEnableAngleAsSystemDriverControllerTest {
} }
@Test @Test
public void updateState_angleNotSupported_preferenceShouldNotBeChecked() { public void updateState_angleUsed_preferenceShouldBeChecked() {
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");
ShadowSystemProperties.override(PROPERTY_PERSISTENT_GRAPHICS_EGL, ANGLE_DRIVER_SUFFIX); ShadowSystemProperties.override(PROPERTY_PERSISTENT_GRAPHICS_EGL, ANGLE_DRIVER_SUFFIX);
mController.updateState(mPreference); mController.updateState(mPreference);
verify(mPreference).setChecked(true); verify(mPreference).setChecked(true);
} }
@Test @Test
public void updateState_angleSupported_angleNotUsed_preferenceShouldNotBeChecked() { public void updateState_angleNotUsed_preferenceShouldNotBeChecked() {
ShadowSystemProperties.override(PROPERTY_RO_GFX_ANGLE_SUPPORTED, "true");
ShadowSystemProperties.override(PROPERTY_PERSISTENT_GRAPHICS_EGL, ""); ShadowSystemProperties.override(PROPERTY_PERSISTENT_GRAPHICS_EGL, "");
mController.updateState(mPreference); mController.updateState(mPreference);
verify(mPreference).setChecked(false); verify(mPreference).setChecked(false);
@@ -147,7 +128,6 @@ public class GraphicsDriverEnableAngleAsSystemDriverControllerTest {
@Test @Test
public void onDeveloperOptionSwitchDisabled_shouldDisableAngleAsSystemDriver() { public void onDeveloperOptionSwitchDisabled_shouldDisableAngleAsSystemDriver() {
ShadowSystemProperties.override(PROPERTY_RO_GFX_ANGLE_SUPPORTED, "true");
mController.onDeveloperOptionsSwitchDisabled(); mController.onDeveloperOptionsSwitchDisabled();
final String systemEGLDriver = SystemProperties.get(PROPERTY_PERSISTENT_GRAPHICS_EGL); final String systemEGLDriver = SystemProperties.get(PROPERTY_PERSISTENT_GRAPHICS_EGL);
assertThat(systemEGLDriver).isEqualTo(""); assertThat(systemEGLDriver).isEqualTo("");
@@ -155,14 +135,12 @@ public class GraphicsDriverEnableAngleAsSystemDriverControllerTest {
@Test @Test
public void onDeveloperOptionSwitchDisabled_preferenceShouldNotBeChecked() { public void onDeveloperOptionSwitchDisabled_preferenceShouldNotBeChecked() {
ShadowSystemProperties.override(PROPERTY_RO_GFX_ANGLE_SUPPORTED, "true");
mController.onDeveloperOptionsSwitchDisabled(); mController.onDeveloperOptionsSwitchDisabled();
verify(mPreference).setChecked(false); verify(mPreference).setChecked(false);
} }
@Test @Test
public void onDeveloperOptionsSwitchDisabled_preferenceShouldNotBeEnabled() { public void onDeveloperOptionsSwitchDisabled_preferenceShouldNotBeEnabled() {
ShadowSystemProperties.override(PROPERTY_RO_GFX_ANGLE_SUPPORTED, "true");
mController.onDeveloperOptionsSwitchDisabled(); mController.onDeveloperOptionsSwitchDisabled();
verify(mPreference).setEnabled(false); verify(mPreference).setEnabled(false);
} }

View File

@@ -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.Injector;
import static com.android.settings.development.graphicsdriver.GraphicsDriverEnableAngleAsSystemDriverController.PROPERTY_DEBUG_ANGLE_DEVELOPER_OPTION; 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_PERSISTENT_GRAPHICS_EGL;
import static com.android.settings.development.graphicsdriver.GraphicsDriverEnableAngleAsSystemDriverController.PROPERTY_RO_GFX_ANGLE_SUPPORTED;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
@@ -181,31 +180,13 @@ public class GraphicsDriverEnableAngleAsSystemDriverControllerJUnitTest {
} }
@Test @Test
public void updateState_angleNotSupported_PreferenceShouldDisabled() { public void updateState_PreferenceShouldEnabled() {
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");
mController.updateState(mPreference); mController.updateState(mPreference);
assertThat(mPreference.isEnabled()).isTrue(); assertThat(mPreference.isEnabled()).isTrue();
} }
@Test @Test
public void updateState_angleSupported_angleIsSystemGLESDriver_PreferenceShouldBeChecked() { public void updateState_angleIsSystemGLESDriver_PreferenceShouldBeChecked() {
when(mSystemPropertiesMock.get(eq(PROPERTY_RO_GFX_ANGLE_SUPPORTED), any()))
.thenReturn("true");
when(mSystemPropertiesMock.get(eq(PROPERTY_PERSISTENT_GRAPHICS_EGL), any())) when(mSystemPropertiesMock.get(eq(PROPERTY_PERSISTENT_GRAPHICS_EGL), any()))
.thenReturn(ANGLE_DRIVER_SUFFIX); .thenReturn(ANGLE_DRIVER_SUFFIX);
mController.updateState(mPreference); mController.updateState(mPreference);
@@ -213,10 +194,7 @@ public class GraphicsDriverEnableAngleAsSystemDriverControllerJUnitTest {
} }
@Test @Test
public void public void updateState_angleIsNotSystemGLESDriver_PreferenceShouldNotBeChecked() {
updateState_angleSupported_angleIsNotSystemGLESDriver_PreferenceShouldNotBeChecked() {
when(mSystemPropertiesMock.get(eq(PROPERTY_RO_GFX_ANGLE_SUPPORTED), any()))
.thenReturn("true");
when(mSystemPropertiesMock.get(eq(PROPERTY_PERSISTENT_GRAPHICS_EGL), any())).thenReturn(""); when(mSystemPropertiesMock.get(eq(PROPERTY_PERSISTENT_GRAPHICS_EGL), any())).thenReturn("");
mController.updateState(mPreference); mController.updateState(mPreference);
assertThat(mPreference.isChecked()).isFalse(); assertThat(mPreference.isChecked()).isFalse();
@@ -232,8 +210,6 @@ public class GraphicsDriverEnableAngleAsSystemDriverControllerJUnitTest {
// Test that onDeveloperOptionSwitchDisabled, // Test that onDeveloperOptionSwitchDisabled,
// persist.graphics.egl updates to "" // persist.graphics.egl updates to ""
when(mSystemPropertiesMock.get(eq(PROPERTY_RO_GFX_ANGLE_SUPPORTED), any()))
.thenReturn("true");
mController.onDeveloperOptionsSwitchDisabled(); mController.onDeveloperOptionsSwitchDisabled();
propertyChangeSignal1.wait(100); propertyChangeSignal1.wait(100);
final String systemEGLDriver = SystemProperties.get(PROPERTY_PERSISTENT_GRAPHICS_EGL); final String systemEGLDriver = SystemProperties.get(PROPERTY_PERSISTENT_GRAPHICS_EGL);
@@ -245,16 +221,12 @@ public class GraphicsDriverEnableAngleAsSystemDriverControllerJUnitTest {
@Test @Test
public void onDeveloperOptionSwitchDisabled_PreferenceShouldNotBeChecked() { public void onDeveloperOptionSwitchDisabled_PreferenceShouldNotBeChecked() {
when(mSystemPropertiesMock.get(eq(PROPERTY_RO_GFX_ANGLE_SUPPORTED), any()))
.thenReturn("true");
mController.onDeveloperOptionsSwitchDisabled(); mController.onDeveloperOptionsSwitchDisabled();
assertThat(mPreference.isChecked()).isFalse(); assertThat(mPreference.isChecked()).isFalse();
} }
@Test @Test
public void onDeveloperOptionSwitchDisabled_PreferenceShouldDisabled() { public void onDeveloperOptionSwitchDisabled_PreferenceShouldDisabled() {
when(mSystemPropertiesMock.get(eq(PROPERTY_RO_GFX_ANGLE_SUPPORTED), any()))
.thenReturn("true");
mController.onDeveloperOptionsSwitchDisabled(); mController.onDeveloperOptionsSwitchDisabled();
assertThat(mPreference.isEnabled()).isFalse(); assertThat(mPreference.isEnabled()).isFalse();
} }
@@ -480,8 +452,6 @@ public class GraphicsDriverEnableAngleAsSystemDriverControllerJUnitTest {
// Test that when debug.graphics.angle.developeroption.enable is false: // Test that when debug.graphics.angle.developeroption.enable is false:
when(mSystemPropertiesMock.getBoolean(eq(PROPERTY_DEBUG_ANGLE_DEVELOPER_OPTION), when(mSystemPropertiesMock.getBoolean(eq(PROPERTY_DEBUG_ANGLE_DEVELOPER_OPTION),
anyBoolean())).thenReturn(false); 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. // 1. "Enable ANGLE" switch is on, the switch should be enabled.
when(mSystemPropertiesMock.get(eq(PROPERTY_PERSISTENT_GRAPHICS_EGL), any())) when(mSystemPropertiesMock.get(eq(PROPERTY_PERSISTENT_GRAPHICS_EGL), any()))