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

Commit 3b7526e1 authored by Chuwei He's avatar Chuwei He Committed by Automerger Merge Worker
Browse files

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

Merge "Add support for argument array for executeShellCommand (1/2)" into main am: bbfd7f0e am: 0ed8ea74

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/3288078



Change-Id: I47a04fd64009ba3624562d3e7d2acdf234959c05
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 5699a18f 0ed8ea74
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
@@ -565,7 +565,12 @@ public final class UiAutomationConnection extends IUiAutomationConnection.Stub {
            // Rethrow the exception. This will be propagated to the remote caller.
            throw ex;
        }
        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) {
@@ -627,6 +632,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) {