Fix "Enable ANGLE" switch behavior when Developer Option Switch is off
Fix below bugs: 1) When developer option switch is turned off, "Enable ANGLE" switch is not disabled. Fixed it in GraphicsDriverEnableAngleAsSystemDriverController::update(). 2) When user turns off developer option switch, a restart is not always mandatory. However, we should ask user to restart the device is "Enable ANGLE" is forced to change due to developer option switch turning off. Fixed it in DevelopmentSettingsDashboardFragment::onSwitchChanged(). 3) When user turns off developer option switch and the reboot dialog pops up, user can dismiss the dialog by not clicking either POSITIVE_BUTTON or NEGATIVE_BUTTON. We should enforce user to click the button and disallow the option to dimiss the dialog by touching screen areas outside the window's bounds. Fixed it in DisableDevSettingsDialogFragment.java. Did a few clean-up and in GraphicsDriverEnableAngleAsSystemDriverController.java, and updated unit test to reflect new code behavior. Bug: b/270994705 Test: m; flash and device can boot. Test: atest -c GraphicsDriverEnableAngleAsSystemDriverControllerJUnitTest Test: atest GraphicsDriverEnableAngleAsSystemDriverControllerTest Test: atest SettingsRoboTests:FreeformWindowsPreferenceControllerTest Test: atest SettingsRoboTests:DesktopModePreferenceControllerTest Change-Id: I199b2fe59b6ad948b753793254c822a293d8b40d
This commit is contained in:
@@ -354,13 +354,18 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra
|
|||||||
final NfcVerboseVendorLogPreferenceController nfcVerboseLogController =
|
final NfcVerboseVendorLogPreferenceController nfcVerboseLogController =
|
||||||
getDevelopmentOptionsController(
|
getDevelopmentOptionsController(
|
||||||
NfcVerboseVendorLogPreferenceController.class);
|
NfcVerboseVendorLogPreferenceController.class);
|
||||||
|
final GraphicsDriverEnableAngleAsSystemDriverController enableAngleController =
|
||||||
|
getDevelopmentOptionsController(
|
||||||
|
GraphicsDriverEnableAngleAsSystemDriverController.class);
|
||||||
// If hardware offload isn't default value, we must reboot after disable
|
// If hardware offload isn't default value, we must reboot after disable
|
||||||
// developer options. Show a dialog for the user to confirm.
|
// developer options. Show a dialog for the user to confirm.
|
||||||
if ((a2dpController == null || a2dpController.isDefaultValue())
|
if ((a2dpController == null || a2dpController.isDefaultValue())
|
||||||
&& (leAudioController == null || leAudioController.isDefaultValue())
|
&& (leAudioController == null || leAudioController.isDefaultValue())
|
||||||
&& (nfcSnoopLogController == null || nfcSnoopLogController.isDefaultValue())
|
&& (nfcSnoopLogController == null || nfcSnoopLogController.isDefaultValue())
|
||||||
&& (nfcVerboseLogController == null
|
&& (nfcVerboseLogController == null
|
||||||
|| nfcVerboseLogController.isDefaultValue())) {
|
|| nfcVerboseLogController.isDefaultValue())
|
||||||
|
&& (enableAngleController == null
|
||||||
|
|| enableAngleController.isDefaultValue())) {
|
||||||
disableDeveloperOptions();
|
disableDeveloperOptions();
|
||||||
} else {
|
} else {
|
||||||
DisableDevSettingsDialogFragment.show(this /* host */);
|
DisableDevSettingsDialogFragment.show(this /* host */);
|
||||||
|
@@ -45,6 +45,10 @@ public class DisableDevSettingsDialogFragment extends InstrumentedDialogFragment
|
|||||||
public static void show(DevelopmentSettingsDashboardFragment host) {
|
public static void show(DevelopmentSettingsDashboardFragment host) {
|
||||||
final DisableDevSettingsDialogFragment dialog = new DisableDevSettingsDialogFragment();
|
final DisableDevSettingsDialogFragment dialog = new DisableDevSettingsDialogFragment();
|
||||||
dialog.setTargetFragment(host, 0 /* requestCode */);
|
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();
|
final FragmentManager manager = host.getActivity().getSupportFragmentManager();
|
||||||
dialog.show(manager, TAG);
|
dialog.show(manager, TAG);
|
||||||
}
|
}
|
||||||
|
@@ -81,6 +81,11 @@ public class GraphicsDriverEnableAngleAsSystemDriverController
|
|||||||
this(context, fragment, new Injector());
|
this(context, fragment, new Injector());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
||||||
@@ -118,38 +123,44 @@ public class GraphicsDriverEnableAngleAsSystemDriverController
|
|||||||
this);
|
this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/** Return the default value of "persist.graphics.egl" */
|
||||||
public void updateState(Preference preference) {
|
public boolean isDefaultValue() {
|
||||||
// set switch on if "persist.graphics.egl" is "angle" and angle is built in /vendor
|
if (!isAngleSupported()) {
|
||||||
// set switch off otherwise.
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
final String currentGlesDriver =
|
final String currentGlesDriver =
|
||||||
mSystemProperties.get(PROPERTY_PERSISTENT_GRAPHICS_EGL, "");
|
mSystemProperties.get(PROPERTY_PERSISTENT_GRAPHICS_EGL, "");
|
||||||
final boolean isAngle = TextUtils.equals(ANGLE_DRIVER_SUFFIX, currentGlesDriver);
|
// default value of "persist.graphics.egl" is ""
|
||||||
final boolean isAngleSupported =
|
return TextUtils.isEmpty(currentGlesDriver);
|
||||||
TextUtils.equals(
|
|
||||||
mSystemProperties.get(PROPERTY_RO_GFX_ANGLE_SUPPORTED, ""), "true");
|
|
||||||
((SwitchPreference) mPreference).setChecked(isAngle && isAngleSupported);
|
|
||||||
((SwitchPreference) mPreference).setEnabled(isAngleSupported);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDeveloperOptionsSwitchEnabled() {
|
public void updateState(Preference preference) {
|
||||||
// only enable the switch if ro.gfx.angle.supported is true
|
super.updateState(preference);
|
||||||
// we use ro.gfx.angle.supported to indicate if ANGLE libs are installed under /vendor
|
if (isAngleSupported()) {
|
||||||
final boolean isAngleSupported =
|
// set switch on if "persist.graphics.egl" is "angle" and angle is built in /vendor
|
||||||
TextUtils.equals(
|
// set switch off otherwise.
|
||||||
mSystemProperties.get(PROPERTY_RO_GFX_ANGLE_SUPPORTED, ""), "true");
|
final String currentGlesDriver =
|
||||||
((SwitchPreference) mPreference).setEnabled(isAngleSupported);
|
mSystemProperties.get(PROPERTY_PERSISTENT_GRAPHICS_EGL, "");
|
||||||
|
final boolean isAngle = TextUtils.equals(ANGLE_DRIVER_SUFFIX, currentGlesDriver);
|
||||||
|
((SwitchPreference) mPreference).setChecked(isAngle);
|
||||||
|
} else {
|
||||||
|
mPreference.setEnabled(false);
|
||||||
|
((SwitchPreference) mPreference).setChecked(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDeveloperOptionsSwitchDisabled() {
|
protected void onDeveloperOptionsSwitchDisabled() {
|
||||||
// 1) set the persist.graphics.egl empty string
|
// 1) disable the switch
|
||||||
GraphicsEnvironment.getInstance().toggleAngleAsSystemDriver(false);
|
super.onDeveloperOptionsSwitchDisabled();
|
||||||
// 2) reset the switch
|
if (isAngleSupported()) {
|
||||||
((SwitchPreference) mPreference).setChecked(false);
|
// 2) set the persist.graphics.egl empty string
|
||||||
// 3) disable switch
|
GraphicsEnvironment.getInstance().toggleAngleAsSystemDriver(false);
|
||||||
((SwitchPreference) mPreference).setEnabled(false);
|
// 3) reset the switch
|
||||||
|
((SwitchPreference) mPreference).setChecked(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void toggleSwitchBack() {
|
void toggleSwitchBack() {
|
||||||
|
@@ -141,6 +141,7 @@ 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("");
|
||||||
@@ -148,12 +149,14 @@ 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);
|
||||||
}
|
}
|
||||||
|
@@ -57,7 +57,7 @@ public class GraphicsDriverEnableAngleAsSystemDriverControllerJUnitTest {
|
|||||||
private GraphicsDriverEnableAngleAsSystemDriverController mController;
|
private GraphicsDriverEnableAngleAsSystemDriverController mController;
|
||||||
|
|
||||||
// Signal to wait for SystemProperty values changed
|
// Signal to wait for SystemProperty values changed
|
||||||
private class PropertyChangeSignal {
|
private static class PropertyChangeSignal {
|
||||||
private CountDownLatch mCountDownLatch;
|
private CountDownLatch mCountDownLatch;
|
||||||
|
|
||||||
private Runnable mCountDownJob;
|
private Runnable mCountDownJob;
|
||||||
@@ -217,23 +217,7 @@ public class GraphicsDriverEnableAngleAsSystemDriverControllerJUnitTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onDeveloperOptionSwitchEnabled_angleSupported_PreferenceShouldEnabled() {
|
public void onDeveloperOptionSwitchDisabled_angleShouldNotBeSystemGLESDriver() {
|
||||||
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() {
|
|
||||||
// Add a callback when SystemProperty changes.
|
// Add a callback when SystemProperty changes.
|
||||||
// This allows the thread to wait until
|
// This allows the thread to wait until
|
||||||
// GpuService::toggleAngleAsSystemDriver() updates the persist.graphics.egl.
|
// GpuService::toggleAngleAsSystemDriver() updates the persist.graphics.egl.
|
||||||
@@ -242,6 +226,8 @@ 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);
|
||||||
@@ -253,12 +239,16 @@ 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();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user