summaryrefslogtreecommitdiffstats
path: root/core/java/android
diff options
context:
space:
mode:
authorGuang Zhu <guangzhu@google.com>2015-03-19 21:14:14 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-03-19 21:14:15 +0000
commit8d09a7445ef2b396e443515ce4b02a52115778db (patch)
tree7d4e90c04d0fe755ab36dfea428a08810838dc85 /core/java/android
parentd81e0056f5bd8b28b83f950b158b7201b91d5815 (diff)
parent14e260125e951c2c6372dae80b603996cbb4d362 (diff)
downloadframeworks_base-8d09a7445ef2b396e443515ce4b02a52115778db.zip
frameworks_base-8d09a7445ef2b396e443515ce4b02a52115778db.tar.gz
frameworks_base-8d09a7445ef2b396e443515ce4b02a52115778db.tar.bz2
Merge "pass stream contents in separate thread for executeShellCommand"
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/app/UiAutomationConnection.java53
1 files changed, 29 insertions, 24 deletions
diff --git a/core/java/android/app/UiAutomationConnection.java b/core/java/android/app/UiAutomationConnection.java
index 81bcb39..9ba6a8e 100644
--- a/core/java/android/app/UiAutomationConnection.java
+++ b/core/java/android/app/UiAutomationConnection.java
@@ -227,7 +227,7 @@ public final class UiAutomationConnection extends IUiAutomationConnection.Stub {
}
@Override
- public void executeShellCommand(String command, ParcelFileDescriptor sink)
+ public void executeShellCommand(final String command, final ParcelFileDescriptor sink)
throws RemoteException {
synchronized (mLock) {
throwIfCalledByNotTrustedUidLocked();
@@ -235,30 +235,35 @@ public final class UiAutomationConnection extends IUiAutomationConnection.Stub {
throwIfNotConnectedLocked();
}
- InputStream in = null;
- OutputStream out = null;
-
- try {
- java.lang.Process process = Runtime.getRuntime().exec(command);
-
- in = process.getInputStream();
- out = new FileOutputStream(sink.getFileDescriptor());
-
- final byte[] buffer = new byte[8192];
- while (true) {
- final int readByteCount = in.read(buffer);
- if (readByteCount < 0) {
- break;
+ Thread streamReader = new Thread() {
+ public void run() {
+ InputStream in = null;
+ OutputStream out = null;
+
+ try {
+ java.lang.Process process = Runtime.getRuntime().exec(command);
+
+ in = process.getInputStream();
+ out = new FileOutputStream(sink.getFileDescriptor());
+
+ final byte[] buffer = new byte[8192];
+ while (true) {
+ final int readByteCount = in.read(buffer);
+ if (readByteCount < 0) {
+ break;
+ }
+ out.write(buffer, 0, readByteCount);
+ }
+ } catch (IOException ioe) {
+ throw new RuntimeException("Error running shell command", ioe);
+ } finally {
+ IoUtils.closeQuietly(in);
+ IoUtils.closeQuietly(out);
+ IoUtils.closeQuietly(sink);
}
- out.write(buffer, 0, readByteCount);
- }
- } catch (IOException ioe) {
- throw new RuntimeException("Error running shell command", ioe);
- } finally {
- IoUtils.closeQuietly(in);
- IoUtils.closeQuietly(out);
- IoUtils.closeQuietly(sink);
- }
+ };
+ };
+ streamReader.start();
}
@Override