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

Commit b941108d authored by Robert Carr's avatar Robert Carr
Browse files

WindowManager: Include sigil in RemoteSurfaceTrace format.

ADB may break up some of our writes so we need a sigil
or sizing information to parse on the other end.

Test: cts-tradefed run singleCommand cts -o --module CtsWindowManagerHostTestCases --test android.server.cts.SurfaceViewMovementTests#testSurfaceMovesWithParent
Change-Id: Idcc4cdd4bd8427e4d261567135c74f9a6f0049cc
parent 58c34372
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -26,6 +26,11 @@ import android.os.Debug;
// Counterpart to remote surface trace for events which are not tied to a particular surface.
class RemoteEventTrace {
    private static final String TAG = "RemoteEventTrace";

    // We terminate all our messages with a recognizable marker, to avoid issues
    // with partial reads (which ADB makes impossible to avoid).
    static final byte[] sigil = {(byte)0xfc, (byte)0xfc, (byte)0xfc, (byte)0xfc};

    private final WindowManagerService mService;
    private final DataOutputStream mOut;

@@ -37,6 +42,7 @@ class RemoteEventTrace {
    void openSurfaceTransaction() {
        try {
            mOut.writeUTF("OpenTransaction");
            writeSigil();
        } catch (Exception e) {
            logException(e);
            mService.disableSurfaceTrace();
@@ -46,12 +52,17 @@ class RemoteEventTrace {
    void closeSurfaceTransaction() {
        try {
            mOut.writeUTF("CloseTransaction");
            writeSigil();
        } catch (Exception e) {
            logException(e);
            mService.disableSurfaceTrace();
        }
    }

    private void writeSigil() throws Exception {
        mOut.write(RemoteEventTrace.sigil, 0, 4);
    }

    static void logException(Exception e) {
        Slog.i(TAG, "Exception writing to SurfaceTrace (client vanished?): " + e.toString());
    }
+7 −0
Original line number Diff line number Diff line
@@ -121,6 +121,7 @@ class RemoteSurfaceTrace extends SurfaceControl {
        try {
            mOut.writeUTF(tag);
            mOut.writeUTF(mWindow.getWindowTag().toString());
            writeSigil();
        } catch (Exception e) {
            RemoteEventTrace.logException(e);
            mService.disableSurfaceTrace();
@@ -134,6 +135,7 @@ class RemoteSurfaceTrace extends SurfaceControl {
            for (int value: values) {
                mOut.writeInt(value);
            }
            writeSigil();
        } catch (Exception e) {
            RemoteEventTrace.logException(e);
            mService.disableSurfaceTrace();
@@ -147,6 +149,7 @@ class RemoteSurfaceTrace extends SurfaceControl {
            for (float value: values) {
                mOut.writeFloat(value);
            }
            writeSigil();
        } catch (Exception e) {
            RemoteEventTrace.logException(e);
            mService.disableSurfaceTrace();
@@ -156,4 +159,8 @@ class RemoteSurfaceTrace extends SurfaceControl {
    private void writeRectEvent(String tag, Rect value) {
        writeFloatEvent(tag, value.left, value.top, value.right, value.bottom);
    }

    private void writeSigil() throws Exception {
        mOut.write(RemoteEventTrace.sigil, 0, 4);
    }
}