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

Commit 953135ff authored by felkachang's avatar felkachang
Browse files

Fix hang of `adb shell cmd resources dump ...`

The process creates a pipe and dup the output file descriptor passed to
the app process. The dup output file descriptor is not closed after
the app has finished the dumping tasks. But, the console is blocked for
reading from the input file descriptor. That's why
`adb shell cmd resources dump com.android.systemui` hangs in very high
frequency.

This patch makes sure the dup output file descriptor is closed after the
app process has finished the dumping tasks.

Fixes: 265098734
Bug: 243579631
Test: adb shell cmd resources dump com.android.systemui
Change-Id: I02eb316e32f27ead25ec37ccbf661a422f137e50
parent 613dc260
Loading
Loading
Loading
Loading
+2 −3
Original line number Original line Diff line number Diff line
@@ -62,13 +62,12 @@ public class ResourcesManagerShellCommand extends ShellCommand {


    private int dumpResources() throws RemoteException {
    private int dumpResources() throws RemoteException {
        String processId = getNextArgRequired();
        String processId = getNextArgRequired();
        try {
        try (ParcelFileDescriptor pfd = ParcelFileDescriptor.dup(getOutFileDescriptor())) {
            ConditionVariable lock = new ConditionVariable();
            ConditionVariable lock = new ConditionVariable();
            RemoteCallback
            RemoteCallback
                    finishCallback = new RemoteCallback(result -> lock.open(), null);
                    finishCallback = new RemoteCallback(result -> lock.open(), null);


            if (!mInterface.dumpResources(processId,
            if (!mInterface.dumpResources(processId, pfd, finishCallback)) {
                    ParcelFileDescriptor.dup(getOutFileDescriptor()), finishCallback)) {
                getErrPrintWriter().println("RESOURCES DUMP FAILED on process " + processId);
                getErrPrintWriter().println("RESOURCES DUMP FAILED on process " + processId);
                return -1;
                return -1;
            }
            }