Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 14e26012 authored by Guang Zhu's avatar Guang Zhu
Browse files

pass stream contents in separate thread for executeShellCommand

Doing it in binder thread will cause deadlock if stdout of
process under execution is larger than buffer of
java.lang.Runtime#exec(String).

Bug: 19829679
Change-Id: Icf0fccd3e2e80b0db4cc1115e501f79066adf091
parent 75f1ba5a
Loading
Loading
Loading
Loading
+29 −24
Original line number Diff line number Diff line
@@ -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,6 +235,8 @@ public final class UiAutomationConnection extends IUiAutomationConnection.Stub {
            throwIfNotConnectedLocked();
        }

        Thread streamReader = new Thread() {
            public void run() {
                InputStream in = null;
                OutputStream out = null;

@@ -259,6 +261,9 @@ public final class UiAutomationConnection extends IUiAutomationConnection.Stub {
                    IoUtils.closeQuietly(out);
                    IoUtils.closeQuietly(sink);
                }
            };
        };
        streamReader.start();
    }

    @Override