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

Commit d693dfa7 authored by Siva Velusamy's avatar Siva Velusamy
Browse files

Report the user id of every app to ddms.

This CL extends the HELO and APNM packets to include the user id
of the application. This allows ddms users to differentiate between
the same app running for multiple users.

Bug 7110696.

Change-Id: I490d0e3781b8fb9db65cf81188677a0955650511
parent 753e1280
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -4066,7 +4066,8 @@ public final class ActivityThread {

        // send up app name; do this *before* waiting for debugger
        Process.setArgV0(data.processName);
        android.ddm.DdmHandleAppName.setAppName(data.processName);
        android.ddm.DdmHandleAppName.setAppName(data.processName,
                                                UserHandle.myUserId());

        if (data.persistent) {
            // Persistent processes on low-memory devices do not get to
@@ -4792,7 +4793,8 @@ public final class ActivityThread {
                    ensureJitEnabled();
                }
            });
            android.ddm.DdmHandleAppName.setAppName("<pre-initialized>");
            android.ddm.DdmHandleAppName.setAppName("<pre-initialized>",
                                                    UserHandle.myUserId());
            RuntimeInit.setApplicationObject(mAppThread.asBinder());
            IActivityManager mgr = ActivityManagerNative.getDefault();
            try {
@@ -4803,7 +4805,8 @@ public final class ActivityThread {
        } else {
            // Don't set application object here -- if the system crashes,
            // we can't display an alert, we just want to die die die.
            android.ddm.DdmHandleAppName.setAppName("system_process");
            android.ddm.DdmHandleAppName.setAppName("system_process",
                                                    UserHandle.myUserId());
            try {
                mInstrumentation = new Instrumentation();
                ContextImpl context = new ContextImpl();
+8 −4
Original line number Diff line number Diff line
@@ -69,14 +69,14 @@ public class DdmHandleAppName extends ChunkHandler {
     * before or after DDMS connects.  For the latter we need to send up
     * an APNM message.
     */
    public static void setAppName(String name) {
    public static void setAppName(String name, int userId) {
        if (name == null || name.length() == 0)
            return;

        mAppName = name;

        // if DDMS is already connected, send the app name up
        sendAPNM(name);
        sendAPNM(name, userId);
    }

    public static String getAppName() {
@@ -86,14 +86,18 @@ public class DdmHandleAppName extends ChunkHandler {
    /*
     * Send an APNM (APplication NaMe) chunk.
     */
    private static void sendAPNM(String appName) {
    private static void sendAPNM(String appName, int userId) {
        if (false)
            Log.v("ddm", "Sending app name");

        ByteBuffer out = ByteBuffer.allocate(4 + appName.length()*2);
        ByteBuffer out = ByteBuffer.allocate(
                            4 /* appName's length */
                            + appName.length()*2 /* appName */
                            + 4 /* userId */);
        out.order(ChunkHandler.CHUNK_ORDER);
        out.putInt(appName.length());
        putString(out, appName);
        out.putInt(userId);

        Chunk chunk = new Chunk(CHUNK_APNM, out);
        DdmServer.sendChunk(chunk);
+3 −1
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import org.apache.harmony.dalvik.ddmc.ChunkHandler;
import org.apache.harmony.dalvik.ddmc.DdmServer;
import android.util.Log;
import android.os.Debug;
import android.os.UserHandle;

import java.nio.ByteBuffer;

@@ -119,7 +120,7 @@ public class DdmHandleHello extends ChunkHandler {
        //    appName = "unknown";
        String appName = DdmHandleAppName.getAppName();

        ByteBuffer out = ByteBuffer.allocate(16
        ByteBuffer out = ByteBuffer.allocate(20
                            + vmIdent.length()*2 + appName.length()*2);
        out.order(ChunkHandler.CHUNK_ORDER);
        out.putInt(DdmServer.CLIENT_PROTOCOL_VERSION);
@@ -128,6 +129,7 @@ public class DdmHandleHello extends ChunkHandler {
        out.putInt(appName.length());
        putString(out, vmIdent);
        putString(out, appName);
        out.putInt(UserHandle.myUserId());

        Chunk reply = new Chunk(CHUNK_HELO, out);