GraphicsEnv: refactor to unify the debuggable logic
By default, PR_SET_DUMPABLE is 0 for zygote spawned apps, except in the
following circumstances:
1. ro.debuggable=1 (global debuggable enabled, i.e., userdebug or eng builds).
2. android:debuggable="true" in the manifest for an individual application.
3. An app which explicitly calls prctl(PR_SET_DUMPABLE, 1).
4. GraphicsEnv calls prctl(PR_SET_DUMPABLE, 1) in the presence of
<meta-data android:name="com.android.graphics.injectLayers.enable"
android:value="true"/>
in the application manifest.
So checking both ro.debuggable=1 and PR_GET_DUMPABLE is redundant.
Bug: b/144186877, b/148566223
Test: CtsAngleIntegrationHostTestCases
Test: CtsRootlessGpuDebugHostTest
Change-Id: I934f64315b67db77ee2c2a9dff50fb23bc0a546a
Merged-In: I934f64315b67db77ee2c2a9dff50fb23bc0a546a
(cherry picked from commit 6a674c9e105bdc5d736c06a4500dcdac1c6c4006)
diff --git a/libs/graphicsenv/GraphicsEnv.cpp b/libs/graphicsenv/GraphicsEnv.cpp
index bb9e263..6e59cc5 100644
--- a/libs/graphicsenv/GraphicsEnv.cpp
+++ b/libs/graphicsenv/GraphicsEnv.cpp
@@ -139,12 +139,8 @@
return env;
}
-int GraphicsEnv::getCanLoadSystemLibraries() {
- if (property_get_bool("ro.debuggable", false) && prctl(PR_GET_DUMPABLE, 0, 0, 0, 0)) {
- // Return an integer value since this crosses library boundaries
- return 1;
- }
- return 0;
+bool GraphicsEnv::isDebuggable() {
+ return prctl(PR_GET_DUMPABLE, 0, 0, 0, 0) > 0;
}
void GraphicsEnv::setDriverPathAndSphalLibraries(const std::string path,
diff --git a/libs/graphicsenv/include/graphicsenv/GraphicsEnv.h b/libs/graphicsenv/include/graphicsenv/GraphicsEnv.h
index 937bcd9..227b458 100644
--- a/libs/graphicsenv/include/graphicsenv/GraphicsEnv.h
+++ b/libs/graphicsenv/include/graphicsenv/GraphicsEnv.h
@@ -84,7 +84,16 @@
public:
static GraphicsEnv& getInstance();
- int getCanLoadSystemLibraries();
+ // Check if the process is debuggable. It returns false except in any of the
+ // following circumstances:
+ // 1. ro.debuggable=1 (global debuggable enabled).
+ // 2. android:debuggable="true" in the manifest for an individual app.
+ // 3. An app which explicitly calls prctl(PR_SET_DUMPABLE, 1).
+ // 4. GraphicsEnv calls prctl(PR_SET_DUMPABLE, 1) in the presence of
+ // <meta-data android:name="com.android.graphics.injectLayers.enable"
+ // android:value="true"/>
+ // in the application manifest.
+ bool isDebuggable();
// Set a search path for loading graphics drivers. The path is a list of
// directories separated by ':'. A directory can be contained in a zip file