summaryrefslogtreecommitdiff
path: root/core/java/android/os/ShellCommand.java
diff options
context:
space:
mode:
Diffstat (limited to 'core/java/android/os/ShellCommand.java')
-rw-r--r--core/java/android/os/ShellCommand.java19
1 files changed, 19 insertions, 0 deletions
diff --git a/core/java/android/os/ShellCommand.java b/core/java/android/os/ShellCommand.java
index 831c9b27ac45..dbb9650a7cb9 100644
--- a/core/java/android/os/ShellCommand.java
+++ b/core/java/android/os/ShellCommand.java
@@ -188,6 +188,25 @@ public abstract class ShellCommand {
}
/**
+ * Helper for just system services to ask the shell to open an output file.
+ * @hide
+ */
+ public ParcelFileDescriptor openOutputFileForSystem(String path) {
+ try {
+ ParcelFileDescriptor pfd = getShellCallback().openOutputFile(path,
+ "u:r:system_server:s0");
+ if (pfd != null) {
+ return pfd;
+ }
+ } catch (RuntimeException e) {
+ getErrPrintWriter().println("Failure opening file: " + e.getMessage());
+ }
+ getErrPrintWriter().println("Error: Unable to open file: " + path);
+ getErrPrintWriter().println("Consider using a file under /data/local/tmp/");
+ return null;
+ }
+
+ /**
* Return the next option on the command line -- that is an argument that
* starts with '-'. If the next argument is not an option, null is returned.
*/