Merge "Add debug property to safe guard ANGLE developer option UI." into udc-qpr-dev am: e456cb72f9 am: 759a3fda7b

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/24842231

Change-Id: Iec2e7a51a9b0179fceef6182a1bd9cd2668ddab0
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Peiyong Lin
2023-09-26 21:34:17 +00:00
committed by Automerger Merge Worker
5 changed files with 43 additions and 2 deletions

View File

@@ -10732,9 +10732,9 @@
</string-array> </string-array>
<!-- Debugging developer settings: enable angle as system driver? [CHAR LIMIT=50] --> <!-- Debugging developer settings: enable angle as system driver? [CHAR LIMIT=50] -->
<string name="enable_angle_as_system_driver">Enable ANGLE</string> <string name="enable_angle_as_system_driver">Experimental: Enable ANGLE</string>
<!-- Debugging developer settings: enable angle as system driver summary [CHAR LIMIT=NONE] --> <!-- Debugging developer settings: enable angle as system driver summary [CHAR LIMIT=NONE] -->
<string name="enable_angle_as_system_driver_summary">Enable ANGLE as default OpenGL ES driver. Enabling it on incompatible devices may break some applications.</string> <string name="enable_angle_as_system_driver_summary">Warning: Enable ANGLE as default OpenGL ES driver. This feature is in experiment and may not be compatible with some camera and video apps.</string>
<!--Dialog body text used to explain a reboot is required after changing ANGLE as system GLES driver setting--> <!--Dialog body text used to explain a reboot is required after changing ANGLE as system GLES driver setting-->
<string name="reboot_dialog_enable_angle_as_system_driver">A reboot is required to change the system OpenGL ES driver</string> <string name="reboot_dialog_enable_angle_as_system_driver">A reboot is required to change the system OpenGL ES driver</string>

View File

@@ -57,6 +57,10 @@ public class GraphicsDriverEnableAngleAsSystemDriverController
@VisibleForTesting @VisibleForTesting
static final String PROPERTY_PERSISTENT_GRAPHICS_EGL = "persist.graphics.egl"; static final String PROPERTY_PERSISTENT_GRAPHICS_EGL = "persist.graphics.egl";
@VisibleForTesting
static final String PROPERTY_DEBUG_ANGLE_DEVELOPER_OPTION =
"debug.graphics.angle.developeroption.enable";
@VisibleForTesting static final String ANGLE_DRIVER_SUFFIX = "angle"; @VisibleForTesting static final String ANGLE_DRIVER_SUFFIX = "angle";
@VisibleForTesting @VisibleForTesting
@@ -72,6 +76,11 @@ public class GraphicsDriverEnableAngleAsSystemDriverController
public void set(String key, String val) { public void set(String key, String val) {
SystemProperties.set(key, val); SystemProperties.set(key, val);
} }
@Override
public boolean getBoolean(String key, boolean def) {
return SystemProperties.getBoolean(key, def);
}
}; };
} }
} }
@@ -81,6 +90,13 @@ public class GraphicsDriverEnableAngleAsSystemDriverController
this(context, fragment, new Injector()); this(context, fragment, new Injector());
} }
// Return true if the ANGLE developer option entry point is enabled.
// This can be enabled by calling:
// `adb shell setprop debug.graphics.angle.developeroption.enable true`
private boolean isAngleDeveloperOptionEnabled() {
return mSystemProperties.getBoolean(PROPERTY_DEBUG_ANGLE_DEVELOPER_OPTION, false);
}
private boolean isAngleSupported() { private boolean isAngleSupported() {
return TextUtils.equals( return TextUtils.equals(
mSystemProperties.get(PROPERTY_RO_GFX_ANGLE_SUPPORTED, ""), "true"); mSystemProperties.get(PROPERTY_RO_GFX_ANGLE_SUPPORTED, ""), "true");
@@ -96,6 +112,10 @@ public class GraphicsDriverEnableAngleAsSystemDriverController
// Exception is when user chooses to reboot now, the switch should keep its current value // Exception is when user chooses to reboot now, the switch should keep its current value
// and persist its' state over reboot. // and persist its' state over reboot.
mShouldToggleSwitchBackOnRebootDialogDismiss = true; mShouldToggleSwitchBackOnRebootDialogDismiss = true;
final String persistGraphicsEglValue =
mSystemProperties.get(PROPERTY_PERSISTENT_GRAPHICS_EGL, "");
Log.v(TAG, "Value of " + PROPERTY_PERSISTENT_GRAPHICS_EGL + " is: "
+ persistGraphicsEglValue);
} }
@Override @Override
@@ -149,6 +169,12 @@ public class GraphicsDriverEnableAngleAsSystemDriverController
mPreference.setEnabled(false); mPreference.setEnabled(false);
((SwitchPreference) mPreference).setChecked(false); ((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()) {
mPreference.setEnabled(false);
}
} }
@Override @Override

