summaryrefslogtreecommitdiffstats
path: root/dalvik
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2011-05-24 14:26:23 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-05-24 14:26:23 -0700
commit46fc50e810eaab93f2787b355257ab1e837d8bf7 (patch)
tree13baaa82cfdf4c97810f1137cd611e8497d5a14d /dalvik
parentc77290eaef032e5e8952d65e0456b091b6b50804 (diff)
parent7047a3d4bf12a8eb33156a0abeb900b0ef95263b (diff)
downloadlibcore-46fc50e810eaab93f2787b355257ab1e837d8bf7.zip
libcore-46fc50e810eaab93f2787b355257ab1e837d8bf7.tar.gz
libcore-46fc50e810eaab93f2787b355257ab1e837d8bf7.tar.bz2
Merge "Support wrapping app processes to inject debug instrumentation. Bug: 4437846"
Diffstat (limited to 'dalvik')
-rw-r--r--dalvik/src/main/java/dalvik/system/Zygote.java27
1 files changed, 27 insertions, 0 deletions
diff --git a/dalvik/src/main/java/dalvik/system/Zygote.java b/dalvik/src/main/java/dalvik/system/Zygote.java
index 8e5b34c..336a6d6 100644
--- a/dalvik/src/main/java/dalvik/system/Zygote.java
+++ b/dalvik/src/main/java/dalvik/system/Zygote.java
@@ -183,4 +183,31 @@ public class Zygote {
native public static int nativeForkSystemServer(int uid, int gid,
int[] gids, int debugFlags, int[][] rlimits,
long permittedCapabilities, long effectiveCapabilities);
+
+ /**
+ * Executes "/system/bin/sh -c &lt;command&gt;" using the exec() system call.
+ * This method never returns.
+ *
+ * @param command The shell command to execute.
+ */
+ public static void execShell(String command) {
+ nativeExecShell(command);
+ }
+
+ /**
+ * Appends quotes shell arguments to the specified string builder.
+ * The arguments are quoted using single-quotes, escaped if necessary,
+ * prefixed with a space, and appended to the command.
+ *
+ * @param command A string builder for the shell command being constructed.
+ * @param args An array of argument strings to be quoted and appended to the command.
+ * @see #execShell(String)
+ */
+ public static void appendQuotedShellArgs(StringBuilder command, String[] args) {
+ for (String arg : args) {
+ command.append(" '").append(arg.replace("'", "'\\''")).append("'");
+ }
+ }
+
+ native private static void nativeExecShell(String command);
}