Skip to content

Commit e10e0ff

Browse files
TreeHugger RobotAndroid (Google) Code Review
authored andcommitted
Merge "GraphicsEnv: refactor to unify the debuggable logic" into qt-qpr1-dev
2 parents f2a1775 + a3acf85 commit e10e0ff

2 files changed

Lines changed: 9 additions & 22 deletions

File tree

core/java/android/os/GraphicsEnvironment.java

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -172,13 +172,6 @@ private static int getVulkanVersion(PackageManager pm) {
172172
return 0;
173173
}
174174

175-
/**
176-
* Check whether application is debuggable
177-
*/
178-
private static boolean isDebuggable(Context context) {
179-
return (context.getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) > 0;
180-
}
181-
182175
/**
183176
* Store the layer paths available to the loader.
184177
*/
@@ -233,7 +226,7 @@ private void setupGpuLayers(
233226
// 2. ENABLE_GPU_DEBUG_LAYERS is true
234227
// 3. Package name is equal to GPU_DEBUG_APP
235228

236-
if (isDebuggable(context) || (getCanLoadSystemLibraries() == 1)) {
229+
if (isDebuggable()) {
237230

238231
final int enable = coreSettings.getInt(Settings.Global.ENABLE_GPU_DEBUG_LAYERS, 0);
239232

@@ -414,9 +407,7 @@ private String getAnglePackageName(PackageManager pm) {
414407
* Check for ANGLE debug package, but only for apps that can load them (dumpable)
415408
*/
416409
private String getAngleDebugPackage(Context context, Bundle coreSettings) {
417-
final boolean appIsDebuggable = isDebuggable(context);
418-
final boolean deviceIsDebuggable = getCanLoadSystemLibraries() == 1;
419-
if (appIsDebuggable || deviceIsDebuggable) {
410+
if (isDebuggable()) {
420411
String debugPackage;
421412

422413
if (coreSettings != null) {
@@ -451,12 +442,8 @@ private static boolean setupAngleWithTempRulesFile(Context context,
451442
* - devices that are running a userdebug build (ro.debuggable) or can inject libraries for
452443
* debugging (PR_SET_DUMPABLE).
453444
*/
454-
final boolean appIsDebuggable = isDebuggable(context);
455-
final boolean deviceIsDebuggable = getCanLoadSystemLibraries() == 1;
456-
if (!(appIsDebuggable || deviceIsDebuggable)) {
457-
Log.v(TAG, "Skipping loading temporary rules file: "
458-
+ "appIsDebuggable = " + appIsDebuggable + ", "
459-
+ "adbRootEnabled = " + deviceIsDebuggable);
445+
if (!isDebuggable()) {
446+
Log.v(TAG, "Skipping loading temporary rules file");
460447
return false;
461448
}
462449

@@ -725,7 +712,7 @@ private static String chooseDriverInternal(
725712

726713
final boolean enablePrereleaseDriver =
727714
(ai.metaData != null && ai.metaData.getBoolean(METADATA_DEVELOPER_DRIVER_ENABLE))
728-
|| getCanLoadSystemLibraries() == 1;
715+
|| isDebuggable();
729716

730717
// Priority for Game Driver settings global on confliction (Higher priority comes first):
731718
// 1. GAME_DRIVER_ALL_APPS
@@ -901,7 +888,7 @@ private static String getSphalLibraries(Context context, String driverPackageNam
901888
return "";
902889
}
903890

904-
private static native int getCanLoadSystemLibraries();
891+
private static native boolean isDebuggable();
905892
private static native void setLayerPaths(ClassLoader classLoader, String layerPaths);
906893
private static native void setDebugLayers(String layers);
907894
private static native void setDebugLayersGLES(String layers);

core/jni/android_os_GraphicsEnvironment.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323

2424
namespace {
2525

26-
int getCanLoadSystemLibraries_native() {
27-
return android::GraphicsEnv::getInstance().getCanLoadSystemLibraries();
26+
bool isDebuggable_native() {
27+
return android::GraphicsEnv::getInstance().isDebuggable();
2828
}
2929

3030
void setDriverPathAndSphalLibraries_native(JNIEnv* env, jobject clazz, jstring path,
@@ -90,7 +90,7 @@ void hintActivityLaunch_native(JNIEnv* env, jobject clazz) {
9090
}
9191

9292
const JNINativeMethod g_methods[] = {
93-
{ "getCanLoadSystemLibraries", "()I", reinterpret_cast<void*>(getCanLoadSystemLibraries_native) },
93+
{ "isDebuggable", "()Z", reinterpret_cast<void*>(isDebuggable_native) },
9494
{ "setDriverPathAndSphalLibraries", "(Ljava/lang/String;Ljava/lang/String;)V", reinterpret_cast<void*>(setDriverPathAndSphalLibraries_native) },
9595
{ "setGpuStats", "(Ljava/lang/String;Ljava/lang/String;JJLjava/lang/String;I)V", reinterpret_cast<void*>(setGpuStats_native) },
9696
{ "setAngleInfo", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/io/FileDescriptor;JJ)V", reinterpret_cast<void*>(setAngleInfo_native) },

0 commit comments

Comments
 (0)