Merge "Unconditionally enable ANGLE developer option UI." into main
diff --git a/src/com/android/settings/development/graphicsdriver/GraphicsDriverEnableAngleAsSystemDriverController.java b/src/com/android/settings/development/graphicsdriver/GraphicsDriverEnableAngleAsSystemDriverController.java
index 482858f..e75ab1a 100644
--- a/src/com/android/settings/development/graphicsdriver/GraphicsDriverEnableAngleAsSystemDriverController.java
+++ b/src/com/android/settings/development/graphicsdriver/GraphicsDriverEnableAngleAsSystemDriverController.java
@@ -52,9 +52,6 @@
     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 @@
         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 @@
 
     /** 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 @@
     @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 @@
     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 686df7a..e623eb8 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 @@
 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 @@
 
     @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 @@
 
     @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 @@
     }
 
     @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 @@
 
     @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 @@
 
     @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 a402d91..8304e5d 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.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 @@
     }
 
     @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 @@
     }
 
     @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 @@
 
         // 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 @@
 
     @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 @@
         // 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()))