Use android.Module instead of blueprint.Module in androidmk.go.

Bug: 377723687
Test: Unit tests and compare the ninja and mk files generated.
Change-Id: I819cb6a7dfe314b27769379a6488bf973e190f19
diff --git a/android/androidmk.go b/android/androidmk.go
index 62ab596..c081ba3 100644
--- a/android/androidmk.go
+++ b/android/androidmk.go
@@ -165,7 +165,7 @@
 
 type androidMkExtraEntriesContext struct {
 	ctx fillInEntriesContext
-	mod blueprint.Module
+	mod Module
 }
 
 func (a *androidMkExtraEntriesContext) Provider(provider blueprint.AnyProviderKey) (any, bool) {
@@ -352,8 +352,8 @@
 }
 
 // Compute the contributions that the module makes to the dist.
-func (a *AndroidMkEntries) getDistContributions(mod blueprint.Module) *distContributions {
-	amod := mod.(Module).base()
+func (a *AndroidMkEntries) getDistContributions(mod Module) *distContributions {
+	amod := mod.base()
 	name := amod.BaseModuleName()
 
 	// Collate the set of associated tag/paths available for copying to the dist.
@@ -390,7 +390,7 @@
 	// Collate the contributions this module makes to the dist.
 	distContributions := &distContributions{}
 
-	if !exemptFromRequiredApplicableLicensesProperty(mod.(Module)) {
+	if !exemptFromRequiredApplicableLicensesProperty(mod) {
 		distContributions.licenseMetadataFile = info.LicenseMetadataFile
 	}
 
@@ -501,7 +501,7 @@
 
 // Compute the list of Make strings to declare phony goals and dist-for-goals
 // calls from the module's dist and dists properties.
-func (a *AndroidMkEntries) GetDistForGoals(mod blueprint.Module) []string {
+func (a *AndroidMkEntries) GetDistForGoals(mod Module) []string {
 	distContributions := a.getDistContributions(mod)
 	if distContributions == nil {
 		return nil
@@ -522,11 +522,10 @@
 	HasMutatorFinished(mutatorName string) bool
 }
 
-func (a *AndroidMkEntries) fillInEntries(ctx fillInEntriesContext, mod blueprint.Module) {
+func (a *AndroidMkEntries) fillInEntries(ctx fillInEntriesContext, mod Module) {
 	a.entryContext = ctx
 	a.EntryMap = make(map[string][]string)
-	amod := mod.(Module)
-	base := amod.base()
+	base := mod.base()
 	name := base.BaseModuleName()
 	if a.OverrideName != "" {
 		name = a.OverrideName
@@ -535,10 +534,10 @@
 	if a.Include == "" {
 		a.Include = "$(BUILD_PREBUILT)"
 	}
-	a.Required = append(a.Required, amod.RequiredModuleNames(ctx)...)
-	a.Required = append(a.Required, amod.VintfFragmentModuleNames(ctx)...)
-	a.Host_required = append(a.Host_required, amod.HostRequiredModuleNames()...)
-	a.Target_required = append(a.Target_required, amod.TargetRequiredModuleNames()...)
+	a.Required = append(a.Required, mod.RequiredModuleNames(ctx)...)
+	a.Required = append(a.Required, mod.VintfFragmentModuleNames(ctx)...)
+	a.Host_required = append(a.Host_required, mod.HostRequiredModuleNames()...)
+	a.Target_required = append(a.Target_required, mod.TargetRequiredModuleNames()...)
 
 	for _, distString := range a.GetDistForGoals(mod) {
 		fmt.Fprintln(&a.header, distString)
@@ -554,7 +553,7 @@
 	a.AddStrings("LOCAL_REQUIRED_MODULES", a.Required...)
 	a.AddStrings("LOCAL_HOST_REQUIRED_MODULES", a.Host_required...)
 	a.AddStrings("LOCAL_TARGET_REQUIRED_MODULES", a.Target_required...)
-	a.AddStrings("LOCAL_SOONG_MODULE_TYPE", ctx.ModuleType(amod))
+	a.AddStrings("LOCAL_SOONG_MODULE_TYPE", ctx.ModuleType(mod))
 
 	// If the install rule was generated by Soong tell Make about it.
 	info := OtherModuleProviderOrDefault(ctx, mod, InstallFilesProvider)
@@ -718,10 +717,10 @@
 
 type androidMkSingleton struct{}
 
-func allModulesSorted(ctx SingletonContext) []blueprint.Module {
-	var allModules []blueprint.Module
+func allModulesSorted(ctx SingletonContext) []Module {
+	var allModules []Module
 
-	ctx.VisitAllModulesBlueprint(func(module blueprint.Module) {
+	ctx.VisitAllModules(func(module Module) {
 		allModules = append(allModules, module)
 	})
 
@@ -776,7 +775,7 @@
 // In soong-only mode, we don't do most of the androidmk stuff. But disted files are still largely
 // defined through the androidmk mechanisms, so this function is an alternate implementation of
 // the androidmk singleton that just focuses on getting the dist contributions
-func (so *soongOnlyAndroidMkSingleton) soongOnlyBuildActions(ctx SingletonContext, mods []blueprint.Module) {
+func (so *soongOnlyAndroidMkSingleton) soongOnlyBuildActions(ctx SingletonContext, mods []Module) {
 	allDistContributions, moduleInfoJSONs := getSoongOnlyDataFromMods(ctx, mods)
 
 	singletonDists := getSingletonDists(ctx.Config())
@@ -886,7 +885,7 @@
 
 // getSoongOnlyDataFromMods gathers data from the given modules needed in soong-only builds.
 // Currently, this is the dist contributions, and the module-info.json contents.
-func getSoongOnlyDataFromMods(ctx fillInEntriesContext, mods []blueprint.Module) ([]distContributions, []*ModuleInfoJSON) {
+func getSoongOnlyDataFromMods(ctx fillInEntriesContext, mods []Module) ([]distContributions, []*ModuleInfoJSON) {
 	var allDistContributions []distContributions
 	var moduleInfoJSONs []*ModuleInfoJSON
 	for _, mod := range mods {
@@ -896,7 +895,7 @@
 			}
 		}
 
-		if amod, ok := mod.(Module); ok && shouldSkipAndroidMkProcessing(ctx, amod.base()) {
+		if shouldSkipAndroidMkProcessing(ctx, mod.base()) {
 			continue
 		}
 		if info, ok := OtherModuleProvider(ctx, mod, AndroidMkInfoProvider); ok {
@@ -960,7 +959,7 @@
 	return allDistContributions, moduleInfoJSONs
 }
 
-func translateAndroidMk(ctx SingletonContext, absMkFile string, moduleInfoJSONPath WritablePath, mods []blueprint.Module) error {
+func translateAndroidMk(ctx SingletonContext, absMkFile string, moduleInfoJSONPath WritablePath, mods []Module) error {
 	buf := &bytes.Buffer{}
 
 	var moduleInfoJSONs []*ModuleInfoJSON
@@ -975,8 +974,8 @@
 			return err
 		}
 
-		if amod, ok := mod.(Module); ok && ctx.PrimaryModule(amod) == amod {
-			typeStats[ctx.ModuleType(amod)] += 1
+		if ctx.PrimaryModule(mod) == mod {
+			typeStats[ctx.ModuleType(mod)] += 1
 		}
 	}
 
@@ -1020,7 +1019,7 @@
 	return nil
 }
 
-func translateAndroidMkModule(ctx SingletonContext, w io.Writer, moduleInfoJSONs *[]*ModuleInfoJSON, mod blueprint.Module) error {
+func translateAndroidMkModule(ctx SingletonContext, w io.Writer, moduleInfoJSONs *[]*ModuleInfoJSON, mod Module) error {
 	defer func() {
 		if r := recover(); r != nil {
 			panic(fmt.Errorf("%s in translateAndroidMkModule for module %s variant %s",
@@ -1051,7 +1050,7 @@
 	return err
 }
 
-func (data *AndroidMkData) fillInData(ctx fillInEntriesContext, mod blueprint.Module) {
+func (data *AndroidMkData) fillInData(ctx fillInEntriesContext, mod Module) {
 	// Get the preamble content through AndroidMkEntries logic.
 	data.Entries = AndroidMkEntries{
 		Class:           data.Class,
@@ -1074,9 +1073,9 @@
 // A support func for the deprecated AndroidMkDataProvider interface. Use AndroidMkEntryProvider
 // instead.
 func translateAndroidModule(ctx SingletonContext, w io.Writer, moduleInfoJSONs *[]*ModuleInfoJSON,
-	mod blueprint.Module, provider AndroidMkDataProvider) error {
+	mod Module, provider AndroidMkDataProvider) error {
 
-	amod := mod.(Module).base()
+	amod := mod.base()
 	if shouldSkipAndroidMkProcessing(ctx, amod) {
 		return nil
 	}
@@ -1088,7 +1087,7 @@
 	}
 
 	data.fillInData(ctx, mod)
-	aconfigUpdateAndroidMkData(ctx, mod.(Module), &data)
+	aconfigUpdateAndroidMkData(ctx, mod, &data)
 
 	prefix := ""
 	if amod.ArchSpecific() {
@@ -1169,13 +1168,13 @@
 }
 
 func translateAndroidMkEntriesModule(ctx SingletonContext, w io.Writer, moduleInfoJSONs *[]*ModuleInfoJSON,
-	mod blueprint.Module, provider AndroidMkEntriesProvider) error {
-	if shouldSkipAndroidMkProcessing(ctx, mod.(Module).base()) {
+	mod Module, provider AndroidMkEntriesProvider) error {
+	if shouldSkipAndroidMkProcessing(ctx, mod.base()) {
 		return nil
 	}
 
 	entriesList := provider.AndroidMkEntries()
-	aconfigUpdateAndroidMkEntries(ctx, mod.(Module), &entriesList)
+	aconfigUpdateAndroidMkEntries(ctx, mod, &entriesList)
 
 	moduleInfoJSON, providesModuleInfoJSON := OtherModuleProvider(ctx, mod, ModuleInfoJSONProvider)
 
@@ -1335,15 +1334,15 @@
 var AndroidMkInfoProvider = blueprint.NewProvider[*AndroidMkProviderInfo]()
 
 func translateAndroidMkEntriesInfoModule(ctx SingletonContext, w io.Writer, moduleInfoJSONs *[]*ModuleInfoJSON,
-	mod blueprint.Module, providerInfo *AndroidMkProviderInfo) error {
-	if shouldSkipAndroidMkProcessing(ctx, mod.(Module).base()) {
+	mod Module, providerInfo *AndroidMkProviderInfo) error {
+	if shouldSkipAndroidMkProcessing(ctx, mod.base()) {
 		return nil
 	}
 
 	// Deep copy the provider info since we need to modify the info later
 	info := deepCopyAndroidMkProviderInfo(providerInfo)
 
-	aconfigUpdateAndroidMkInfos(ctx, mod.(Module), &info)
+	aconfigUpdateAndroidMkInfos(ctx, mod, &info)
 
 	// Any new or special cases here need review to verify correct propagation of license information.
 	info.PrimaryInfo.fillInEntries(ctx, mod)
@@ -1479,13 +1478,12 @@
 	a.AddStrings("LOCAL_COMPATIBILITY_SUITE", suites...)
 }
 
-func (a *AndroidMkInfo) fillInEntries(ctx fillInEntriesContext, mod blueprint.Module) {
+func (a *AndroidMkInfo) fillInEntries(ctx fillInEntriesContext, mod Module) {
 	helperInfo := AndroidMkInfo{
 		EntryMap: make(map[string][]string),
 	}
 
-	amod := mod.(Module)
-	base := amod.base()
+	base := mod.base()
 	name := base.BaseModuleName()
 	if a.OverrideName != "" {
 		name = a.OverrideName
@@ -1494,10 +1492,10 @@
 	if a.Include == "" {
 		a.Include = "$(BUILD_PREBUILT)"
 	}
-	a.Required = append(a.Required, amod.RequiredModuleNames(ctx)...)
-	a.Required = append(a.Required, amod.VintfFragmentModuleNames(ctx)...)
-	a.Host_required = append(a.Host_required, amod.HostRequiredModuleNames()...)
-	a.Target_required = append(a.Target_required, amod.TargetRequiredModuleNames()...)
+	a.Required = append(a.Required, mod.RequiredModuleNames(ctx)...)
+	a.Required = append(a.Required, mod.VintfFragmentModuleNames(ctx)...)
+	a.Host_required = append(a.Host_required, mod.HostRequiredModuleNames()...)
+	a.Target_required = append(a.Target_required, mod.TargetRequiredModuleNames()...)
 
 	for _, distString := range a.GetDistForGoals(ctx, mod) {
 		a.HeaderStrings = append(a.HeaderStrings, distString)
@@ -1513,7 +1511,7 @@
 	helperInfo.AddStrings("LOCAL_REQUIRED_MODULES", a.Required...)
 	helperInfo.AddStrings("LOCAL_HOST_REQUIRED_MODULES", a.Host_required...)
 	helperInfo.AddStrings("LOCAL_TARGET_REQUIRED_MODULES", a.Target_required...)
-	helperInfo.AddStrings("LOCAL_SOONG_MODULE_TYPE", ctx.ModuleType(amod))
+	helperInfo.AddStrings("LOCAL_SOONG_MODULE_TYPE", ctx.ModuleType(mod))
 
 	// If the install rule was generated by Soong tell Make about it.
 	info := OtherModuleProviderOrDefault(ctx, mod, InstallFilesProvider)
@@ -1654,7 +1652,7 @@
 
 // Compute the list of Make strings to declare phony goals and dist-for-goals
 // calls from the module's dist and dists properties.
-func (a *AndroidMkInfo) GetDistForGoals(ctx fillInEntriesContext, mod blueprint.Module) []string {
+func (a *AndroidMkInfo) GetDistForGoals(ctx fillInEntriesContext, mod Module) []string {
 	distContributions := a.getDistContributions(ctx, mod)
 	if distContributions == nil {
 		return nil
@@ -1664,8 +1662,8 @@
 }
 
 // Compute the contributions that the module makes to the dist.
-func (a *AndroidMkInfo) getDistContributions(ctx fillInEntriesContext, mod blueprint.Module) *distContributions {
-	amod := mod.(Module).base()
+func (a *AndroidMkInfo) getDistContributions(ctx fillInEntriesContext, mod Module) *distContributions {
+	amod := mod.base()
 	name := amod.BaseModuleName()
 
 	// Collate the set of associated tag/paths available for copying to the dist.
@@ -1702,7 +1700,7 @@
 	// Collate the contributions this module makes to the dist.
 	distContributions := &distContributions{}
 
-	if !exemptFromRequiredApplicableLicensesProperty(mod.(Module)) {
+	if !exemptFromRequiredApplicableLicensesProperty(mod) {
 		distContributions.licenseMetadataFile = info.LicenseMetadataFile
 	}
 
diff --git a/android/testing.go b/android/testing.go
index 8e38b3b..fe9bcec 100644
--- a/android/testing.go
+++ b/android/testing.go
@@ -1161,7 +1161,7 @@
 	config.katiEnabled = true
 }
 
-func AndroidMkEntriesForTest(t *testing.T, ctx *TestContext, mod blueprint.Module) []AndroidMkEntries {
+func AndroidMkEntriesForTest(t *testing.T, ctx *TestContext, mod Module) []AndroidMkEntries {
 	t.Helper()
 	var p AndroidMkEntriesProvider
 	var ok bool
@@ -1170,15 +1170,15 @@
 	}
 
 	entriesList := p.AndroidMkEntries()
-	aconfigUpdateAndroidMkEntries(ctx, mod.(Module), &entriesList)
+	aconfigUpdateAndroidMkEntries(ctx, mod, &entriesList)
 	for i := range entriesList {
 		entriesList[i].fillInEntries(ctx, mod)
 	}
 	return entriesList
 }
 
-func AndroidMkInfoForTest(t *testing.T, ctx *TestContext, mod blueprint.Module) *AndroidMkProviderInfo {
-	if runtime.GOOS == "darwin" && mod.(Module).base().Os() != Darwin {
+func AndroidMkInfoForTest(t *testing.T, ctx *TestContext, mod Module) *AndroidMkProviderInfo {
+	if runtime.GOOS == "darwin" && mod.base().Os() != Darwin {
 		// The AndroidMkInfo provider is not set in this case.
 		t.Skip("AndroidMkInfo provider is not set on darwin")
 	}
@@ -1190,7 +1190,7 @@
 	}
 
 	info := OtherModuleProviderOrDefault(ctx, mod, AndroidMkInfoProvider)
-	aconfigUpdateAndroidMkInfos(ctx, mod.(Module), info)
+	aconfigUpdateAndroidMkInfos(ctx, mod, info)
 	info.PrimaryInfo.fillInEntries(ctx, mod)
 	if len(info.ExtraInfo) > 0 {
 		for _, ei := range info.ExtraInfo {
@@ -1201,7 +1201,7 @@
 	return info
 }
 
-func AndroidMkDataForTest(t *testing.T, ctx *TestContext, mod blueprint.Module) AndroidMkData {
+func AndroidMkDataForTest(t *testing.T, ctx *TestContext, mod Module) AndroidMkData {
 	t.Helper()
 	var p AndroidMkDataProvider
 	var ok bool
@@ -1210,7 +1210,7 @@
 	}
 	data := p.AndroidMk()
 	data.fillInData(ctx, mod)
-	aconfigUpdateAndroidMkData(ctx, mod.(Module), &data)
+	aconfigUpdateAndroidMkData(ctx, mod, &data)
 	return data
 }