diff --git a/java/bootclasspath_fragment.go b/java/bootclasspath_fragment.go index b6b179cdf..d78918bff 100644 --- a/java/bootclasspath_fragment.go +++ b/java/bootclasspath_fragment.go @@ -145,7 +145,7 @@ type bootclasspathFragmentProperties struct { BootclasspathFragmentsDepsProperties } -type HiddenApiPackageProperties struct { +type HiddenAPIPackageProperties struct { Hidden_api struct { // Contains prefixes of a package hierarchy that is provided solely by this // bootclasspath_fragment. @@ -222,8 +222,8 @@ type HiddenApiPackageProperties struct { } type SourceOnlyBootclasspathProperties struct { - HiddenApiPackageProperties - Coverage HiddenApiPackageProperties + HiddenAPIPackageProperties + Coverage HiddenAPIPackageProperties } type BootclasspathFragmentModule struct { @@ -293,7 +293,7 @@ func bootclasspathFragmentFactory() android.Module { return } - err = proptools.AppendProperties(&m.sourceOnlyProperties.HiddenApiPackageProperties, &m.sourceOnlyProperties.Coverage, nil) + err = proptools.AppendProperties(&m.sourceOnlyProperties.HiddenAPIPackageProperties, &m.sourceOnlyProperties.Coverage, nil) if err != nil { ctx.PropertyErrorf("coverage", "error trying to append hidden api coverage specific properties: %s", err) return @@ -827,6 +827,9 @@ func (b *BootclasspathFragmentModule) createHiddenAPIFlagInput(ctx android.Modul // Populate with flag file paths from the properties. input.extractFlagFilesFromProperties(ctx, &b.properties.Hidden_api) + // Populate with package rules from the properties. + input.extractPackageRulesFromProperties(&b.sourceOnlyProperties.HiddenAPIPackageProperties) + // Add the stub dex jars from this module's fragment dependencies. input.DependencyStubDexJarsByScope.addStubDexJarsByModule(dependencyHiddenApiInfo.TransitiveStubDexJarsByScope) @@ -862,9 +865,9 @@ func (b *BootclasspathFragmentModule) produceHiddenAPIOutput(ctx android.ModuleC // If the module specifies split_packages or package_prefixes then use those to generate the // signature patterns. - splitPackages := b.sourceOnlyProperties.Hidden_api.Split_packages - packagePrefixes := b.sourceOnlyProperties.Hidden_api.Package_prefixes - singlePackages := b.sourceOnlyProperties.Hidden_api.Single_packages + splitPackages := input.SplitPackages + packagePrefixes := input.PackagePrefixes + singlePackages := input.SinglePackages if splitPackages != nil || packagePrefixes != nil || singlePackages != nil { output.SignaturePatternsPath = buildRuleSignaturePatternsFile( ctx, output.AllFlagsPath, splitPackages, packagePrefixes, singlePackages) diff --git a/java/hiddenapi_modular.go b/java/hiddenapi_modular.go index c90b2ff97..8b77f367b 100644 --- a/java/hiddenapi_modular.go +++ b/java/hiddenapi_modular.go @@ -686,13 +686,50 @@ func (s StubDexJarsByModule) StubDexJarsForScope(scope *HiddenAPIScope) android. return stubDexJars } -// HiddenAPIFlagInput encapsulates information obtained from a module and its dependencies that are -// needed for hidden API flag generation. -type HiddenAPIFlagInput struct { +type HiddenAPIPropertyInfo struct { // FlagFilesByCategory contains the flag files that override the initial flags that are derived // from the stub dex files. FlagFilesByCategory FlagFilesByCategory + // See HiddenAPIFlagFileProperties.Package_prefixes + PackagePrefixes []string + + // See HiddenAPIFlagFileProperties.Single_packages + SinglePackages []string + + // See HiddenAPIFlagFileProperties.Split_packages + SplitPackages []string +} + +// newHiddenAPIPropertyInfo creates a new initialized HiddenAPIPropertyInfo struct. +func newHiddenAPIPropertyInfo() HiddenAPIPropertyInfo { + return HiddenAPIPropertyInfo{ + FlagFilesByCategory: FlagFilesByCategory{}, + } +} + +// extractFlagFilesFromProperties extracts the paths to flag files that are specified in the +// supplied properties and stores them in this struct. +func (i *HiddenAPIPropertyInfo) extractFlagFilesFromProperties(ctx android.ModuleContext, p *HiddenAPIFlagFileProperties) { + for _, category := range HiddenAPIFlagFileCategories { + paths := android.PathsForModuleSrc(ctx, category.propertyValueReader(p)) + i.FlagFilesByCategory[category] = paths + } +} + +// extractPackageRulesFromProperties extracts the package rules that are specified in the supplied +// properties and stores them in this struct. +func (i *HiddenAPIPropertyInfo) extractPackageRulesFromProperties(p *HiddenAPIPackageProperties) { + i.PackagePrefixes = p.Hidden_api.Package_prefixes + i.SinglePackages = p.Hidden_api.Single_packages + i.SplitPackages = p.Hidden_api.Split_packages +} + +// HiddenAPIFlagInput encapsulates information obtained from a module and its dependencies that are +// needed for hidden API flag generation. +type HiddenAPIFlagInput struct { + HiddenAPIPropertyInfo + // StubDexJarsByScope contains the stub dex jars for different *HiddenAPIScope and which determine // the initial flags for each dex member. StubDexJarsByScope StubDexJarsByModule @@ -714,10 +751,10 @@ type HiddenAPIFlagInput struct { RemovedTxtFiles android.Paths } -// newHiddenAPIFlagInput creates a new initialize HiddenAPIFlagInput struct. +// newHiddenAPIFlagInput creates a new initialized HiddenAPIFlagInput struct. func newHiddenAPIFlagInput() HiddenAPIFlagInput { input := HiddenAPIFlagInput{ - FlagFilesByCategory: FlagFilesByCategory{}, + HiddenAPIPropertyInfo: newHiddenAPIPropertyInfo(), StubDexJarsByScope: StubDexJarsByModule{}, DependencyStubDexJarsByScope: StubDexJarsByModule{}, AdditionalStubDexJarsByScope: StubDexJarsByModule{}, @@ -773,15 +810,6 @@ func (i *HiddenAPIFlagInput) gatherStubLibInfo(ctx android.ModuleContext, conten i.RemovedTxtFiles = android.SortedUniquePaths(i.RemovedTxtFiles) } -// extractFlagFilesFromProperties extracts the paths to flag files that are specified in the -// supplied properties and stores them in this struct. -func (i *HiddenAPIFlagInput) extractFlagFilesFromProperties(ctx android.ModuleContext, p *HiddenAPIFlagFileProperties) { - for _, category := range HiddenAPIFlagFileCategories { - paths := android.PathsForModuleSrc(ctx, category.propertyValueReader(p)) - i.FlagFilesByCategory[category] = paths - } -} - func (i *HiddenAPIFlagInput) transitiveStubDexJarsByScope() StubDexJarsByModule { transitive := i.DependencyStubDexJarsByScope transitive.addStubDexJarsByModule(i.StubDexJarsByScope)