Skip to content

Commit 45a5c70

Browse files
committed
support older (?) adb logcat output when starting process
1 parent c67e488 commit 45a5c70

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

src/processing/mode/android/Device.java

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,16 +244,36 @@ public void processLine(final String line) {
244244
entry.message.contains("Start proc") &&
245245
entry.message.contains(packageName)) {
246246
// Sample message string from logcat when starting process:
247-
// "Start proc 29318:processing.test.sketch001/u0a403 for activity processing.test.sketch001/.MainActivity"
247+
// "Start proc 29318:processing.test.sketch001/u0a403 for activity processing.test.sketch001/.MainActivity"
248+
boolean pidFound = false;
249+
248250
try {
249251
int idx0 = entry.message.indexOf("Start proc") + 11;
250252
int idx1 = entry.message.indexOf(packageName) - 1;
251253
String pidStr = entry.message.substring(idx0, idx1);
252254
int pid = Integer.parseInt(pidStr);
253255
startProc(entry.source, pid);
254-
} catch (Exception ex) {
255-
System.err.println("AndroidDevice: cannot find process id, console output will be disabled.");
256-
}
256+
pidFound = true;
257+
} catch (Exception ex) { }
258+
259+
if (!pidFound) {
260+
// In some cases (old adb maybe?):
261+
// https://github.com/processing/processing-android/issues/331
262+
// the process start line is slightly different:
263+
// I/ActivityManager( 648): Start proc processing.test.sketch_170818a for activity processing.test.sketch_170818a/.MainActivity: pid=4256 uid=10175 gids={50175}
264+
try {
265+
int idx0 = entry.message.indexOf("pid=") + 4;
266+
int idx1 = entry.message.indexOf("uid") - 1;
267+
String pidStr = entry.message.substring(idx0, idx1);
268+
int pid = Integer.parseInt(pidStr);
269+
startProc(entry.source, pid);
270+
pidFound = true;
271+
} catch (Exception ex) { }
272+
273+
if (!pidFound) {
274+
System.err.println("AndroidDevice: cannot find process id, console output will be disabled.");
275+
}
276+
}
257277
} else if (packageName != null && !packageName.equals("") &&
258278
entry.message.contains("Killing") &&
259279
entry.message.contains(packageName)) {

0 commit comments

Comments
 (0)