summaryrefslogtreecommitdiffstats
path: root/dalvik
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2011-05-24 15:08:50 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2011-05-24 15:08:50 -0700
commit917753d34de3aaf43bc4f3b4e851bccfe3595f82 (patch)
tree064d292af4f96c53ca748618e89f3ffef290f540 /dalvik
parent548d2e6ef6d2f4334a488cac591d11e60675111a (diff)
parent46fc50e810eaab93f2787b355257ab1e837d8bf7 (diff)
downloadlibcore-917753d34de3aaf43bc4f3b4e851bccfe3595f82.zip
libcore-917753d34de3aaf43bc4f3b4e851bccfe3595f82.tar.gz
libcore-917753d34de3aaf43bc4f3b4e851bccfe3595f82.tar.bz2
am 46fc50e8: Merge "Support wrapping app processes to inject debug instrumentation. Bug: 4437846"
* commit '46fc50e810eaab93f2787b355257ab1e837d8bf7': 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);
}