Allow ANGLE developer option toggle UI enabled if ANGLE is enabled.

Previously the ANGLE developer option toggle UI was disabled by default
and a user would need to use adb command to set the debug property to
true to enable it, and every reboot would reset the debug property to
false again and hence disable the toggle UI again. However, since ANGLE
is still in experiment, we would like to make sure it's not easy to
enable but easy to disable. This patch keeps ANGLE toggle UI enabled
when ANGLE is enabled so that users can easily disable. Once ANGLE is
disabled, if the debug property is not set to true, the toggle UI will
remain disabled.

Bug: b/293503000
Test: atest -c GraphicsDriverEnableAngleAsSystemDriverControllerJUnitTest
Test: atest SettingsRoboTests:GraphicsDriverEnableAngleAsSystemDriverControllerTest
Change-Id: I2e63431cd0d8cf4712fc278646627fbf34a2b542
This commit is contained in:
Peiyong Lin
2023-10-12 23:55:50 +00:00
parent d02ebcc3bf
commit 8e6af783ce
2 changed files with 29 additions and 3 deletions

View File

@@ -170,9 +170,10 @@ public class GraphicsDriverEnableAngleAsSystemDriverController
((SwitchPreference) mPreference).setChecked(false);
}
// Regardless of whether ANGLE is enabled, disable the developer option UI
// as long as UI is not enabled via debug property.
if (!isAngleDeveloperOptionEnabled()) {
// 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
// disable the developer option toggle UI so that it can be turned off easily.
if (!isAngleDeveloperOptionEnabled() && !((SwitchPreference) mPreference).isChecked()) {
mPreference.setEnabled(false);
}
}

View File

@@ -24,6 +24,8 @@ import static com.android.settings.development.graphicsdriver.GraphicsDriverEnab
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertFalse;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.eq;
@@ -472,4 +474,27 @@ public class GraphicsDriverEnableAngleAsSystemDriverControllerJUnitTest {
SystemProperties.removeChangeCallback(propertyChangeSignal1.getCountDownJob());
SystemProperties.removeChangeCallback(propertyChangeSignal2.getCountDownJob());
}
@Test
public void updateState_DeveloperOptionPropertyIsFalse() {
// 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()))
.thenReturn(ANGLE_DRIVER_SUFFIX);
mController.updateState(mPreference);
assertTrue(mPreference.isChecked());
assertTrue(mPreference.isEnabled());
// 2. "Enable ANGLE" switch is off, the switch should be disabled.
when(mSystemPropertiesMock.get(eq(PROPERTY_PERSISTENT_GRAPHICS_EGL), any()))
.thenReturn("");
mController.updateState(mPreference);
assertFalse(mPreference.isChecked());
assertFalse(mPreference.isEnabled());
}
}