OSDN Git Service

Avoid using usap when wrap property set.
authorChristopher Ferris <cferris@google.com>
Thu, 30 May 2019 23:28:49 +0000 (16:28 -0700)
committerChristopher Ferris <cferris@google.com>
Fri, 31 May 2019 17:29:00 +0000 (10:29 -0700)
Bug: 133515802

Test: Verified that malloc debug can be enabled on a USAP enabled device.
Change-Id: I5f25030ce8e667d175712796c0950f38baa2532d

core/java/android/os/ZygoteProcess.java

index 8f10061..73c48bd 100644 (file)
@@ -407,7 +407,7 @@ public class ZygoteProcess {
          */
         String msgStr = args.size() + "\n" + String.join("\n", args) + "\n";
 
-        if (useUsapPool && mUsapPoolEnabled && isValidUsapCommand(args)) {
+        if (useUsapPool && mUsapPoolEnabled && canAttemptUsap(args)) {
             try {
                 return attemptUsapSendArgsAndGetResult(zygoteState, msgStr);
             } catch (IOException ex) {
@@ -498,13 +498,21 @@ public class ZygoteProcess {
      * @param args  Zygote/USAP command arguments
      * @return  True if the command can be passed to a USAP; false otherwise
      */
-    private static boolean isValidUsapCommand(ArrayList<String> args) {
+    private static boolean canAttemptUsap(ArrayList<String> args) {
         for (String flag : args) {
             for (String badFlag : INVALID_USAP_FLAGS) {
                 if (flag.startsWith(badFlag)) {
                     return false;
                 }
             }
+            if (flag.startsWith("--nice-name=")) {
+                // Check if the wrap property is set, usap would ignore it.
+                String niceName = flag.substring(12);
+                String property_value = SystemProperties.get("wrap." + niceName);
+                if (property_value != null && property_value.length() != 0) {
+                    return false;
+                }
+            }
         }
 
         return true;