Merge changes I898a94ba,I654c8eb7 into main

* changes:
  Skip recovery.img in Soong target_files.zip
  Get filesystemInfo from Super_image dep
diff --git a/filesystem/android_device.go b/filesystem/android_device.go
index 98a56d7..83cac74 100644
--- a/filesystem/android_device.go
+++ b/filesystem/android_device.go
@@ -225,11 +225,17 @@
 	}
 }
 
+// Helper structs for target_files.zip creation
 type targetFilesZipCopy struct {
 	srcModule  *string
 	destSubdir string
 }
 
+type targetFilesystemZipCopy struct {
+	fsInfo     FilesystemInfo
+	destSubdir string
+}
+
 func (a *androidDevice) buildTargetFilesZip(ctx android.ModuleContext) {
 	targetFilesDir := android.PathForModuleOut(ctx, "target_files_dir")
 	targetFilesZip := android.PathForModuleOut(ctx, "target_files.zip")
@@ -256,25 +262,45 @@
 		toCopy = append(toCopy, targetFilesZipCopy{a.partitionProps.Recovery_partition_name, "VENDOR_BOOT/RAMDISK"})
 	}
 
+	filesystemsToCopy := []targetFilesystemZipCopy{}
 	for _, zipCopy := range toCopy {
 		if zipCopy.srcModule == nil {
 			continue
 		}
-		fsInfo := a.getFilesystemInfo(ctx, *zipCopy.srcModule)
-		subdir := zipCopy.destSubdir
-		rootDirString := fsInfo.RootDir.String()
-		if subdir == "SYSTEM" {
+		filesystemsToCopy = append(
+			filesystemsToCopy,
+			targetFilesystemZipCopy{a.getFilesystemInfo(ctx, *zipCopy.srcModule), zipCopy.destSubdir},
+		)
+	}
+	// Get additional filesystems from super_partition dependency
+	if a.partitionProps.Super_partition_name != nil {
+		superPartition := ctx.GetDirectDepWithTag(*a.partitionProps.Super_partition_name, superPartitionDepTag)
+		if info, ok := android.OtherModuleProvider(ctx, superPartition, SuperImageProvider); ok {
+			for _, partition := range android.SortedStringKeys(info.SubImageInfo) {
+				filesystemsToCopy = append(
+					filesystemsToCopy,
+					targetFilesystemZipCopy{info.SubImageInfo[partition], strings.ToUpper(partition)},
+				)
+			}
+		} else {
+			ctx.ModuleErrorf("Super partition %s does set SuperImageProvider\n", superPartition.Name())
+		}
+	}
+
+	for _, toCopy := range filesystemsToCopy {
+		rootDirString := toCopy.fsInfo.RootDir.String()
+		if toCopy.destSubdir == "SYSTEM" {
 			rootDirString = rootDirString + "/system"
 		}
-		builder.Command().Textf("mkdir -p %s/%s", targetFilesDir.String(), subdir)
+		builder.Command().Textf("mkdir -p %s/%s", targetFilesDir.String(), toCopy.destSubdir)
 		builder.Command().
 			BuiltTool("acp").
-			Textf("-rd %s/. %s/%s", rootDirString, targetFilesDir, subdir).
-			Implicit(fsInfo.Output) // so that the staging dir is built
+			Textf("-rd %s/. %s/%s", rootDirString, targetFilesDir, toCopy.destSubdir).
+			Implicit(toCopy.fsInfo.Output) // so that the staging dir is built
 
-		if subdir == "SYSTEM" {
+		if toCopy.destSubdir == "SYSTEM" {
 			// Create the ROOT partition in target_files.zip
-			builder.Command().Textf("rsync --links --exclude=system/* %s/ -r %s/ROOT", fsInfo.RootDir, targetFilesDir.String())
+			builder.Command().Textf("rsync --links --exclude=system/* %s/ -r %s/ROOT", toCopy.fsInfo.RootDir, targetFilesDir.String())
 		}
 	}
 	// Copy cmdline, kernel etc. files of boot images
@@ -332,9 +358,13 @@
 	}
 	// Copy the filesystem ,boot and vbmeta img files to IMAGES/
 	ctx.VisitDirectDepsProxyWithTag(filesystemDepTag, func(child android.ModuleProxy) {
-		if info, ok := android.OtherModuleProvider(ctx, child, FilesystemProvider); ok {
+		if strings.Contains(child.Name(), "recovery") {
+			return // skip recovery.img to match the make packaging behavior
+		}
+		if info, ok := android.OtherModuleProvider(ctx, child, BootimgInfoProvider); ok {
+			// Check Boot img first so that the boot.img is copied and not its dep ramdisk.img
 			builder.Command().Textf("cp ").Input(info.Output).Textf(" %s/IMAGES/", targetFilesDir.String())
-		} else if info, ok := android.OtherModuleProvider(ctx, child, BootimgInfoProvider); ok {
+		} else if info, ok := android.OtherModuleProvider(ctx, child, FilesystemProvider); ok {
 			builder.Command().Textf("cp ").Input(info.Output).Textf(" %s/IMAGES/", targetFilesDir.String())
 		} else if info, ok := android.OtherModuleProvider(ctx, child, vbmetaPartitionProvider); ok {
 			builder.Command().Textf("cp ").Input(info.Output).Textf(" %s/IMAGES/", targetFilesDir.String())
@@ -342,6 +372,17 @@
 			ctx.ModuleErrorf("Module %s does not provide an .img file output for target_files.zip", child.Name())
 		}
 	})
+
+	if a.partitionProps.Super_partition_name != nil {
+		superPartition := ctx.GetDirectDepWithTag(*a.partitionProps.Super_partition_name, superPartitionDepTag)
+		if info, ok := android.OtherModuleProvider(ctx, superPartition, SuperImageProvider); ok {
+			for _, partition := range android.SortedStringKeys(info.SubImageInfo) {
+				builder.Command().Textf("cp ").Input(info.SubImageInfo[partition].Output).Textf(" %s/IMAGES/", targetFilesDir.String())
+			}
+		} else {
+			ctx.ModuleErrorf("Super partition %s does set SuperImageProvider\n", superPartition.Name())
+		}
+	}
 }
 
 func (a *androidDevice) getFilesystemInfo(ctx android.ModuleContext, depName string) FilesystemInfo {