Propagate owners info in filesystem provider
Owners contain information about the name and the variants of the
modules that are installed in the partition. This information can be
used to determine whether the dependency module is installed or not.
Utilization of this information will be done in a follow up change.
Test: m nothing
Bug: 395989947
Change-Id: I8c63ed5765a3f582ff0d2ce98f63e6e0fc6edad8
diff --git a/filesystem/android_device.go b/filesystem/android_device.go
index 8d7f92f..6d65217 100644
--- a/filesystem/android_device.go
+++ b/filesystem/android_device.go
@@ -15,7 +15,9 @@
package filesystem
import (
+ "cmp"
"fmt"
+ "slices"
"strings"
"sync/atomic"
@@ -247,6 +249,38 @@
a.distFiles(ctx)
}
+// Returns a list of modules that are installed, which are collected from the dependency
+// filesystem and super_image modules.
+func (a *androidDevice) allInstalledModules(ctx android.ModuleContext) []android.Module {
+ fsInfoMap := a.getFsInfos(ctx)
+ allOwners := make(map[string][]string)
+ for _, partition := range android.SortedKeys(fsInfoMap) {
+ fsInfo := fsInfoMap[partition]
+ for _, owner := range fsInfo.Owners {
+ allOwners[owner.Name] = append(allOwners[owner.Name], owner.Variation)
+ }
+ }
+
+ ret := []android.Module{}
+ ctx.WalkDepsProxy(func(mod, _ android.ModuleProxy) bool {
+ if variations, ok := allOwners[mod.Name()]; ok && android.InList(ctx.OtherModuleSubDir(mod), variations) {
+ ret = append(ret, mod)
+ }
+ return true
+ })
+
+ // Remove duplicates
+ ret = android.FirstUniqueFunc(ret, func(a, b android.Module) bool {
+ return a.String() == b.String()
+ })
+
+ // Sort the modules by their names and variants
+ slices.SortFunc(ret, func(a, b android.Module) int {
+ return cmp.Compare(a.String(), b.String())
+ })
+ return ret
+}
+
func (a *androidDevice) distFiles(ctx android.ModuleContext) {
if !ctx.Config().KatiEnabled() {
if proptools.Bool(a.deviceProps.Main_device) {