Skip to content

Commit bc91c5f

Browse files
vsivaAndroid (Google) Code Review
authored andcommitted
Merge "Report the user id of every app to ddms." into jb-mr1-dev
2 parents 009ea5a + d693dfa commit bc91c5f

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

core/java/android/app/ActivityThread.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4066,7 +4066,8 @@ private void handleBindApplication(AppBindData data) {
40664066

40674067
// send up app name; do this *before* waiting for debugger
40684068
Process.setArgV0(data.processName);
4069-
android.ddm.DdmHandleAppName.setAppName(data.processName);
4069+
android.ddm.DdmHandleAppName.setAppName(data.processName,
4070+
UserHandle.myUserId());
40704071

40714072
if (data.persistent) {
40724073
// Persistent processes on low-memory devices do not get to
@@ -4792,7 +4793,8 @@ public void run() {
47924793
ensureJitEnabled();
47934794
}
47944795
});
4795-
android.ddm.DdmHandleAppName.setAppName("<pre-initialized>");
4796+
android.ddm.DdmHandleAppName.setAppName("<pre-initialized>",
4797+
UserHandle.myUserId());
47964798
RuntimeInit.setApplicationObject(mAppThread.asBinder());
47974799
IActivityManager mgr = ActivityManagerNative.getDefault();
47984800
try {
@@ -4803,7 +4805,8 @@ public void run() {
48034805
} else {
48044806
// Don't set application object here -- if the system crashes,
48054807
// we can't display an alert, we just want to die die die.
4806-
android.ddm.DdmHandleAppName.setAppName("system_process");
4808+
android.ddm.DdmHandleAppName.setAppName("system_process",
4809+
UserHandle.myUserId());
48074810
try {
48084811
mInstrumentation = new Instrumentation();
48094812
ContextImpl context = new ContextImpl();

core/java/android/ddm/DdmHandleAppName.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,14 @@ public Chunk handleChunk(Chunk request) {
6969
* before or after DDMS connects. For the latter we need to send up
7070
* an APNM message.
7171
*/
72-
public static void setAppName(String name) {
72+
public static void setAppName(String name, int userId) {
7373
if (name == null || name.length() == 0)
7474
return;
7575

7676
mAppName = name;
7777

7878
// if DDMS is already connected, send the app name up
79-
sendAPNM(name);
79+
sendAPNM(name, userId);
8080
}
8181

8282
public static String getAppName() {
@@ -86,14 +86,18 @@ public static String getAppName() {
8686
/*
8787
* Send an APNM (APplication NaMe) chunk.
8888
*/
89-
private static void sendAPNM(String appName) {
89+
private static void sendAPNM(String appName, int userId) {
9090
if (false)
9191
Log.v("ddm", "Sending app name");
9292

93-
ByteBuffer out = ByteBuffer.allocate(4 + appName.length()*2);
93+
ByteBuffer out = ByteBuffer.allocate(
94+
4 /* appName's length */
95+
+ appName.length()*2 /* appName */
96+
+ 4 /* userId */);
9497
out.order(ChunkHandler.CHUNK_ORDER);
9598
out.putInt(appName.length());
9699
putString(out, appName);
100+
out.putInt(userId);
97101

98102
Chunk chunk = new Chunk(CHUNK_APNM, out);
99103
DdmServer.sendChunk(chunk);

core/java/android/ddm/DdmHandleHello.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.apache.harmony.dalvik.ddmc.DdmServer;
2222
import android.util.Log;
2323
import android.os.Debug;
24+
import android.os.UserHandle;
2425

2526
import java.nio.ByteBuffer;
2627

@@ -119,7 +120,7 @@ private Chunk handleHELO(Chunk request) {
119120
// appName = "unknown";
120121
String appName = DdmHandleAppName.getAppName();
121122

122-
ByteBuffer out = ByteBuffer.allocate(16
123+
ByteBuffer out = ByteBuffer.allocate(20
123124
+ vmIdent.length()*2 + appName.length()*2);
124125
out.order(ChunkHandler.CHUNK_ORDER);
125126
out.putInt(DdmServer.CLIENT_PROTOCOL_VERSION);
@@ -128,6 +129,7 @@ private Chunk handleHELO(Chunk request) {
128129
out.putInt(appName.length());
129130
putString(out, vmIdent);
130131
putString(out, appName);
132+
out.putInt(UserHandle.myUserId());
131133

132134
Chunk reply = new Chunk(CHUNK_HELO, out);
133135

0 commit comments

Comments
 (0)