Merge "GraphicsEnv: refactor to unify the debuggable logic" into qt-qpr1-dev

This commit is contained in:
TreeHugger Robot
2020-01-31 18:09:16 +00:00
committed by Android (Google) Code Review
2 changed files with 9 additions and 22 deletions

View File

@@ -172,13 +172,6 @@ public class GraphicsEnvironment {
return 0; return 0;
} }
/**
* Check whether application is debuggable
*/
private static boolean isDebuggable(Context context) {
return (context.getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) > 0;
}
/** /**
* Store the layer paths available to the loader. * Store the layer paths available to the loader.
*/ */
@@ -233,7 +226,7 @@ public class GraphicsEnvironment {
// 2. ENABLE_GPU_DEBUG_LAYERS is true // 2. ENABLE_GPU_DEBUG_LAYERS is true
// 3. Package name is equal to GPU_DEBUG_APP // 3. Package name is equal to GPU_DEBUG_APP
if (isDebuggable(context) || (getCanLoadSystemLibraries() == 1)) { if (isDebuggable()) {
final int enable = coreSettings.getInt(Settings.Global.ENABLE_GPU_DEBUG_LAYERS, 0); final int enable = coreSettings.getInt(Settings.Global.ENABLE_GPU_DEBUG_LAYERS, 0);
@@ -414,9 +407,7 @@ public class GraphicsEnvironment {
* Check for ANGLE debug package, but only for apps that can load them (dumpable) * Check for ANGLE debug package, but only for apps that can load them (dumpable)
*/ */
private String getAngleDebugPackage(Context context, Bundle coreSettings) { private String getAngleDebugPackage(Context context, Bundle coreSettings) {
final boolean appIsDebuggable = isDebuggable(context); if (isDebuggable()) {
final boolean deviceIsDebuggable = getCanLoadSystemLibraries() == 1;
if (appIsDebuggable || deviceIsDebuggable) {
String debugPackage; String debugPackage;
if (coreSettings != null) { if (coreSettings != null) {
@@ -451,12 +442,8 @@ public class GraphicsEnvironment {
* - devices that are running a userdebug build (ro.debuggable) or can inject libraries for * - devices that are running a userdebug build (ro.debuggable) or can inject libraries for
* debugging (PR_SET_DUMPABLE). * debugging (PR_SET_DUMPABLE).
*/ */
final boolean appIsDebuggable = isDebuggable(context); if (!isDebuggable()) {
final boolean deviceIsDebuggable = getCanLoadSystemLibraries() == 1; Log.v(TAG, "Skipping loading temporary rules file");
if (!(appIsDebuggable || deviceIsDebuggable)) {
Log.v(TAG, "Skipping loading temporary rules file: "
+ "appIsDebuggable = " + appIsDebuggable + ", "
+ "adbRootEnabled = " + deviceIsDebuggable);
return false; return false;
} }
@@ -725,7 +712,7 @@ public class GraphicsEnvironment {
final boolean enablePrereleaseDriver = final boolean enablePrereleaseDriver =
(ai.metaData != null && ai.metaData.getBoolean(METADATA_DEVELOPER_DRIVER_ENABLE)) (ai.metaData != null && ai.metaData.getBoolean(METADATA_DEVELOPER_DRIVER_ENABLE))
|| getCanLoadSystemLibraries() == 1; || isDebuggable();
// Priority for Game Driver settings global on confliction (Higher priority comes first): // Priority for Game Driver settings global on confliction (Higher priority comes first):
// 1. GAME_DRIVER_ALL_APPS // 1. GAME_DRIVER_ALL_APPS
@@ -901,7 +888,7 @@ public class GraphicsEnvironment {
return ""; return "";
} }
private static native int getCanLoadSystemLibraries(); private static native boolean isDebuggable();
private static native void setLayerPaths(ClassLoader classLoader, String layerPaths); private static native void setLayerPaths(ClassLoader classLoader, String layerPaths);
private static native void setDebugLayers(String layers); private static native void setDebugLayers(String layers);
private static native void setDebugLayersGLES(String layers); private static native void setDebugLayersGLES(String layers);

View File

@@ -23,8 +23,8 @@
namespace { namespace {
int getCanLoadSystemLibraries_native() { bool isDebuggable_native() {
return android::GraphicsEnv::getInstance().getCanLoadSystemLibraries(); return android::GraphicsEnv::getInstance().isDebuggable();
} }
void setDriverPathAndSphalLibraries_native(JNIEnv* env, jobject clazz, jstring path, void setDriverPathAndSphalLibraries_native(JNIEnv* env, jobject clazz, jstring path,
@@ -90,7 +90,7 @@ void hintActivityLaunch_native(JNIEnv* env, jobject clazz) {
} }
const JNINativeMethod g_methods[] = { const JNINativeMethod g_methods[] = {
{ "getCanLoadSystemLibraries", "()I", reinterpret_cast<void*>(getCanLoadSystemLibraries_native) }, { "isDebuggable", "()Z", reinterpret_cast<void*>(isDebuggable_native) },
{ "setDriverPathAndSphalLibraries", "(Ljava/lang/String;Ljava/lang/String;)V", reinterpret_cast<void*>(setDriverPathAndSphalLibraries_native) }, { "setDriverPathAndSphalLibraries", "(Ljava/lang/String;Ljava/lang/String;)V", reinterpret_cast<void*>(setDriverPathAndSphalLibraries_native) },
{ "setGpuStats", "(Ljava/lang/String;Ljava/lang/String;JJLjava/lang/String;I)V", reinterpret_cast<void*>(setGpuStats_native) }, { "setGpuStats", "(Ljava/lang/String;Ljava/lang/String;JJLjava/lang/String;I)V", reinterpret_cast<void*>(setGpuStats_native) },
{ "setAngleInfo", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/io/FileDescriptor;JJ)V", reinterpret_cast<void*>(setAngleInfo_native) }, { "setAngleInfo", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/io/FileDescriptor;JJ)V", reinterpret_cast<void*>(setAngleInfo_native) },