Merge "Add support for argument array for executeShellCommand (1/2)" into main
diff --git a/core/java/android/app/IUiAutomationConnection.aidl b/core/java/android/app/IUiAutomationConnection.aidl
old mode 100644
new mode 100755
index 69c3bd3..0264f73
--- a/core/java/android/app/IUiAutomationConnection.aidl
+++ b/core/java/android/app/IUiAutomationConnection.aidl
@@ -61,6 +61,8 @@
oneway void shutdown();
void executeShellCommandWithStderr(String command, in ParcelFileDescriptor sink,
in ParcelFileDescriptor source, in ParcelFileDescriptor stderrSink);
+ void executeShellCommandArrayWithStderr(in String[] command, in ParcelFileDescriptor sink,
+ in ParcelFileDescriptor source, in ParcelFileDescriptor stderrSink);
List<String> getAdoptedShellPermissions();
void addOverridePermissionState(int uid, String permission, int result);
void removeOverridePermissionState(int uid, String permission);
diff --git a/core/java/android/app/UiAutomationConnection.java b/core/java/android/app/UiAutomationConnection.java
old mode 100644
new mode 100755
index 3c4bd9e..72db465
--- a/core/java/android/app/UiAutomationConnection.java
+++ b/core/java/android/app/UiAutomationConnection.java
@@ -553,7 +553,12 @@
} catch (IOException exc) {
throw new RuntimeException("Error running shell command '" + command + "'", exc);
}
+ handleExecuteShellCommandProcess(process, sink, source, stderrSink);
+ }
+ private void handleExecuteShellCommandProcess(final java.lang.Process process,
+ final ParcelFileDescriptor sink, final ParcelFileDescriptor source,
+ final ParcelFileDescriptor stderrSink) {
// Read from process and write to pipe
final Thread readFromProcess;
if (sink != null) {
@@ -616,6 +621,26 @@
}
@Override
+ public void executeShellCommandArrayWithStderr(final String[] command,
+ final ParcelFileDescriptor sink, final ParcelFileDescriptor source,
+ final ParcelFileDescriptor stderrSink) throws RemoteException {
+ synchronized (mLock) {
+ throwIfCalledByNotTrustedUidLocked();
+ throwIfShutdownLocked();
+ throwIfNotConnectedLocked();
+ }
+ final java.lang.Process process;
+
+ try {
+ process = Runtime.getRuntime().exec(command);
+ } catch (IOException exc) {
+ throw new RuntimeException(
+ "Error running shell command '" + String.join(" ", command) + "'", exc);
+ }
+ handleExecuteShellCommandProcess(process, sink, source, stderrSink);
+ }
+
+ @Override
public void shutdown() {
synchronized (mLock) {
if (isConnectedLocked()) {