summaryrefslogtreecommitdiffstats
path: root/dalvik
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2011-05-16 17:08:24 -0700
committerJeff Brown <jeffbrown@google.com>2011-05-20 15:21:35 -0700
commit7047a3d4bf12a8eb33156a0abeb900b0ef95263b (patch)
tree6a2bf2b55e086ee4c1f889c1f4e06002ea3b928d /dalvik
parent1e8d508f2d97e19f2fc8a709330ea97e1e9f203a (diff)
downloadlibcore-7047a3d4bf12a8eb33156a0abeb900b0ef95263b.zip
libcore-7047a3d4bf12a8eb33156a0abeb900b0ef95263b.tar.gz
libcore-7047a3d4bf12a8eb33156a0abeb900b0ef95263b.tar.bz2
Support wrapping app processes to inject debug instrumentation.
Bug: 4437846 Change-Id: I8d66b13f1c1dc9c30f72033f190121979a44b212
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);
}