Replace usages of SdkAware in sdk module with Module

Previously, the sdk snapshot code used SdkAware instead of Module to
ensure that all its members had implemented SdkAware. However, it never
used any of the methods provided by SdkAware, or if it did it no longer
does. So, this change replaces usages of SdkAware with Module in
preparation for deleting it completely.

Bug: 260237150
Test: m nothing
Change-Id: Ia89e02394f27b2da776f0cf0f0bc86835a03433a
This commit is contained in:
Paul Duffin
2022-11-23 18:09:54 +00:00
parent 2178762a8a
commit 5e71e68a82
2 changed files with 15 additions and 15 deletions

View File

@@ -541,7 +541,7 @@ type SdkMember interface {
Name() string Name() string
// Variants returns all the variants of this module depended upon by the SDK. // Variants returns all the variants of this module depended upon by the SDK.
Variants() []SdkAware Variants() []Module
} }
// SdkMemberDependencyTag is the interface that a tag must implement in order to allow the // SdkMemberDependencyTag is the interface that a tag must implement in order to allow the
@@ -673,7 +673,7 @@ type SdkMemberType interface {
// The sdk module code generates the snapshot as follows: // The sdk module code generates the snapshot as follows:
// //
// * A properties struct of type SdkMemberProperties is created for each variant and // * A properties struct of type SdkMemberProperties is created for each variant and
// populated with information from the variant by calling PopulateFromVariant(SdkAware) // populated with information from the variant by calling PopulateFromVariant(Module)
// on the struct. // on the struct.
// //
// * An additional properties struct is created into which the common properties will be // * An additional properties struct is created into which the common properties will be

View File

@@ -171,9 +171,9 @@ func (s *sdk) collectMembers(ctx android.ModuleContext) {
exportedComponentsInfo = ctx.OtherModuleProvider(child, android.ExportedComponentsInfoProvider).(android.ExportedComponentsInfo) exportedComponentsInfo = ctx.OtherModuleProvider(child, android.ExportedComponentsInfoProvider).(android.ExportedComponentsInfo)
} }
var container android.SdkAware var container android.Module
if parent != ctx.Module() { if parent != ctx.Module() {
container = parent.(android.SdkAware) container = parent.(android.Module)
} }
minApiLevel := android.MinApiLevelForSdkSnapshot(ctx, child) minApiLevel := android.MinApiLevelForSdkSnapshot(ctx, child)
@@ -182,7 +182,7 @@ func (s *sdk) collectMembers(ctx android.ModuleContext) {
s.memberVariantDeps = append(s.memberVariantDeps, sdkMemberVariantDep{ s.memberVariantDeps = append(s.memberVariantDeps, sdkMemberVariantDep{
sdkVariant: s, sdkVariant: s,
memberType: memberType, memberType: memberType,
variant: child.(android.SdkAware), variant: child.(android.Module),
minApiLevel: minApiLevel, minApiLevel: minApiLevel,
container: container, container: container,
export: export, export: export,
@@ -269,7 +269,7 @@ func isMemberTypeSupportedByTargetBuildRelease(memberType android.SdkMemberType,
return supportedByTargetBuildRelease return supportedByTargetBuildRelease
} }
func appendUniqueVariants(variants []android.SdkAware, newVariant android.SdkAware) []android.SdkAware { func appendUniqueVariants(variants []android.Module, newVariant android.Module) []android.Module {
for _, v := range variants { for _, v := range variants {
if v == newVariant { if v == newVariant {
return variants return variants
@@ -1246,12 +1246,12 @@ type sdkMemberVariantDep struct {
memberType android.SdkMemberType memberType android.SdkMemberType
// The variant that is added to the sdk. // The variant that is added to the sdk.
variant android.SdkAware variant android.Module
// The optional container of this member, i.e. the module that is depended upon by the sdk // The optional container of this member, i.e. the module that is depended upon by the sdk
// (possibly transitively) and whose dependency on this module is why it was added to the sdk. // (possibly transitively) and whose dependency on this module is why it was added to the sdk.
// Is nil if this a direct dependency of the sdk. // Is nil if this a direct dependency of the sdk.
container android.SdkAware container android.Module
// True if the member should be exported, i.e. accessible, from outside the sdk. // True if the member should be exported, i.e. accessible, from outside the sdk.
export bool export bool
@@ -1270,14 +1270,14 @@ var _ android.SdkMember = (*sdkMember)(nil)
type sdkMember struct { type sdkMember struct {
memberType android.SdkMemberType memberType android.SdkMemberType
name string name string
variants []android.SdkAware variants []android.Module
} }
func (m *sdkMember) Name() string { func (m *sdkMember) Name() string {
return m.name return m.name
} }
func (m *sdkMember) Variants() []android.SdkAware { func (m *sdkMember) Variants() []android.Module {
return m.variants return m.variants
} }
@@ -1362,24 +1362,24 @@ func getVariantCoordinate(ctx *memberContext, variant android.Module) variantCoo
// by apex variant, where one is the default/platform variant and one is the APEX variant. In that // by apex variant, where one is the default/platform variant and one is the APEX variant. In that
// case it picks the APEX variant. It picks the APEX variant because that is the behavior that would // case it picks the APEX variant. It picks the APEX variant because that is the behavior that would
// be expected // be expected
func selectApexVariantsWhereAvailable(ctx *memberContext, variants []android.SdkAware) []android.SdkAware { func selectApexVariantsWhereAvailable(ctx *memberContext, variants []android.Module) []android.Module {
moduleCtx := ctx.sdkMemberContext moduleCtx := ctx.sdkMemberContext
// Group the variants by coordinates. // Group the variants by coordinates.
variantsByCoord := make(map[variantCoordinate][]android.SdkAware) variantsByCoord := make(map[variantCoordinate][]android.Module)
for _, variant := range variants { for _, variant := range variants {
coord := getVariantCoordinate(ctx, variant) coord := getVariantCoordinate(ctx, variant)
variantsByCoord[coord] = append(variantsByCoord[coord], variant) variantsByCoord[coord] = append(variantsByCoord[coord], variant)
} }
toDiscard := make(map[android.SdkAware]struct{}) toDiscard := make(map[android.Module]struct{})
for coord, list := range variantsByCoord { for coord, list := range variantsByCoord {
count := len(list) count := len(list)
if count == 1 { if count == 1 {
continue continue
} }
variantsByApex := make(map[string]android.SdkAware) variantsByApex := make(map[string]android.Module)
conflictDetected := false conflictDetected := false
for _, variant := range list { for _, variant := range list {
apexInfo := moduleCtx.OtherModuleProvider(variant, android.ApexInfoProvider).(android.ApexInfo) apexInfo := moduleCtx.OtherModuleProvider(variant, android.ApexInfoProvider).(android.ApexInfo)
@@ -1421,7 +1421,7 @@ func selectApexVariantsWhereAvailable(ctx *memberContext, variants []android.Sdk
// If there are any variants to discard then remove them from the list of variants, while // If there are any variants to discard then remove them from the list of variants, while
// preserving the order. // preserving the order.
if len(toDiscard) > 0 { if len(toDiscard) > 0 {
filtered := []android.SdkAware{} filtered := []android.Module{}
for _, variant := range variants { for _, variant := range variants {
if _, ok := toDiscard[variant]; !ok { if _, ok := toDiscard[variant]; !ok {
filtered = append(filtered, variant) filtered = append(filtered, variant)