@@ -89,6 +89,7 @@ public void start(MainWindow mainWindow) {
89
89
app .get ("/manifest" , this ::handleManifest );
90
90
app .get ("/main-application" , this ::handleMainApplication );
91
91
app .get ("/main-activity" , this ::handleMainActivity );
92
+ app .get ("/main-application-class-names" , this ::handleMainApplicationClassNames );
92
93
93
94
logger .info ("JADX MCP plugin HTTP server started at http://127.0.0.1:8650/" );
94
95
} catch (Exception e ) {
@@ -352,6 +353,53 @@ private void handleManifest(Context ctx) {
352
353
}
353
354
}
354
355
356
+ private void handleMainApplicationClassNames (Context ctx ) {
357
+ try {
358
+ JadxWrapper wrapper = mainWindow .getWrapper ();
359
+ List <ResourceFile > resources = wrapper .getResources ();
360
+
361
+ // Get the manifest ResourceFile
362
+ ResourceFile manifestRes = AndroidManifestParser .getAndroidManifest (resources );
363
+ if (manifestRes == null ) {
364
+ ctx .status (404 ).json (Map .of ("error" , "AndroidManifest.xml not found." ));
365
+ return ;
366
+ }
367
+
368
+ // Load manifest content and parse XML
369
+ String manifestXml = manifestRes .loadContent ().getText ().getCodeStr ();
370
+ Document manifestDoc = parseManifestXml (manifestXml , wrapper .getArgs ().getSecurity ());
371
+
372
+ // Extract the package name from the <manifest> tag
373
+ Element manifestElement = (Element ) manifestDoc .getElementsByTagName ("manifest" ).item (0 );
374
+ String packageName = manifestElement .getAttribute ("package" );
375
+
376
+ if (packageName .isEmpty ()) {
377
+ ctx .status (404 ).json (Map .of ("error" , "Package name not found in manifest." ));
378
+ return ;
379
+ }
380
+
381
+ // Filter classes under this package
382
+ List <JavaClass > matchedClasses = wrapper .getDecompiler ().getClasses ().stream ()
383
+ .filter (cls -> cls .getFullName ().startsWith (packageName ))
384
+ .collect (Collectors .toList ());
385
+
386
+ List <Map <String , Object >> classesInfo = new ArrayList <>();
387
+ for (JavaClass cls : matchedClasses ) {
388
+ Map <String , Object > classInfo = new HashMap <>();
389
+ classInfo .put ("name" , cls .getFullName ());
390
+ classesInfo .add (classInfo );
391
+ }
392
+
393
+ Map <String , Object > result = new HashMap <>();
394
+ result .put ("allClassesInPackageName" , classesInfo );
395
+
396
+ ctx .json (result );
397
+ } catch (Exception e ) {
398
+ logger .error ("Error handling main application" , e );
399
+ ctx .status (500 ).json (Map .of ("error" , "Internal error retrieving AndroidManifest.xml: " + e .getMessage ()));
400
+ }
401
+ }
402
+
355
403
private void handleMainApplication (Context ctx ) {
356
404
try {
357
405
JadxWrapper wrapper = mainWindow .getWrapper ();
@@ -402,8 +450,6 @@ private void handleMainApplication(Context ctx) {
402
450
}
403
451
404
452
405
-
406
-
407
453
private void handleMainActivity (Context ctx ) {
408
454
try {
409
455
JadxWrapper wrapper = mainWindow .getWrapper ();
0 commit comments