View File

@@ -41,4 +41,13 @@ interface GraphicsDriverSystemPropertiesWrapper {
* SELinux. libc will log the underlying reason. * SELinux. libc will log the underlying reason.
*/ */
void set(@NonNull String key, @Nullable String val); void set(@NonNull String key, @Nullable String val);
/**
* Get the boolean value for the given {@code key}.
*
* @param key the key to lookup
* @param def the default value in case the property is not set or empty
* @return if the {@code key} isn't found, return {@code def}.
*/
boolean getBoolean(@NonNull String key, @NonNull boolean def);
} }

View File

@@ -17,6 +17,7 @@
package com.android.settings.development.graphicsdriver; package com.android.settings.development.graphicsdriver;
import static com.android.settings.development.graphicsdriver.GraphicsDriverEnableAngleAsSystemDriverController.ANGLE_DRIVER_SUFFIX; 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_PERSISTENT_GRAPHICS_EGL;
import static com.android.settings.development.graphicsdriver.GraphicsDriverEnableAngleAsSystemDriverController.PROPERTY_RO_GFX_ANGLE_SUPPORTED; import static com.android.settings.development.graphicsdriver.GraphicsDriverEnableAngleAsSystemDriverController.PROPERTY_RO_GFX_ANGLE_SUPPORTED;
@@ -71,6 +72,7 @@ public class GraphicsDriverEnableAngleAsSystemDriverControllerTest {
public void setUp() { public void setUp() {
MockitoAnnotations.initMocks(this); MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application; mContext = RuntimeEnvironment.application;
ShadowSystemProperties.override(PROPERTY_DEBUG_ANGLE_DEVELOPER_OPTION, "true");
doReturn(mTransaction).when(mFragmentManager).beginTransaction(); doReturn(mTransaction).when(mFragmentManager).beginTransaction();
doReturn(mFragmentManager).when(mActivity).getSupportFragmentManager(); doReturn(mFragmentManager).when(mActivity).getSupportFragmentManager();
doReturn(mActivity).when(mFragment).getActivity(); doReturn(mActivity).when(mFragment).getActivity();

View File

@@ -18,12 +18,14 @@ package com.android.settings.development.graphicsdriver;
import static com.android.settings.development.graphicsdriver.GraphicsDriverEnableAngleAsSystemDriverController.ANGLE_DRIVER_SUFFIX; import static com.android.settings.development.graphicsdriver.GraphicsDriverEnableAngleAsSystemDriverController.ANGLE_DRIVER_SUFFIX;
import static com.android.settings.development.graphicsdriver.GraphicsDriverEnableAngleAsSystemDriverController.Injector; 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_PERSISTENT_GRAPHICS_EGL;
import static com.android.settings.development.graphicsdriver.GraphicsDriverEnableAngleAsSystemDriverController.PROPERTY_RO_GFX_ANGLE_SUPPORTED; import static com.android.settings.development.graphicsdriver.GraphicsDriverEnableAngleAsSystemDriverController.PROPERTY_RO_GFX_ANGLE_SUPPORTED;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
@@ -98,6 +100,8 @@ public class GraphicsDriverEnableAngleAsSystemDriverControllerJUnitTest {
} }
mContext = ApplicationProvider.getApplicationContext(); mContext = ApplicationProvider.getApplicationContext();
when(mSystemPropertiesMock.getBoolean(eq(PROPERTY_DEBUG_ANGLE_DEVELOPER_OPTION),
anyBoolean())).thenReturn(true);
// Construct a GraphicsDriverEnableAngleAsSystemDriverController with two Overrides: // Construct a GraphicsDriverEnableAngleAsSystemDriverController with two Overrides:
// 1) Override the mSystemProperties with mSystemPropertiesMock, // 1) Override the mSystemProperties with mSystemPropertiesMock,