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

Commit 09944b04 authored by Jeff Hao's avatar Jeff Hao Committed by Android Git Automerger
Browse files

am 6b34ab3f: Merge "Merge MPSE and SPSE Chunk handlers for ddms."

* commit '6b34ab3f':
  Merge MPSE and SPSE Chunk handlers for ddms.
parents 5d21168b 6b34ab3f
Loading
Loading
Loading
Loading
+13 −34
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ public class DdmHandleProfiling extends ChunkHandler {
    public static final int CHUNK_SPSS = type("SPSS");
    public static final int CHUNK_SPSE = type("SPSE");

    private static final boolean DEBUG = false;
    private static DdmHandleProfiling mInstance = new DdmHandleProfiling();


@@ -72,7 +73,7 @@ public class DdmHandleProfiling extends ChunkHandler {
     * Handle a chunk of data.
     */
    public Chunk handleChunk(Chunk request) {
        if (false)
        if (DEBUG)
            Log.v("ddm-heap", "Handling " + name(request.type) + " chunk");
        int type = request.type;

@@ -83,13 +84,13 @@ public class DdmHandleProfiling extends ChunkHandler {
        } else if (type == CHUNK_MPSS) {
            return handleMPSS(request);
        } else if (type == CHUNK_MPSE) {
            return handleMPSE(request);
            return handleMPSEOrSPSE(request, "Method");
        } else if (type == CHUNK_MPRQ) {
            return handleMPRQ(request);
        } else if (type == CHUNK_SPSS) {
            return handleSPSS(request);
        } else if (type == CHUNK_SPSE) {
            return handleSPSE(request);
            return handleMPSEOrSPSE(request, "Sample");
        } else {
            throw new RuntimeException("Unknown packet "
                + ChunkHandler.name(type));
@@ -106,7 +107,7 @@ public class DdmHandleProfiling extends ChunkHandler {
        int flags = in.getInt();
        int len = in.getInt();
        String fileName = getString(in, len);
        if (false)
        if (DEBUG)
            Log.v("ddm-heap", "Method profiling start: filename='" + fileName
                + "', size=" + bufferSize + ", flags=" + flags);

@@ -146,7 +147,7 @@ public class DdmHandleProfiling extends ChunkHandler {

        int bufferSize = in.getInt();
        int flags = in.getInt();
        if (false) {
        if (DEBUG) {
            Log.v("ddm-heap", "Method prof stream start: size=" + bufferSize
                + ", flags=" + flags);
        }
@@ -160,20 +161,18 @@ public class DdmHandleProfiling extends ChunkHandler {
    }

    /*
     * Handle a "Method Profiling w/Streaming End" request.
     * Handle a "Method Profiling w/Streaming End" request or a
     * "Sample Profiling w/Streaming End" request.
     */
    private Chunk handleMPSE(Chunk request) {
        byte result;

        if (false) {
            Log.v("ddm-heap", "Method prof stream end");
    private Chunk handleMPSEOrSPSE(Chunk request, String type) {
        if (DEBUG) {
            Log.v("ddm-heap", type + " prof stream end");
        }

        try {
            Debug.stopMethodTracing();
            result = 0;
        } catch (RuntimeException re) {
            Log.w("ddm-heap", "Method prof stream end failed: "
            Log.w("ddm-heap", type + " prof stream end failed: "
                + re.getMessage());
            return createFailChunk(1, re.getMessage());
        }
@@ -202,7 +201,7 @@ public class DdmHandleProfiling extends ChunkHandler {
        int bufferSize = in.getInt();
        int flags = in.getInt();
        int interval = in.getInt();
        if (false) {
        if (DEBUG) {
            Log.v("ddm-heap", "Sample prof stream start: size=" + bufferSize
                + ", flags=" + flags + ", interval=" + interval);
        }
@@ -214,25 +213,5 @@ public class DdmHandleProfiling extends ChunkHandler {
            return createFailChunk(1, re.getMessage());
        }
    }

    /*
     * Handle a "Sample Profiling w/Streaming End" request.
     */
    private Chunk handleSPSE(Chunk request) {
        if (false) {
            Log.v("ddm-heap", "Sample prof stream end");
        }

        try {
            Debug.stopMethodTracing();
        } catch (RuntimeException re) {
            Log.w("ddm-heap", "Sample prof stream end failed: "
                + re.getMessage());
            return createFailChunk(1, re.getMessage());
        }

        /* VM sent the (perhaps very large) response directly */
        return null;
    }
}