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

Commit df7184b3 authored by Riddle Hsu's avatar Riddle Hsu Committed by Automerger Merge Worker
Browse files

Merge "[WMS][Bugfix] Catch exception when dump local window." am: 9b40b1ff...

Merge "[WMS][Bugfix] Catch exception when dump local window." am: 9b40b1ff am: 7d8ac480 am: e1b1e3d9 am: e76395d3 am: e8cae4ca

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



Change-Id: I2dbd087330b24bed00ee2cbb3f7311a14aadfa6c
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 876f13b0 e8cae4ca
Loading
Loading
Loading
Loading
+18 −10
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ import android.provider.Settings;
import android.util.DisplayMetrics;
import android.util.Pair;
import android.view.Display;
import android.view.IWindow;
import android.view.IWindowManager;
import android.view.ViewDebug;

@@ -569,6 +570,22 @@ public class WindowManagerShellCommand extends ShellCommand {
        return 0;
    }

    private void dumpLocalWindowAsync(IWindow client, ParcelFileDescriptor pfd) {
        // Make it asynchronous to avoid writer from being blocked
        // by waiting for the buffer to be consumed in the same process.
        IoThread.getExecutor().execute(() -> {
            synchronized (mInternal.mGlobalLock) {
                try {
                    client.executeCommand(ViewDebug.REMOTE_COMMAND_DUMP_ENCODED, null, pfd);
                } catch (Exception e) {
                    // Ignore RemoteException for local call. Just print trace for other
                    // exceptions caused by RC with tolerable low possibility.
                    e.printStackTrace();
                }
            }
        });
    }

    private int runDumpVisibleWindowViews(PrintWriter pw) {
        if (!mInternal.checkCallingPermission(android.Manifest.permission.DUMP,
                "runDumpVisibleWindowViews()")) {
@@ -591,16 +608,7 @@ public class WindowManagerShellCommand extends ShellCommand {
                            pipe = new ByteTransferPipe();
                            final ParcelFileDescriptor pfd = pipe.getWriteFd();
                            if (w.isClientLocal()) {
                                // Make it asynchronous to avoid writer from being blocked
                                // by waiting for the buffer to be consumed in the same process.
                                IoThread.getExecutor().execute(() -> {
                                    try {
                                        w.mClient.executeCommand(
                                                ViewDebug.REMOTE_COMMAND_DUMP_ENCODED, null, pfd);
                                    } catch (RemoteException e) {
                                        // Ignore for local call.
                                    }
                                });
                                dumpLocalWindowAsync(w.mClient, pfd);
                            } else {
                                w.mClient.executeCommand(
                                        ViewDebug.REMOTE_COMMAND_DUMP_ENCODED, null, pfd);