From a250d0461beb6247f5ee37ba6d00bd2d7d872b40 Mon Sep 17 00:00:00 2001 From: demonlol <48394561+demonlol@users.noreply.github.com> Date: Sun, 2 Jan 2022 11:09:24 -0600 Subject: [PATCH] fix(dbg): support multiple main and tags (#1322)(PR #1323) * fix(dgb): support multiple main and tags in manifest * Update jadx-gui/src/main/java/jadx/gui/device/debugger/DbgUtils.java --- .../jadx/gui/device/debugger/DbgUtils.java | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/jadx-gui/src/main/java/jadx/gui/device/debugger/DbgUtils.java b/jadx-gui/src/main/java/jadx/gui/device/debugger/DbgUtils.java index 620bdbf3a..4915513e7 100644 --- a/jadx-gui/src/main/java/jadx/gui/device/debugger/DbgUtils.java +++ b/jadx-gui/src/main/java/jadx/gui/device/debugger/DbgUtils.java @@ -126,13 +126,21 @@ public class DbgUtils { @Nullable public static JClass searchMainActivity(MainWindow mainWindow) { String content = getManifestContent(mainWindow); - int pos = content.indexOf(" -1) { - pos = content.lastIndexOf(" -1) { - pos = content.indexOf(" android:name=\"", pos); + int pos; // current position + int actionPos = 0; // last found action's index + String actionTag = " -1) { + pos = content.indexOf(actionTag, actionPos + actionTagLen); + actionPos = pos; + int activityPos = content.lastIndexOf(" -1) { + int aliasPos = content.lastIndexOf(" -1 && aliasPos > activityPos; + String classPathAttribute = " android:" + (isAnAlias ? "targetActivity" : "name") + "=\""; + pos = content.indexOf(classPathAttribute, isAnAlias ? aliasPos : activityPos); if (pos > -1) { - pos += " android:name=\"".length(); + pos += classPathAttribute.length(); String classFullName = content.substring(pos, content.indexOf("\"", pos)); // in case the MainActivity class has been renamed before, we need raw name. JavaClass cls = mainWindow.getWrapper().getDecompiler().searchJavaClassByAliasFullName(classFullName); @@ -142,6 +150,9 @@ public class DbgUtils { } } } + if (actionTagLen == 0) { + actionTagLen = actionTag.length(); + } } return null; }