Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c711d1c3 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge changes from topic "angle-developer-option-toggle1" into main am: 0481d6a3

parents a62d0146 0481d6a3
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -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);
        }
    }
+25 −0
Original line number Diff line number Diff line
@@ -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());
    }
}