Add debug property to safe guard ANGLE developer option UI.

Add a debug property to guard ANGLE developer option UI, only when the
debug property is enabled will ANGLE developer option UI be enabled.

Add further clarification in the text to indicate that this is an
experimental feature.

Bug: b/287909344
Test: atest -c GraphicsDriverEnableAngleAsSystemDriverControllerJUnitTest
Test: atest -c GraphicsDriverEnableAngleAsSystemDriverControllerTest
Change-Id: Ife31f4b0426f3ce107f86cfbaf3f1aeca567e250
This commit is contained in:
Peiyong Lin
2023-09-22 23:27:51 +00:00
parent 7c1b1fc934
commit 774378530f
5 changed files with 43 additions and 2 deletions

View File

@@ -57,6 +57,10 @@ public class GraphicsDriverEnableAngleAsSystemDriverController
@VisibleForTesting
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
@@ -72,6 +76,11 @@ public class GraphicsDriverEnableAngleAsSystemDriverController
public void set(String key, String 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());
}
// 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() {
return TextUtils.equals(
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
// and persist its' state over reboot.
mShouldToggleSwitchBackOnRebootDialogDismiss = true;
final String persistGraphicsEglValue =
mSystemProperties.get(PROPERTY_PERSISTENT_GRAPHICS_EGL, "");
Log.v(TAG, "Value of " + PROPERTY_PERSISTENT_GRAPHICS_EGL + " is: "
+ persistGraphicsEglValue);
}
@Override
@@ -149,6 +169,12 @@ public class GraphicsDriverEnableAngleAsSystemDriverController
mPreference.setEnabled(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

View File

@@ -41,4 +41,13 @@ interface GraphicsDriverSystemPropertiesWrapper {
* SELinux. libc will log the underlying reason.
*/
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);
}