Run soong-built module-info.json through merger

The merge_module_info_json tool is normally used to merge soong and
make-built module-info.json files. But the soong-built module-info.json
file is actually a list of modules, and the merger is still necessary
to turn that list into a map.

Bug: 389720048
Test: refreshmod
Change-Id: I89e617cc07058561611ea97f9650016a9817d9e5
diff --git a/android/androidmk.go b/android/androidmk.go
index f84fd8c..6f094e5 100644
--- a/android/androidmk.go
+++ b/android/androidmk.go
@@ -746,10 +746,17 @@
 	// Build module-info.json. Only in builds with HasDeviceProduct(), as we need a named
 	// device to have a TARGET_OUT folder.
 	if ctx.Config().HasDeviceProduct() {
+		preMergePath := PathForOutput(ctx, "module_info_pre_merging.json")
 		moduleInfoJSONPath := pathForInstall(ctx, Android, X86_64, "", "module-info.json")
-		if err := writeModuleInfoJSON(ctx, moduleInfoJSONs, moduleInfoJSONPath); err != nil {
+		if err := writeModuleInfoJSON(ctx, moduleInfoJSONs, preMergePath); err != nil {
 			ctx.Errorf("%s", err)
 		}
+		builder := NewRuleBuilder(pctx, ctx)
+		builder.Command().
+			BuiltTool("merge_module_info_json").
+			FlagWithOutput("-o ", moduleInfoJSONPath).
+			Input(preMergePath)
+		builder.Build("merge_module_info_json", "merge module info json")
 		ctx.Phony("module-info", moduleInfoJSONPath)
 		ctx.Phony("droidcore-unbundled", moduleInfoJSONPath)
 		allDistContributions = append(allDistContributions, distContributions{