Revert "Patch to fix Aug train issue with tethering"

Revert "[automerge] Patch to fix Aug train issue with tethering ..."

Revert submission 19432194-presubmit-am-5e598b33be884d9f98a29ce1c3c575fb

Reason for revert: Not needed in tm-mainline-prod and breaks bluetooth.
Reverted Changes:
I57969b85a:Patch to fix Aug train issue with tethering
Ie6560f201:[automerge] Patch to fix Aug train issue with teth...

Change-Id: If44d16a00847a554862aa139c04370ad30166c74
This commit is contained in:
Paul Duffin
2022-07-28 10:07:30 +00:00
parent a649ad5b31
commit 9bcfe69743
8 changed files with 84 additions and 431 deletions

View File

@@ -74,22 +74,6 @@ type SdkAware interface {
sdkAwareWithoutModule sdkAwareWithoutModule
} }
type minApiLevelForSdkSnapshot interface {
MinApiLevelForSdkSnapshot(ctx EarlyModuleContext) ApiLevel
}
func MinApiLevelForSdkSnapshot(ctx EarlyModuleContext, module Module) ApiLevel {
minApiLevel := NoneApiLevel
if m, ok := module.(minApiLevelForSdkSnapshot); ok {
minApiLevel = m.MinApiLevelForSdkSnapshot(ctx)
}
if minApiLevel == NoneApiLevel {
// The default API level is Q, i.e. the first release that supported mainline modules.
minApiLevel = uncheckedFinalApiLevel(29)
}
return minApiLevel
}
// SdkRef refers to a version of an SDK // SdkRef refers to a version of an SDK
type SdkRef struct { type SdkRef struct {
Name string Name string

View File

@@ -645,14 +645,6 @@ func (j *Module) MinSdkVersion(ctx android.EarlyModuleContext) android.SdkSpec {
return j.SdkVersion(ctx) return j.SdkVersion(ctx)
} }
func (j *Module) MinApiLevelForSdkSnapshot(ctx android.EarlyModuleContext) android.ApiLevel {
if j.deviceProperties.Min_sdk_version != nil {
return android.SdkSpecFrom(ctx, *j.deviceProperties.Min_sdk_version).ApiLevel
} else {
return android.NoneApiLevel
}
}
func (j *Module) MaxSdkVersion(ctx android.EarlyModuleContext) android.SdkSpec { func (j *Module) MaxSdkVersion(ctx android.EarlyModuleContext) android.SdkSpec {
maxSdkVersion := proptools.StringDefault(j.deviceProperties.Max_sdk_version, "") maxSdkVersion := proptools.StringDefault(j.deviceProperties.Max_sdk_version, "")
// SdkSpecFrom returns SdkSpecPrivate for this, which may be confusing. // SdkSpecFrom returns SdkSpecPrivate for this, which may be confusing.

View File

@@ -769,7 +769,7 @@ func (b *BootclasspathFragmentModule) generateHiddenAPIBuildActions(ctx android.
// their own. // their own.
if output.SignaturePatternsPath == nil { if output.SignaturePatternsPath == nil {
output.SignaturePatternsPath = buildRuleSignaturePatternsFile( output.SignaturePatternsPath = buildRuleSignaturePatternsFile(
ctx, output.AllFlagsPath, []string{"*"}, nil, nil, "") ctx, output.AllFlagsPath, []string{"*"}, nil, nil)
} }
// Initialize a HiddenAPIInfo structure. // Initialize a HiddenAPIInfo structure.
@@ -853,10 +853,12 @@ func (b *BootclasspathFragmentModule) isTestFragment() bool {
return false return false
} }
func (b *BootclasspathFragmentModule) generateHiddenApiFlagRules(ctx android.ModuleContext, contents []android.Module, input HiddenAPIFlagInput, bootDexInfoByModule bootDexInfoByModule, suffix string) HiddenAPIFlagOutput { // produceHiddenAPIOutput produces the hidden API all-flags.csv file (and supporting files)
// for the fragment as well as encoding the flags in the boot dex jars.
func (b *BootclasspathFragmentModule) produceHiddenAPIOutput(ctx android.ModuleContext, contents []android.Module, input HiddenAPIFlagInput) *HiddenAPIOutput {
// Generate the rules to create the hidden API flags and update the supplied hiddenAPIInfo with the // Generate the rules to create the hidden API flags and update the supplied hiddenAPIInfo with the
// paths to the created files. // paths to the created files.
flagOutput := hiddenAPIFlagRulesForBootclasspathFragment(ctx, bootDexInfoByModule, contents, input, suffix) output := hiddenAPIRulesForBootclasspathFragment(ctx, contents, input)
// If the module specifies split_packages or package_prefixes then use those to generate the // If the module specifies split_packages or package_prefixes then use those to generate the
// signature patterns. // signature patterns.
@@ -864,8 +866,8 @@ func (b *BootclasspathFragmentModule) generateHiddenApiFlagRules(ctx android.Mod
packagePrefixes := b.sourceOnlyProperties.Hidden_api.Package_prefixes packagePrefixes := b.sourceOnlyProperties.Hidden_api.Package_prefixes
singlePackages := b.sourceOnlyProperties.Hidden_api.Single_packages singlePackages := b.sourceOnlyProperties.Hidden_api.Single_packages
if splitPackages != nil || packagePrefixes != nil || singlePackages != nil { if splitPackages != nil || packagePrefixes != nil || singlePackages != nil {
flagOutput.SignaturePatternsPath = buildRuleSignaturePatternsFile( output.SignaturePatternsPath = buildRuleSignaturePatternsFile(
ctx, flagOutput.AllFlagsPath, splitPackages, packagePrefixes, singlePackages, suffix) ctx, output.AllFlagsPath, splitPackages, packagePrefixes, singlePackages)
} else if !b.isTestFragment() { } else if !b.isTestFragment() {
ctx.ModuleErrorf(`Must specify at least one of the split_packages, package_prefixes and single_packages properties ctx.ModuleErrorf(`Must specify at least one of the split_packages, package_prefixes and single_packages properties
If this is a new bootclasspath_fragment or you are unsure what to do add the If this is a new bootclasspath_fragment or you are unsure what to do add the
@@ -877,49 +879,6 @@ func (b *BootclasspathFragmentModule) generateHiddenApiFlagRules(ctx android.Mod
should specify here. If you are happy with its suggestions then you can add should specify here. If you are happy with its suggestions then you can add
the --fix option and it will fix them for you.`, b.BaseModuleName()) the --fix option and it will fix them for you.`, b.BaseModuleName())
} }
return flagOutput
}
// produceHiddenAPIOutput produces the hidden API all-flags.csv file (and supporting files)
// for the fragment as well as encoding the flags in the boot dex jars.
func (b *BootclasspathFragmentModule) produceHiddenAPIOutput(ctx android.ModuleContext, contents []android.Module, input HiddenAPIFlagInput) *HiddenAPIOutput {
// Gather information about the boot dex files for the boot libraries provided by this fragment.
bootDexInfoByModule := extractBootDexInfoFromModules(ctx, contents)
flagOutput := b.generateHiddenApiFlagRules(ctx, contents, input, bootDexInfoByModule, "")
encodedBootDexFilesByModule := hiddenAPIEncodeRulesForBootclasspathFragment(ctx, bootDexInfoByModule, flagOutput.AllFlagsPath)
output := &HiddenAPIOutput{
HiddenAPIFlagOutput: flagOutput,
EncodedBootDexFilesByModule: encodedBootDexFilesByModule,
}
config := ctx.Config()
targetApiLevel := android.ApiLevelOrPanic(ctx,
config.GetenvWithDefault("SOONG_SDK_SNAPSHOT_TARGET_BUILD_RELEASE", "current"))
filterContents := []android.Module{}
for _, module := range contents {
minApiLevel := android.MinApiLevelForSdkSnapshot(ctx, module)
if minApiLevel.GreaterThan(targetApiLevel) {
delete(bootDexInfoByModule, module.Name())
delete(input.StubDexJarsByScope, module.Name())
continue
}
filterContents = append(filterContents, module)
}
if len(filterContents) != len(contents) {
flagOutput = b.generateHiddenApiFlagRules(ctx, filterContents, input, bootDexInfoByModule, "-for-sdk-snapshot")
}
// Copy the information and make it available for sdk snapshot.
ctx.SetProvider(HiddenAPIInfoForSdkProvider, HiddenAPIInfoForSdk{
FlagFilesByCategory: input.FlagFilesByCategory,
HiddenAPIFlagOutput: flagOutput,
})
return output return output
} }
@@ -1085,7 +1044,7 @@ func (b *bootclasspathFragmentSdkMemberProperties) PopulateFromVariant(ctx andro
// Get the hidden API information from the module. // Get the hidden API information from the module.
mctx := ctx.SdkModuleContext() mctx := ctx.SdkModuleContext()
hiddenAPIInfo := mctx.OtherModuleProvider(module, HiddenAPIInfoForSdkProvider).(HiddenAPIInfoForSdk) hiddenAPIInfo := mctx.OtherModuleProvider(module, HiddenAPIInfoProvider).(HiddenAPIInfo)
b.Flag_files_by_category = hiddenAPIInfo.FlagFilesByCategory b.Flag_files_by_category = hiddenAPIInfo.FlagFilesByCategory
// Copy all the generated file paths. // Copy all the generated file paths.
@@ -1264,15 +1223,6 @@ func (module *PrebuiltBootclasspathFragmentModule) produceHiddenAPIOutput(ctx an
output.FilteredStubFlagsPath = pathForOptionalSrc(module.prebuiltProperties.Hidden_api.Filtered_stub_flags, output.StubFlagsPath) output.FilteredStubFlagsPath = pathForOptionalSrc(module.prebuiltProperties.Hidden_api.Filtered_stub_flags, output.StubFlagsPath)
output.FilteredFlagsPath = pathForOptionalSrc(module.prebuiltProperties.Hidden_api.Filtered_flags, output.AllFlagsPath) output.FilteredFlagsPath = pathForOptionalSrc(module.prebuiltProperties.Hidden_api.Filtered_flags, output.AllFlagsPath)
// If the prebuilts module does not provide a signature patterns file then generate one from the
// flags.
// TODO(b/192868581): Remove once the prebuilts all provide a signature patterns file of their
// own.
if output.SignaturePatternsPath == nil {
output.SignaturePatternsPath = buildRuleSignaturePatternsFile(
ctx, output.AllFlagsPath, []string{"*"}, nil, nil, "")
}
return &output return &output
} }

View File

@@ -571,23 +571,6 @@ func (i *HiddenAPIInfo) FlagSubset() SignatureCsvSubset {
var HiddenAPIInfoProvider = blueprint.NewProvider(HiddenAPIInfo{}) var HiddenAPIInfoProvider = blueprint.NewProvider(HiddenAPIInfo{})
// HiddenAPIInfoForSdk contains information provided by the hidden API processing for use
// by the sdk snapshot.
//
// That includes paths resolved from HiddenAPIFlagFileProperties and also generated by hidden API
// processing.
type HiddenAPIInfoForSdk struct {
// FlagFilesByCategory maps from the flag file category to the paths containing information for
// that category.
FlagFilesByCategory FlagFilesByCategory
// The output from the hidden API processing needs to be made available to other modules.
HiddenAPIFlagOutput
}
// Provides hidden API info for the sdk snapshot.
var HiddenAPIInfoForSdkProvider = blueprint.NewProvider(HiddenAPIInfoForSdk{})
// ModuleStubDexJars contains the stub dex jars provided by a single module. // ModuleStubDexJars contains the stub dex jars provided by a single module.
// //
// It maps a *HiddenAPIScope to the path to stub dex jars appropriate for that scope. See // It maps a *HiddenAPIScope to the path to stub dex jars appropriate for that scope. See
@@ -970,11 +953,8 @@ func (s SignatureCsvSubsets) RelativeToTop() []string {
// patterns that will select a subset of the monolithic flags. // patterns that will select a subset of the monolithic flags.
func buildRuleSignaturePatternsFile( func buildRuleSignaturePatternsFile(
ctx android.ModuleContext, flagsPath android.Path, ctx android.ModuleContext, flagsPath android.Path,
splitPackages []string, packagePrefixes []string, singlePackages []string, splitPackages []string, packagePrefixes []string, singlePackages []string) android.Path {
suffix string) android.Path { patternsFile := android.PathForModuleOut(ctx, "modular-hiddenapi", "signature-patterns.csv")
hiddenApiSubDir := "modular-hiddenapi" + suffix
patternsFile := android.PathForModuleOut(ctx, hiddenApiSubDir, "signature-patterns.csv")
// Create a rule to validate the output from the following rule. // Create a rule to validate the output from the following rule.
rule := android.NewRuleBuilder(pctx, ctx) rule := android.NewRuleBuilder(pctx, ctx)
@@ -991,7 +971,7 @@ func buildRuleSignaturePatternsFile(
FlagForEachArg("--package-prefix ", packagePrefixes). FlagForEachArg("--package-prefix ", packagePrefixes).
FlagForEachArg("--single-package ", singlePackages). FlagForEachArg("--single-package ", singlePackages).
FlagWithOutput("--output ", patternsFile) FlagWithOutput("--output ", patternsFile)
rule.Build("hiddenAPISignaturePatterns"+suffix, "hidden API signature patterns"+suffix) rule.Build("hiddenAPISignaturePatterns", "hidden API signature patterns")
return patternsFile return patternsFile
} }
@@ -1065,7 +1045,7 @@ func buildRuleValidateOverlappingCsvFiles(ctx android.BuilderContext, name strin
return validFile return validFile
} }
// hiddenAPIFlagRulesForBootclasspathFragment will generate all the flags for a fragment of the // hiddenAPIRulesForBootclasspathFragment will generate all the flags for a fragment of the
// bootclasspath and then encode the flags into the boot dex files. // bootclasspath and then encode the flags into the boot dex files.
// //
// It takes: // It takes:
@@ -1080,27 +1060,30 @@ func buildRuleValidateOverlappingCsvFiles(ctx android.BuilderContext, name strin
// * index.csv // * index.csv
// * all-flags.csv // * all-flags.csv
// * encoded boot dex files // * encoded boot dex files
func hiddenAPIFlagRulesForBootclasspathFragment(ctx android.ModuleContext, bootDexInfoByModule bootDexInfoByModule, contents []android.Module, input HiddenAPIFlagInput, suffix string) HiddenAPIFlagOutput { func hiddenAPIRulesForBootclasspathFragment(ctx android.ModuleContext, contents []android.Module, input HiddenAPIFlagInput) *HiddenAPIOutput {
hiddenApiSubDir := "modular-hiddenapi" + suffix hiddenApiSubDir := "modular-hiddenapi"
// Gather information about the boot dex files for the boot libraries provided by this fragment.
bootDexInfoByModule := extractBootDexInfoFromModules(ctx, contents)
// Generate the stub-flags.csv. // Generate the stub-flags.csv.
stubFlagsCSV := android.PathForModuleOut(ctx, hiddenApiSubDir, "stub-flags.csv") stubFlagsCSV := android.PathForModuleOut(ctx, hiddenApiSubDir, "stub-flags.csv")
buildRuleToGenerateHiddenAPIStubFlagsFile(ctx, "modularHiddenAPIStubFlagsFile"+suffix, "modular hiddenapi stub flags", stubFlagsCSV, bootDexInfoByModule.bootDexJars(), input, nil) buildRuleToGenerateHiddenAPIStubFlagsFile(ctx, "modularHiddenAPIStubFlagsFile", "modular hiddenapi stub flags", stubFlagsCSV, bootDexInfoByModule.bootDexJars(), input, nil)
// Extract the classes jars from the contents. // Extract the classes jars from the contents.
classesJars := extractClassesJarsFromModules(contents) classesJars := extractClassesJarsFromModules(contents)
// Generate the set of flags from the annotations in the source code. // Generate the set of flags from the annotations in the source code.
annotationFlagsCSV := android.PathForModuleOut(ctx, hiddenApiSubDir, "annotation-flags.csv") annotationFlagsCSV := android.PathForModuleOut(ctx, hiddenApiSubDir, "annotation-flags.csv")
buildRuleToGenerateAnnotationFlags(ctx, "modular hiddenapi annotation flags"+suffix, classesJars, stubFlagsCSV, annotationFlagsCSV) buildRuleToGenerateAnnotationFlags(ctx, "modular hiddenapi annotation flags", classesJars, stubFlagsCSV, annotationFlagsCSV)
// Generate the metadata from the annotations in the source code. // Generate the metadata from the annotations in the source code.
metadataCSV := android.PathForModuleOut(ctx, hiddenApiSubDir, "metadata.csv") metadataCSV := android.PathForModuleOut(ctx, hiddenApiSubDir, "metadata.csv")
buildRuleToGenerateMetadata(ctx, "modular hiddenapi metadata"+suffix, classesJars, stubFlagsCSV, metadataCSV) buildRuleToGenerateMetadata(ctx, "modular hiddenapi metadata", classesJars, stubFlagsCSV, metadataCSV)
// Generate the index file from the CSV files in the classes jars. // Generate the index file from the CSV files in the classes jars.
indexCSV := android.PathForModuleOut(ctx, hiddenApiSubDir, "index.csv") indexCSV := android.PathForModuleOut(ctx, hiddenApiSubDir, "index.csv")
buildRuleToGenerateIndex(ctx, "modular hiddenapi index"+suffix, classesJars, indexCSV) buildRuleToGenerateIndex(ctx, "modular hiddenapi index", classesJars, indexCSV)
// Removed APIs need to be marked and in order to do that the hiddenAPIInfo needs to specify files // Removed APIs need to be marked and in order to do that the hiddenAPIInfo needs to specify files
// containing dex signatures of all the removed APIs. In the monolithic files that is done by // containing dex signatures of all the removed APIs. In the monolithic files that is done by
@@ -1108,42 +1091,15 @@ func hiddenAPIFlagRulesForBootclasspathFragment(ctx android.ModuleContext, bootD
// signatures, see the combined-removed-dex module. This does that automatically by using the // signatures, see the combined-removed-dex module. This does that automatically by using the
// *removed.txt files retrieved from the java_sdk_library modules that are specified in the // *removed.txt files retrieved from the java_sdk_library modules that are specified in the
// stub_libs and contents properties of a bootclasspath_fragment. // stub_libs and contents properties of a bootclasspath_fragment.
removedDexSignatures := buildRuleToGenerateRemovedDexSignatures(ctx, suffix, input.RemovedTxtFiles) removedDexSignatures := buildRuleToGenerateRemovedDexSignatures(ctx, input.RemovedTxtFiles)
// Generate the all-flags.csv which are the flags that will, in future, be encoded into the dex // Generate the all-flags.csv which are the flags that will, in future, be encoded into the dex
// files. // files.
allFlagsCSV := android.PathForModuleOut(ctx, hiddenApiSubDir, "all-flags.csv") allFlagsCSV := android.PathForModuleOut(ctx, hiddenApiSubDir, "all-flags.csv")
buildRuleToGenerateHiddenApiFlags(ctx, "modularHiddenApiAllFlags"+suffix, "modular hiddenapi all flags"+suffix, allFlagsCSV, stubFlagsCSV, android.Paths{annotationFlagsCSV}, input.FlagFilesByCategory, nil, removedDexSignatures) buildRuleToGenerateHiddenApiFlags(ctx, "modularHiddenApiAllFlags", "modular hiddenapi all flags", allFlagsCSV, stubFlagsCSV, android.Paths{annotationFlagsCSV}, input.FlagFilesByCategory, nil, removedDexSignatures)
// Generate the filtered-stub-flags.csv file which contains the filtered stub flags that will be
// compared against the monolithic stub flags.
filteredStubFlagsCSV := android.PathForModuleOut(ctx, hiddenApiSubDir, "filtered-stub-flags.csv")
buildRuleRemoveSignaturesWithImplementationFlags(ctx, "modularHiddenApiFilteredStubFlags"+suffix,
"modular hiddenapi filtered stub flags"+suffix, stubFlagsCSV, filteredStubFlagsCSV,
HIDDENAPI_STUB_FLAGS_IMPL_FLAGS)
// Generate the filtered-flags.csv file which contains the filtered flags that will be compared
// against the monolithic flags.
filteredFlagsCSV := android.PathForModuleOut(ctx, hiddenApiSubDir, "filtered-flags.csv")
buildRuleRemoveSignaturesWithImplementationFlags(ctx, "modularHiddenApiFilteredFlags"+suffix,
"modular hiddenapi filtered flags"+suffix, allFlagsCSV, filteredFlagsCSV,
HIDDENAPI_FLAGS_CSV_IMPL_FLAGS)
// Store the paths in the info for use by other modules and sdk snapshot generation.
return HiddenAPIFlagOutput{
AnnotationFlagsPath: annotationFlagsCSV,
MetadataPath: metadataCSV,
IndexPath: indexCSV,
StubFlagsPath: stubFlagsCSV,
AllFlagsPath: allFlagsCSV,
FilteredStubFlagsPath: filteredStubFlagsCSV,
FilteredFlagsPath: filteredFlagsCSV,
}
}
func hiddenAPIEncodeRulesForBootclasspathFragment(ctx android.ModuleContext, bootDexInfoByModule bootDexInfoByModule, allFlagsCSV android.Path) bootDexJarByModule {
// Encode the flags into the boot dex files. // Encode the flags into the boot dex files.
encodedBootDexJarsByModule := bootDexJarByModule{} encodedBootDexJarsByModule := map[string]android.Path{}
outputDir := android.PathForModuleOut(ctx, "hiddenapi-modular/encoded").OutputPath outputDir := android.PathForModuleOut(ctx, "hiddenapi-modular/encoded").OutputPath
for _, name := range android.SortedStringKeys(bootDexInfoByModule) { for _, name := range android.SortedStringKeys(bootDexInfoByModule) {
bootDexInfo := bootDexInfoByModule[name] bootDexInfo := bootDexInfoByModule[name]
@@ -1151,15 +1107,43 @@ func hiddenAPIEncodeRulesForBootclasspathFragment(ctx android.ModuleContext, boo
encodedDex := hiddenAPIEncodeDex(ctx, unencodedDex, allFlagsCSV, bootDexInfo.uncompressDex, bootDexInfo.minSdkVersion, outputDir) encodedDex := hiddenAPIEncodeDex(ctx, unencodedDex, allFlagsCSV, bootDexInfo.uncompressDex, bootDexInfo.minSdkVersion, outputDir)
encodedBootDexJarsByModule[name] = encodedDex encodedBootDexJarsByModule[name] = encodedDex
} }
return encodedBootDexJarsByModule
// Generate the filtered-stub-flags.csv file which contains the filtered stub flags that will be
// compared against the monolithic stub flags.
filteredStubFlagsCSV := android.PathForModuleOut(ctx, hiddenApiSubDir, "filtered-stub-flags.csv")
buildRuleRemoveSignaturesWithImplementationFlags(ctx, "modularHiddenApiFilteredStubFlags",
"modular hiddenapi filtered stub flags", stubFlagsCSV, filteredStubFlagsCSV,
HIDDENAPI_STUB_FLAGS_IMPL_FLAGS)
// Generate the filtered-flags.csv file which contains the filtered flags that will be compared
// against the monolithic flags.
filteredFlagsCSV := android.PathForModuleOut(ctx, hiddenApiSubDir, "filtered-flags.csv")
buildRuleRemoveSignaturesWithImplementationFlags(ctx, "modularHiddenApiFilteredFlags",
"modular hiddenapi filtered flags", allFlagsCSV, filteredFlagsCSV,
HIDDENAPI_FLAGS_CSV_IMPL_FLAGS)
// Store the paths in the info for use by other modules and sdk snapshot generation.
output := HiddenAPIOutput{
HiddenAPIFlagOutput: HiddenAPIFlagOutput{
AnnotationFlagsPath: annotationFlagsCSV,
MetadataPath: metadataCSV,
IndexPath: indexCSV,
StubFlagsPath: stubFlagsCSV,
AllFlagsPath: allFlagsCSV,
FilteredStubFlagsPath: filteredStubFlagsCSV,
FilteredFlagsPath: filteredFlagsCSV,
},
EncodedBootDexFilesByModule: encodedBootDexJarsByModule,
}
return &output
} }
func buildRuleToGenerateRemovedDexSignatures(ctx android.ModuleContext, suffix string, removedTxtFiles android.Paths) android.OptionalPath { func buildRuleToGenerateRemovedDexSignatures(ctx android.ModuleContext, removedTxtFiles android.Paths) android.OptionalPath {
if len(removedTxtFiles) == 0 { if len(removedTxtFiles) == 0 {
return android.OptionalPath{} return android.OptionalPath{}
} }
output := android.PathForModuleOut(ctx, "module-hiddenapi"+suffix, "removed-dex-signatures.txt") output := android.PathForModuleOut(ctx, "modular-hiddenapi/removed-dex-signatures.txt")
rule := android.NewRuleBuilder(pctx, ctx) rule := android.NewRuleBuilder(pctx, ctx)
rule.Command(). rule.Command().
@@ -1167,7 +1151,7 @@ func buildRuleToGenerateRemovedDexSignatures(ctx android.ModuleContext, suffix s
Flag("--no-banner"). Flag("--no-banner").
Inputs(removedTxtFiles). Inputs(removedTxtFiles).
FlagWithOutput("--dex-api ", output) FlagWithOutput("--dex-api ", output)
rule.Build("modular-hiddenapi-removed-dex-signatures"+suffix, "modular hiddenapi removed dex signatures"+suffix) rule.Build("modular-hiddenapi-removed-dex-signatures", "modular hiddenapi removed dex signatures")
return android.OptionalPathForPath(output) return android.OptionalPathForPath(output)
} }

View File

@@ -216,13 +216,13 @@ class FlagsDict:
def _check_entries_set(self, keys_subset, source): def _check_entries_set(self, keys_subset, source):
assert isinstance(keys_subset, set) assert isinstance(keys_subset, set)
# assert keys_subset.issubset(self._dict_keyset), ( assert keys_subset.issubset(self._dict_keyset), (
# 'Error: {} specifies signatures not present in code:\n' 'Error: {} specifies signatures not present in code:\n'
# '{}' '{}'
# 'Please visit go/hiddenapi for more information.').format( 'Please visit go/hiddenapi for more information.').format(
# source, ''.join( source, ''.join(
# [' ' + str(x) + '\n' for x in [' ' + str(x) + '\n' for x in
# keys_subset - self._dict_keyset])) keys_subset - self._dict_keyset]))
def _check_flags_set(self, flags_subset, source): def _check_flags_set(self, flags_subset, source):
assert isinstance(flags_subset, set) assert isinstance(flags_subset, set)
@@ -330,7 +330,6 @@ class FlagsDict:
# Iterate over the API subset, find each entry in dict and assign the # Iterate over the API subset, find each entry in dict and assign the
# flag to it. # flag to it.
for api in apis: for api in apis:
if api in self._dict:
self._dict[api].add(flag) self._dict[api].add(flag)
if tag: if tag:
self._dict[api].add(tag) self._dict[api].add(tag)

View File

@@ -92,8 +92,8 @@ class TestHiddenapiListGeneration(unittest.TestCase):
) )
# Test invalid API signature. # Test invalid API signature.
# with self.assertRaises(AssertionError): with self.assertRaises(AssertionError):
# flags.assign_flag(FLAG_SDK, set(['C'])) flags.assign_flag(FLAG_SDK, set(['C']))
# Test invalid flag. # Test invalid flag.
with self.assertRaises(AssertionError): with self.assertRaises(AssertionError):

View File

@@ -847,222 +847,3 @@ my-unsupported-packages.txt -> hiddenapi/my-unsupported-packages.txt
snapshotTestPreparer(checkSnapshotPreferredWithSource, preparerForSnapshot), snapshotTestPreparer(checkSnapshotPreferredWithSource, preparerForSnapshot),
) )
} }
func testSnapshotWithBootClasspathFragment_MinSdkVersion(t *testing.T, targetBuildRelease string,
expectedSdkSnapshot string,
expectedCopyRules string,
expectedStubFlagsInputs []string,
suffix string) {
result := android.GroupFixturePreparers(
prepareForSdkTestWithJava,
java.PrepareForTestWithJavaDefaultModules,
java.PrepareForTestWithJavaSdkLibraryFiles,
java.FixtureWithLastReleaseApis("mysdklibrary", "mynewsdklibrary"),
java.FixtureConfigureApexBootJars("myapex:mysdklibrary", "myapex:mynewsdklibrary"),
prepareForSdkTestWithApex,
// Add a platform_bootclasspath that depends on the fragment.
fixtureAddPlatformBootclasspathForBootclasspathFragment("myapex", "mybootclasspathfragment"),
android.FixtureMergeEnv(map[string]string{
"SOONG_SDK_SNAPSHOT_TARGET_BUILD_RELEASE": targetBuildRelease,
}),
android.FixtureWithRootAndroidBp(`
sdk {
name: "mysdk",
apexes: ["myapex"],
}
apex {
name: "myapex",
key: "myapex.key",
min_sdk_version: "S",
bootclasspath_fragments: ["mybootclasspathfragment"],
}
bootclasspath_fragment {
name: "mybootclasspathfragment",
apex_available: ["myapex"],
contents: [
"mysdklibrary",
"mynewsdklibrary",
],
hidden_api: {
split_packages: [],
},
}
java_sdk_library {
name: "mysdklibrary",
apex_available: ["myapex"],
srcs: ["Test.java"],
shared_library: false,
public: {enabled: true},
min_sdk_version: "S",
}
java_sdk_library {
name: "mynewsdklibrary",
apex_available: ["myapex"],
srcs: ["Test.java"],
compile_dex: true,
public: {enabled: true},
min_sdk_version: "Tiramisu",
permitted_packages: ["mynewsdklibrary"],
}
`),
).RunTest(t)
bcpf := result.ModuleForTests("mybootclasspathfragment", "android_common")
rule := bcpf.Output("out/soong/.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi" + suffix + "/stub-flags.csv")
android.AssertPathsRelativeToTopEquals(t, "stub flags inputs", expectedStubFlagsInputs, rule.Implicits)
CheckSnapshot(t, result, "mysdk", "",
checkAndroidBpContents(expectedSdkSnapshot),
checkAllCopyRules(expectedCopyRules),
)
}
func TestSnapshotWithBootClasspathFragment_MinSdkVersion(t *testing.T) {
t.Run("target S build", func(t *testing.T) {
expectedSnapshot := `
// This is auto-generated. DO NOT EDIT.
prebuilt_bootclasspath_fragment {
name: "mybootclasspathfragment",
prefer: false,
visibility: ["//visibility:public"],
apex_available: ["myapex"],
contents: ["mysdklibrary"],
hidden_api: {
annotation_flags: "hiddenapi/annotation-flags.csv",
metadata: "hiddenapi/metadata.csv",
index: "hiddenapi/index.csv",
stub_flags: "hiddenapi/stub-flags.csv",
all_flags: "hiddenapi/all-flags.csv",
},
}
java_sdk_library_import {
name: "mysdklibrary",
prefer: false,
visibility: ["//visibility:public"],
apex_available: ["myapex"],
shared_library: false,
public: {
jars: ["sdk_library/public/mysdklibrary-stubs.jar"],
stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"],
current_api: "sdk_library/public/mysdklibrary.txt",
removed_api: "sdk_library/public/mysdklibrary-removed.txt",
sdk_version: "current",
},
}
`
expectedCopyRules := `
.intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi-for-sdk-snapshot/annotation-flags.csv -> hiddenapi/annotation-flags.csv
.intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi-for-sdk-snapshot/metadata.csv -> hiddenapi/metadata.csv
.intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi-for-sdk-snapshot/index.csv -> hiddenapi/index.csv
.intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi-for-sdk-snapshot/stub-flags.csv -> hiddenapi/stub-flags.csv
.intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi-for-sdk-snapshot/all-flags.csv -> hiddenapi/all-flags.csv
.intermediates/mysdklibrary.stubs/android_common/javac/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar
.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt
.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt
`
// On S the stub flags should only be generated from mysdklibrary as mynewsdklibrary is not part
// of the snapshot.
expectedStubFlagsInputs := []string{
"out/soong/.intermediates/mysdklibrary.stubs/android_common/dex/mysdklibrary.stubs.jar",
"out/soong/.intermediates/mysdklibrary/android_common/aligned/mysdklibrary.jar",
}
testSnapshotWithBootClasspathFragment_MinSdkVersion(t, "S",
expectedSnapshot, expectedCopyRules, expectedStubFlagsInputs, "-for-sdk-snapshot")
})
t.Run("target-Tiramisu-build", func(t *testing.T) {
expectedSnapshot := `
// This is auto-generated. DO NOT EDIT.
prebuilt_bootclasspath_fragment {
name: "mybootclasspathfragment",
prefer: false,
visibility: ["//visibility:public"],
apex_available: ["myapex"],
contents: [
"mysdklibrary",
"mynewsdklibrary",
],
hidden_api: {
annotation_flags: "hiddenapi/annotation-flags.csv",
metadata: "hiddenapi/metadata.csv",
index: "hiddenapi/index.csv",
signature_patterns: "hiddenapi/signature-patterns.csv",
filtered_stub_flags: "hiddenapi/filtered-stub-flags.csv",
filtered_flags: "hiddenapi/filtered-flags.csv",
},
}
java_sdk_library_import {
name: "mysdklibrary",
prefer: false,
visibility: ["//visibility:public"],
apex_available: ["myapex"],
shared_library: false,
public: {
jars: ["sdk_library/public/mysdklibrary-stubs.jar"],
stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"],
current_api: "sdk_library/public/mysdklibrary.txt",
removed_api: "sdk_library/public/mysdklibrary-removed.txt",
sdk_version: "current",
},
}
java_sdk_library_import {
name: "mynewsdklibrary",
prefer: false,
visibility: ["//visibility:public"],
apex_available: ["myapex"],
shared_library: true,
compile_dex: true,
permitted_packages: ["mynewsdklibrary"],
public: {
jars: ["sdk_library/public/mynewsdklibrary-stubs.jar"],
stub_srcs: ["sdk_library/public/mynewsdklibrary_stub_sources"],
current_api: "sdk_library/public/mynewsdklibrary.txt",
removed_api: "sdk_library/public/mynewsdklibrary-removed.txt",
sdk_version: "current",
},
}
`
expectedCopyRules := `
.intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/annotation-flags.csv -> hiddenapi/annotation-flags.csv
.intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/metadata.csv -> hiddenapi/metadata.csv
.intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/index.csv -> hiddenapi/index.csv
.intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/signature-patterns.csv -> hiddenapi/signature-patterns.csv
.intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/filtered-stub-flags.csv -> hiddenapi/filtered-stub-flags.csv
.intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/filtered-flags.csv -> hiddenapi/filtered-flags.csv
.intermediates/mysdklibrary.stubs/android_common/javac/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar
.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt
.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt
.intermediates/mynewsdklibrary.stubs/android_common/javac/mynewsdklibrary.stubs.jar -> sdk_library/public/mynewsdklibrary-stubs.jar
.intermediates/mynewsdklibrary.stubs.source/android_common/metalava/mynewsdklibrary.stubs.source_api.txt -> sdk_library/public/mynewsdklibrary.txt
.intermediates/mynewsdklibrary.stubs.source/android_common/metalava/mynewsdklibrary.stubs.source_removed.txt -> sdk_library/public/mynewsdklibrary-removed.txt
`
// On tiramisu the stub flags should be generated from both mynewsdklibrary and mysdklibrary as
// they are both part of the snapshot.
expectedStubFlagsInputs := []string{
"out/soong/.intermediates/mynewsdklibrary.stubs/android_common/dex/mynewsdklibrary.stubs.jar",
"out/soong/.intermediates/mynewsdklibrary/android_common/aligned/mynewsdklibrary.jar",
"out/soong/.intermediates/mysdklibrary.stubs/android_common/dex/mysdklibrary.stubs.jar",
"out/soong/.intermediates/mysdklibrary/android_common/aligned/mysdklibrary.jar",
}
testSnapshotWithBootClasspathFragment_MinSdkVersion(t, "Tiramisu",
expectedSnapshot, expectedCopyRules, expectedStubFlagsInputs, "")
})
}

View File

@@ -183,7 +183,6 @@ func (gf *generatedFile) build(pctx android.PackageContext, ctx android.BuilderC
// multilibs (32/64/both) are used by this sdk variant. // multilibs (32/64/both) are used by this sdk variant.
func (s *sdk) collectMembers(ctx android.ModuleContext) { func (s *sdk) collectMembers(ctx android.ModuleContext) {
s.multilibUsages = multilibNone s.multilibUsages = multilibNone
ctx.WalkDeps(func(child android.Module, parent android.Module) bool { ctx.WalkDeps(func(child android.Module, parent android.Module) bool {
tag := ctx.OtherModuleDependencyTag(child) tag := ctx.OtherModuleDependencyTag(child)
if memberTag, ok := tag.(android.SdkMemberDependencyTag); ok { if memberTag, ok := tag.(android.SdkMemberDependencyTag); ok {
@@ -212,14 +211,11 @@ func (s *sdk) collectMembers(ctx android.ModuleContext) {
container = parent.(android.SdkAware) container = parent.(android.SdkAware)
} }
minApiLevel := android.MinApiLevelForSdkSnapshot(ctx, child)
export := memberTag.ExportMember() export := memberTag.ExportMember()
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.SdkAware),
minApiLevel: minApiLevel,
container: container, container: container,
export: export, export: export,
exportedComponentsInfo: exportedComponentsInfo, exportedComponentsInfo: exportedComponentsInfo,
@@ -336,29 +332,10 @@ const BUILD_NUMBER_FILE = "snapshot-creation-build-number.txt"
// <arch>/lib/ // <arch>/lib/
// libFoo.so : a stub library // libFoo.so : a stub library
func (s sdk) targetBuildRelease(ctx android.ModuleContext) *buildRelease {
config := ctx.Config()
currentBuildRelease := latestBuildRelease()
targetBuildReleaseEnv := config.GetenvWithDefault("SOONG_SDK_SNAPSHOT_TARGET_BUILD_RELEASE", currentBuildRelease.name)
targetBuildRelease, err := nameToRelease(targetBuildReleaseEnv)
if err != nil {
ctx.ModuleErrorf("invalid SOONG_SDK_SNAPSHOT_TARGET_BUILD_RELEASE: %s", err)
targetBuildRelease = currentBuildRelease
}
return targetBuildRelease
}
// buildSnapshot is the main function in this source file. It creates rules to copy // buildSnapshot is the main function in this source file. It creates rules to copy
// the contents (header files, stub libraries, etc) into the zip file. // the contents (header files, stub libraries, etc) into the zip file.
func (s *sdk) buildSnapshot(ctx android.ModuleContext, sdkVariants []*sdk) { func (s *sdk) buildSnapshot(ctx android.ModuleContext, sdkVariants []*sdk) {
targetBuildRelease := s.targetBuildRelease(ctx)
targetApiLevel, err := android.ApiLevelFromUser(ctx, targetBuildRelease.name)
if err != nil {
targetApiLevel = android.FutureApiLevel
}
// Aggregate all the sdkMemberVariantDep instances from all the sdk variants. // Aggregate all the sdkMemberVariantDep instances from all the sdk variants.
hasLicenses := false hasLicenses := false
var memberVariantDeps []sdkMemberVariantDep var memberVariantDeps []sdkMemberVariantDep
@@ -369,18 +346,12 @@ func (s *sdk) buildSnapshot(ctx android.ModuleContext, sdkVariants []*sdk) {
// Filter out any sdkMemberVariantDep that is a component of another. // Filter out any sdkMemberVariantDep that is a component of another.
memberVariantDeps = filterOutComponents(ctx, memberVariantDeps) memberVariantDeps = filterOutComponents(ctx, memberVariantDeps)
// Record the names of all the members, both explicitly specified and implicitly included. Also, // Record the names of all the members, both explicitly specified and implicitly
// record the names of any members that should be excluded from this snapshot. // included.
allMembersByName := make(map[string]struct{}) allMembersByName := make(map[string]struct{})
exportedMembersByName := make(map[string]struct{}) exportedMembersByName := make(map[string]struct{})
excludedMembersByName := make(map[string]struct{})
addMember := func(name string, export bool, exclude bool) {
if exclude {
excludedMembersByName[name] = struct{}{}
return
}
addMember := func(name string, export bool) {
allMembersByName[name] = struct{}{} allMembersByName[name] = struct{}{}
if export { if export {
exportedMembersByName[name] = struct{}{} exportedMembersByName[name] = struct{}{}
@@ -391,15 +362,11 @@ func (s *sdk) buildSnapshot(ctx android.ModuleContext, sdkVariants []*sdk) {
name := memberVariantDep.variant.Name() name := memberVariantDep.variant.Name()
export := memberVariantDep.export export := memberVariantDep.export
// If the minApiLevel of the member is greater than the target API level then exclude it from addMember(name, export)
// this snapshot.
exclude := memberVariantDep.minApiLevel.GreaterThan(targetApiLevel)
addMember(name, export, exclude)
// Add any components provided by the module. // Add any components provided by the module.
for _, component := range memberVariantDep.exportedComponentsInfo.Components { for _, component := range memberVariantDep.exportedComponentsInfo.Components {
addMember(component, export, exclude) addMember(component, export)
} }
if memberVariantDep.memberType == android.LicenseModuleSdkMemberType { if memberVariantDep.memberType == android.LicenseModuleSdkMemberType {
@@ -415,9 +382,19 @@ func (s *sdk) buildSnapshot(ctx android.ModuleContext, sdkVariants []*sdk) {
modules: make(map[string]*bpModule), modules: make(map[string]*bpModule),
} }
config := ctx.Config()
// Always add -current to the end // Always add -current to the end
snapshotFileSuffix := "-current" snapshotFileSuffix := "-current"
currentBuildRelease := latestBuildRelease()
targetBuildReleaseEnv := config.GetenvWithDefault("SOONG_SDK_SNAPSHOT_TARGET_BUILD_RELEASE", currentBuildRelease.name)
targetBuildRelease, err := nameToRelease(targetBuildReleaseEnv)
if err != nil {
ctx.ModuleErrorf("invalid SOONG_SDK_SNAPSHOT_TARGET_BUILD_RELEASE: %s", err)
targetBuildRelease = currentBuildRelease
}
builder := &snapshotBuilder{ builder := &snapshotBuilder{
ctx: ctx, ctx: ctx,
sdk: s, sdk: s,
@@ -428,7 +405,6 @@ func (s *sdk) buildSnapshot(ctx android.ModuleContext, sdkVariants []*sdk) {
prebuiltModules: make(map[string]*bpModule), prebuiltModules: make(map[string]*bpModule),
allMembersByName: allMembersByName, allMembersByName: allMembersByName,
exportedMembersByName: exportedMembersByName, exportedMembersByName: exportedMembersByName,
excludedMembersByName: excludedMembersByName,
targetBuildRelease: targetBuildRelease, targetBuildRelease: targetBuildRelease,
} }
s.builderForTests = builder s.builderForTests = builder
@@ -462,10 +438,6 @@ be unnecessary as every module in the sdk already has its own licenses property.
} }
name := member.name name := member.name
if _, ok := excludedMembersByName[name]; ok {
continue
}
requiredTraits := traits[name] requiredTraits := traits[name]
if requiredTraits == nil { if requiredTraits == nil {
requiredTraits = android.EmptySdkMemberTraitSet() requiredTraits = android.EmptySdkMemberTraitSet()
@@ -500,7 +472,7 @@ be unnecessary as every module in the sdk already has its own licenses property.
contents := bp.content.String() contents := bp.content.String()
// If the snapshot is being generated for the current build release then check the syntax to make // If the snapshot is being generated for the current build release then check the syntax to make
// sure that it is compatible. // sure that it is compatible.
if targetBuildRelease == latestBuildRelease() { if targetBuildRelease == currentBuildRelease {
syntaxCheckSnapshotBpFile(ctx, contents) syntaxCheckSnapshotBpFile(ctx, contents)
} }
@@ -1063,9 +1035,6 @@ type snapshotBuilder struct {
// The set of exported members by name. // The set of exported members by name.
exportedMembersByName map[string]struct{} exportedMembersByName map[string]struct{}
// The set of members which have been excluded from this snapshot; by name.
excludedMembersByName map[string]struct{}
// The target build release for which the snapshot is to be generated. // The target build release for which the snapshot is to be generated.
targetBuildRelease *buildRelease targetBuildRelease *buildRelease
@@ -1250,9 +1219,6 @@ func (s *snapshotBuilder) snapshotSdkMemberName(name string, required bool) stri
func (s *snapshotBuilder) snapshotSdkMemberNames(members []string, required bool) []string { func (s *snapshotBuilder) snapshotSdkMemberNames(members []string, required bool) []string {
var references []string = nil var references []string = nil
for _, m := range members { for _, m := range members {
if _, ok := s.excludedMembersByName[m]; ok {
continue
}
references = append(references, s.snapshotSdkMemberName(m, required)) references = append(references, s.snapshotSdkMemberName(m, required))
} }
return references return references
@@ -1295,9 +1261,6 @@ type sdkMemberVariantDep struct {
// The names of additional component modules provided by the variant. // The names of additional component modules provided by the variant.
exportedComponentsInfo android.ExportedComponentsInfo exportedComponentsInfo android.ExportedComponentsInfo
// The minimum API level on which this module is supported.
minApiLevel android.ApiLevel
} }
var _ android.SdkMember = (*sdkMember)(nil) var _ android.SdkMember = (*sdkMember)(nil)