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

Commit 43b9b48f authored by Konstantin Lopyrev's avatar Konstantin Lopyrev
Browse files

Preventing the hierarchy viewer from getting stuck, once when trying to load...

Preventing the hierarchy viewer from getting stuck, once when trying to load the window data for SurfaceView and the Wallpaper, and in the case the captured node has disappeared.

Change-Id: Iaff6bd501a2bb3faa7a394fff740479f6a95e899
parent b8814dce
Loading
Loading
Loading
Loading
+17 −15
Original line number Diff line number Diff line
@@ -1139,7 +1139,13 @@ public class ViewDebug {
        final View captureView = findView(root, parameter);
        Bitmap b = performViewCapture(captureView, false);

        if (b != null) {
        if (b == null) {
            Log.w("View", "Failed to create capture bitmap!");
            // Send an empty one so that it doesn't get stuck waiting for
            // something.
            b = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888);
        }

        BufferedOutputStream out = null;
        try {
            out = new BufferedOutputStream(clientStream, 32 * 1024);
@@ -1151,10 +1157,6 @@ public class ViewDebug {
            }
            b.recycle();
        }
        } else {
            Log.w("View", "Failed to create capture bitmap!");
            clientStream.close();
        }
    }

    private static Bitmap performViewCapture(final View captureView, final boolean skpiChildren) {
+15 −0
Original line number Diff line number Diff line
@@ -4808,6 +4808,8 @@ public class WindowManagerService extends IWindowManager.Stub
        Parcel data = null;
        Parcel reply = null;

        BufferedWriter out = null;

        // Any uncaught exception will crash the system process
        try {
            // Find the hashcode of the window
@@ -4845,6 +4847,12 @@ public class WindowManagerService extends IWindowManager.Stub

            reply.readException();

            if (!client.isOutputShutdown()) {
                out = new BufferedWriter(new OutputStreamWriter(client.getOutputStream()));
                out.write("DONE\n");
                out.flush();
            }

        } catch (Exception e) {
            Slog.w(TAG, "Could not send command " + command + " with parameters " + parameters, e);
            success = false;
@@ -4855,6 +4863,13 @@ public class WindowManagerService extends IWindowManager.Stub
            if (reply != null) {
                reply.recycle();
            }
            if (out != null) {
                try {
                    out.close();
                } catch (IOException e) {

                }
            }
        }

        return success;