Dist installed-files.* in soong only build

Implementation details:
- Define static rules for building installed-files.txt and
  installed-files.json
- Avoided adding dependency on the root dir and added dependency
  on the output image file instead
- Propagate the generated installed-files.* via filesystem info provider
  and generate the dist rule in the main android device

Test: m droid dist --soong-only && ls -l out/dist
Bug: 395162005
Bug: 394365683
Change-Id: I615b0374c557fd11c19fcd190232cab411e2d299
diff --git a/filesystem/android_device.go b/filesystem/android_device.go
index b783d0f..52b9d94 100644
--- a/filesystem/android_device.go
+++ b/filesystem/android_device.go
@@ -237,6 +237,26 @@
 	ctx.CheckbuildFile(allImagesStamp)
 
 	a.setVbmetaPhonyTargets(ctx)
+
+	a.distFiles(ctx)
+}
+
+func (a *androidDevice) distFiles(ctx android.ModuleContext) {
+	if !ctx.Config().KatiEnabled() {
+		if proptools.Bool(a.deviceProps.Main_device) {
+			fsInfoMap := a.getFsInfos(ctx)
+			for _, partition := range android.SortedKeys(fsInfoMap) {
+				fsInfo := fsInfoMap[partition]
+				if fsInfo.InstalledFiles.Json != nil {
+					ctx.DistForGoal("droidcore-unbundled", fsInfo.InstalledFiles.Json)
+				}
+				if fsInfo.InstalledFiles.Txt != nil {
+					ctx.DistForGoal("droidcore-unbundled", fsInfo.InstalledFiles.Txt)
+				}
+			}
+		}
+	}
+
 }
 
 func (a *androidDevice) MakeVars(ctx android.MakeVarsModuleContext) {