Loading src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java +6 −1 Original line number Diff line number Diff line Loading @@ -354,13 +354,18 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra final NfcVerboseVendorLogPreferenceController nfcVerboseLogController = getDevelopmentOptionsController( NfcVerboseVendorLogPreferenceController.class); final GraphicsDriverEnableAngleAsSystemDriverController enableAngleController = getDevelopmentOptionsController( GraphicsDriverEnableAngleAsSystemDriverController.class); // If hardware offload isn't default value, we must reboot after disable // developer options. Show a dialog for the user to confirm. if ((a2dpController == null || a2dpController.isDefaultValue()) && (leAudioController == null || leAudioController.isDefaultValue()) && (nfcSnoopLogController == null || nfcSnoopLogController.isDefaultValue()) && (nfcVerboseLogController == null || nfcVerboseLogController.isDefaultValue())) { || nfcVerboseLogController.isDefaultValue()) && (enableAngleController == null || enableAngleController.isDefaultValue())) { disableDeveloperOptions(); } else { DisableDevSettingsDialogFragment.show(this /* host */); Loading src/com/android/settings/development/DisableDevSettingsDialogFragment.java +4 −0 Original line number Diff line number Diff line Loading @@ -45,6 +45,10 @@ public class DisableDevSettingsDialogFragment extends InstrumentedDialogFragment public static void show(DevelopmentSettingsDashboardFragment host) { final DisableDevSettingsDialogFragment dialog = new DisableDevSettingsDialogFragment(); dialog.setTargetFragment(host, 0 /* requestCode */); // We need to handle data changes and switch state based on which button user clicks, // therefore we should enforce user to click one of the buttons // by disallowing dialog dismiss through tapping outside of dialog bounds. dialog.setCancelable(false); final FragmentManager manager = host.getActivity().getSupportFragmentManager(); dialog.show(manager, TAG); } Loading src/com/android/settings/development/graphicsdriver/GraphicsDriverEnableAngleAsSystemDriverController.java +34 −23 Original line number Diff line number Diff line Loading @@ -81,6 +81,11 @@ public class GraphicsDriverEnableAngleAsSystemDriverController this(context, fragment, new Injector()); } private boolean isAngleSupported() { return TextUtils.equals( mSystemProperties.get(PROPERTY_RO_GFX_ANGLE_SUPPORTED, ""), "true"); } @VisibleForTesting GraphicsDriverEnableAngleAsSystemDriverController( Context context, DevelopmentSettingsDashboardFragment fragment, Injector injector) { Loading Loading @@ -118,38 +123,44 @@ public class GraphicsDriverEnableAngleAsSystemDriverController this); } /** 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 "" return TextUtils.isEmpty(currentGlesDriver); } @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); final boolean isAngleSupported = TextUtils.equals( mSystemProperties.get(PROPERTY_RO_GFX_ANGLE_SUPPORTED, ""), "true"); ((SwitchPreference) mPreference).setChecked(isAngle && isAngleSupported); ((SwitchPreference) mPreference).setEnabled(isAngleSupported); ((SwitchPreference) mPreference).setChecked(isAngle); } else { mPreference.setEnabled(false); ((SwitchPreference) mPreference).setChecked(false); } @Override protected void onDeveloperOptionsSwitchEnabled() { // only enable the switch if ro.gfx.angle.supported is true // we use ro.gfx.angle.supported to indicate if ANGLE libs are installed under /vendor final boolean isAngleSupported = TextUtils.equals( mSystemProperties.get(PROPERTY_RO_GFX_ANGLE_SUPPORTED, ""), "true"); ((SwitchPreference) mPreference).setEnabled(isAngleSupported); } @Override protected void onDeveloperOptionsSwitchDisabled() { // 1) set the persist.graphics.egl empty string // 1) disable the switch super.onDeveloperOptionsSwitchDisabled(); if (isAngleSupported()) { // 2) set the persist.graphics.egl empty string GraphicsEnvironment.getInstance().toggleAngleAsSystemDriver(false); // 2) reset the switch // 3) reset the switch ((SwitchPreference) mPreference).setChecked(false); // 3) disable switch ((SwitchPreference) mPreference).setEnabled(false); } } void toggleSwitchBack() { Loading tests/robotests/src/com/android/settings/development/graphicsdriver/GraphicsDriverEnableAngleAsSystemDriverControllerTest.java +3 −0 Original line number Diff line number Diff line Loading @@ -141,6 +141,7 @@ 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(""); Loading @@ -148,12 +149,14 @@ 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); } Loading tests/unit/src/com/android/settings/development/graphicsdriver/GraphicsDriverEnableAngleAsSystemDriverControllerJUnitTest.java +8 −18 Original line number Diff line number Diff line Loading @@ -57,7 +57,7 @@ public class GraphicsDriverEnableAngleAsSystemDriverControllerJUnitTest { private GraphicsDriverEnableAngleAsSystemDriverController mController; // Signal to wait for SystemProperty values changed private class PropertyChangeSignal { private static class PropertyChangeSignal { private CountDownLatch mCountDownLatch; private Runnable mCountDownJob; Loading Loading @@ -217,23 +217,7 @@ public class GraphicsDriverEnableAngleAsSystemDriverControllerJUnitTest { } @Test public void onDeveloperOptionSwitchEnabled_angleSupported_PreferenceShouldEnabled() { when(mSystemPropertiesMock.get(eq(PROPERTY_RO_GFX_ANGLE_SUPPORTED), any())) .thenReturn("true"); mController.onDeveloperOptionsSwitchEnabled(); assertThat(mPreference.isEnabled()).isTrue(); } @Test public void onDeveloperOptionSwitchEnabled_angleNotSupported_PrefenceShouldDisabled() { when(mSystemPropertiesMock.get(eq(PROPERTY_RO_GFX_ANGLE_SUPPORTED), any())) .thenReturn("false"); mController.onDeveloperOptionsSwitchEnabled(); assertThat(mPreference.isEnabled()).isFalse(); } @Test public void onDeveloperOptionSwitchDisabled_angleIsNotSystemGLESDriver() { public void onDeveloperOptionSwitchDisabled_angleShouldNotBeSystemGLESDriver() { // Add a callback when SystemProperty changes. // This allows the thread to wait until // GpuService::toggleAngleAsSystemDriver() updates the persist.graphics.egl. Loading @@ -242,6 +226,8 @@ 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); Loading @@ -253,12 +239,16 @@ 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(); } Loading Loading
src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java +6 −1 Original line number Diff line number Diff line Loading @@ -354,13 +354,18 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra final NfcVerboseVendorLogPreferenceController nfcVerboseLogController = getDevelopmentOptionsController( NfcVerboseVendorLogPreferenceController.class); final GraphicsDriverEnableAngleAsSystemDriverController enableAngleController = getDevelopmentOptionsController( GraphicsDriverEnableAngleAsSystemDriverController.class); // If hardware offload isn't default value, we must reboot after disable // developer options. Show a dialog for the user to confirm. if ((a2dpController == null || a2dpController.isDefaultValue()) && (leAudioController == null || leAudioController.isDefaultValue()) && (nfcSnoopLogController == null || nfcSnoopLogController.isDefaultValue()) && (nfcVerboseLogController == null || nfcVerboseLogController.isDefaultValue())) { || nfcVerboseLogController.isDefaultValue()) && (enableAngleController == null || enableAngleController.isDefaultValue())) { disableDeveloperOptions(); } else { DisableDevSettingsDialogFragment.show(this /* host */); Loading
src/com/android/settings/development/DisableDevSettingsDialogFragment.java +4 −0 Original line number Diff line number Diff line Loading @@ -45,6 +45,10 @@ public class DisableDevSettingsDialogFragment extends InstrumentedDialogFragment public static void show(DevelopmentSettingsDashboardFragment host) { final DisableDevSettingsDialogFragment dialog = new DisableDevSettingsDialogFragment(); dialog.setTargetFragment(host, 0 /* requestCode */); // We need to handle data changes and switch state based on which button user clicks, // therefore we should enforce user to click one of the buttons // by disallowing dialog dismiss through tapping outside of dialog bounds. dialog.setCancelable(false); final FragmentManager manager = host.getActivity().getSupportFragmentManager(); dialog.show(manager, TAG); } Loading
src/com/android/settings/development/graphicsdriver/GraphicsDriverEnableAngleAsSystemDriverController.java +34 −23 Original line number Diff line number Diff line Loading @@ -81,6 +81,11 @@ public class GraphicsDriverEnableAngleAsSystemDriverController this(context, fragment, new Injector()); } private boolean isAngleSupported() { return TextUtils.equals( mSystemProperties.get(PROPERTY_RO_GFX_ANGLE_SUPPORTED, ""), "true"); } @VisibleForTesting GraphicsDriverEnableAngleAsSystemDriverController( Context context, DevelopmentSettingsDashboardFragment fragment, Injector injector) { Loading Loading @@ -118,38 +123,44 @@ public class GraphicsDriverEnableAngleAsSystemDriverController this); } /** 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 "" return TextUtils.isEmpty(currentGlesDriver); } @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); final boolean isAngleSupported = TextUtils.equals( mSystemProperties.get(PROPERTY_RO_GFX_ANGLE_SUPPORTED, ""), "true"); ((SwitchPreference) mPreference).setChecked(isAngle && isAngleSupported); ((SwitchPreference) mPreference).setEnabled(isAngleSupported); ((SwitchPreference) mPreference).setChecked(isAngle); } else { mPreference.setEnabled(false); ((SwitchPreference) mPreference).setChecked(false); } @Override protected void onDeveloperOptionsSwitchEnabled() { // only enable the switch if ro.gfx.angle.supported is true // we use ro.gfx.angle.supported to indicate if ANGLE libs are installed under /vendor final boolean isAngleSupported = TextUtils.equals( mSystemProperties.get(PROPERTY_RO_GFX_ANGLE_SUPPORTED, ""), "true"); ((SwitchPreference) mPreference).setEnabled(isAngleSupported); } @Override protected void onDeveloperOptionsSwitchDisabled() { // 1) set the persist.graphics.egl empty string // 1) disable the switch super.onDeveloperOptionsSwitchDisabled(); if (isAngleSupported()) { // 2) set the persist.graphics.egl empty string GraphicsEnvironment.getInstance().toggleAngleAsSystemDriver(false); // 2) reset the switch // 3) reset the switch ((SwitchPreference) mPreference).setChecked(false); // 3) disable switch ((SwitchPreference) mPreference).setEnabled(false); } } void toggleSwitchBack() { Loading
tests/robotests/src/com/android/settings/development/graphicsdriver/GraphicsDriverEnableAngleAsSystemDriverControllerTest.java +3 −0 Original line number Diff line number Diff line Loading @@ -141,6 +141,7 @@ 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(""); Loading @@ -148,12 +149,14 @@ 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); } Loading
tests/unit/src/com/android/settings/development/graphicsdriver/GraphicsDriverEnableAngleAsSystemDriverControllerJUnitTest.java +8 −18 Original line number Diff line number Diff line Loading @@ -57,7 +57,7 @@ public class GraphicsDriverEnableAngleAsSystemDriverControllerJUnitTest { private GraphicsDriverEnableAngleAsSystemDriverController mController; // Signal to wait for SystemProperty values changed private class PropertyChangeSignal { private static class PropertyChangeSignal { private CountDownLatch mCountDownLatch; private Runnable mCountDownJob; Loading Loading @@ -217,23 +217,7 @@ public class GraphicsDriverEnableAngleAsSystemDriverControllerJUnitTest { } @Test public void onDeveloperOptionSwitchEnabled_angleSupported_PreferenceShouldEnabled() { when(mSystemPropertiesMock.get(eq(PROPERTY_RO_GFX_ANGLE_SUPPORTED), any())) .thenReturn("true"); mController.onDeveloperOptionsSwitchEnabled(); assertThat(mPreference.isEnabled()).isTrue(); } @Test public void onDeveloperOptionSwitchEnabled_angleNotSupported_PrefenceShouldDisabled() { when(mSystemPropertiesMock.get(eq(PROPERTY_RO_GFX_ANGLE_SUPPORTED), any())) .thenReturn("false"); mController.onDeveloperOptionsSwitchEnabled(); assertThat(mPreference.isEnabled()).isFalse(); } @Test public void onDeveloperOptionSwitchDisabled_angleIsNotSystemGLESDriver() { public void onDeveloperOptionSwitchDisabled_angleShouldNotBeSystemGLESDriver() { // Add a callback when SystemProperty changes. // This allows the thread to wait until // GpuService::toggleAngleAsSystemDriver() updates the persist.graphics.egl. Loading @@ -242,6 +226,8 @@ 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); Loading @@ -253,12 +239,16 @@ 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(); } Loading