From 86bd25d5ed8518f2cb91e18ea28bb4e4c0645c19 Mon Sep 17 00:00:00 2001 From: Christopher Ferris Date: Thu, 30 May 2019 16:28:49 -0700 Subject: [PATCH] Avoid using usap when wrap property set. Bug: 133515802 Test: Verified that malloc debug can be enabled on a USAP enabled device. Change-Id: I5f25030ce8e667d175712796c0950f38baa2532d --- core/java/android/os/ZygoteProcess.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/core/java/android/os/ZygoteProcess.java b/core/java/android/os/ZygoteProcess.java index 8f100616f0804..73c48bd18760b 100644 --- a/core/java/android/os/ZygoteProcess.java +++ b/core/java/android/os/ZygoteProcess.java @@ -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 args) { + private static boolean canAttemptUsap(ArrayList 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;