From 3df6643ad7652a7fb55233a2362bea757257798f Mon Sep 17 00:00:00 2001 From: Tim Van Patten Date: Mon, 14 Jan 2019 15:56:12 -0700 Subject: [PATCH] Enhance Logging When Skipping Loading Temp Rules We only want to load a temporary rules file for processing if the current app is debuggable or if adb is running as root. The logic to do this is a bit less than straightforward to read and we don't currently log the values to help make it clearer (though we know they were both 'false' to return early). This change helps make the code a bit easier to read and adds some logging that helps make reading the logs a little easier too. Bug: 122612037 Test: atest CtsAngleIntegrationHostTestCases Change-Id: I38baf02ebdb847f9423a80a1093385903eda1686 --- core/java/android/os/GraphicsEnvironment.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/core/java/android/os/GraphicsEnvironment.java b/core/java/android/os/GraphicsEnvironment.java index b0b8f493e98a2..05b47a2535734 100644 --- a/core/java/android/os/GraphicsEnvironment.java +++ b/core/java/android/os/GraphicsEnvironment.java @@ -306,9 +306,18 @@ public class GraphicsEnvironment { String packageName, String paths, String devOptIn) { - // Check for temporary rules if debuggable or root - if (!isDebuggable(context) && !(getCanLoadSystemLibraries() == 1)) { - Log.v(TAG, "Skipping loading temporary rules file"); + /** + * We only want to load a temp rules file for: + * - apps that are marked 'debuggable' in their manifest + * - devices that are running a userdebug build (ro.debuggable) or can inject libraries for + * debugging (PR_SET_DUMPABLE). + */ + boolean appIsDebuggable = isDebuggable(context); + boolean deviceIsDebuggable = getCanLoadSystemLibraries() == 1; + if (!(appIsDebuggable || deviceIsDebuggable)) { + Log.v(TAG, "Skipping loading temporary rules file: " + + "appIsDebuggable = " + appIsDebuggable + ", " + + "adbRootEnabled = " + deviceIsDebuggable); return false; }