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

Commit bbfd7f0e authored by Chuwei He's avatar Chuwei He Committed by Gerrit Code Review
Browse files

Merge "Add support for argument array for executeShellCommand (1/2)" into main

parents 42724a8e 43fb7395
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -61,6 +61,8 @@ interface IUiAutomationConnection {
    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);
+25 −0
Original line number Diff line number Diff line
@@ -553,7 +553,12 @@ public final class UiAutomationConnection extends IUiAutomationConnection.Stub {
        } 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) {
@@ -615,6 +620,26 @@ public final class UiAutomationConnection extends IUiAutomationConnection.Stub {
        cleanup.start();
    }

    @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) {