Merge "hiddenapi: Prevent libraries for Q/R from include S+ flags." am: a09d95f605
am: c06a700dcc
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2079360 Change-Id: I47fca3348146cddbc042acb5fbfeea9dbfb7bb4c Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
64d5a525f4
3 changed files with 25 additions and 3 deletions
|
@ -65,6 +65,8 @@ func (h *hiddenAPI) uncompressDex() *bool {
|
|||
type hiddenAPIModule interface {
|
||||
android.Module
|
||||
hiddenAPIIntf
|
||||
|
||||
MinSdkVersion(ctx android.EarlyModuleContext) android.SdkSpec
|
||||
}
|
||||
|
||||
type hiddenAPIIntf interface {
|
||||
|
@ -148,7 +150,7 @@ func (h *hiddenAPI) hiddenAPIEncodeDex(ctx android.ModuleContext, dexJar android
|
|||
// Create a copy of the dex jar which has been encoded with hiddenapi flags.
|
||||
flagsCSV := hiddenAPISingletonPaths(ctx).flags
|
||||
outputDir := android.PathForModuleOut(ctx, "hiddenapi").OutputPath
|
||||
encodedDex := hiddenAPIEncodeDex(ctx, dexJar, flagsCSV, uncompressDex, outputDir)
|
||||
encodedDex := hiddenAPIEncodeDex(ctx, dexJar, flagsCSV, uncompressDex, android.SdkSpecNone, outputDir)
|
||||
|
||||
// Use the encoded dex jar from here onwards.
|
||||
return encodedDex
|
||||
|
@ -246,7 +248,7 @@ var hiddenAPIEncodeDexRule = pctx.AndroidStaticRule("hiddenAPIEncodeDex", bluepr
|
|||
// The encode dex rule requires unzipping, encoding and rezipping the classes.dex files along with
|
||||
// all the resources from the input jar. It also ensures that if it was uncompressed in the input
|
||||
// it stays uncompressed in the output.
|
||||
func hiddenAPIEncodeDex(ctx android.ModuleContext, dexInput, flagsCSV android.Path, uncompressDex bool, outputDir android.OutputPath) android.OutputPath {
|
||||
func hiddenAPIEncodeDex(ctx android.ModuleContext, dexInput, flagsCSV android.Path, uncompressDex bool, minSdkVersion android.SdkSpec, outputDir android.OutputPath) android.OutputPath {
|
||||
|
||||
// The output file has the same name as the input file and is in the output directory.
|
||||
output := outputDir.Join(ctx, dexInput.Base())
|
||||
|
@ -274,6 +276,15 @@ func hiddenAPIEncodeDex(ctx android.ModuleContext, dexInput, flagsCSV android.Pa
|
|||
hiddenapiFlags = "--no-force-assign-all"
|
||||
}
|
||||
|
||||
// If the library is targeted for Q and/or R then make sure that they do not
|
||||
// have any S+ flags encoded as that will break the runtime.
|
||||
minApiLevel := minSdkVersion.ApiLevel
|
||||
if !minApiLevel.IsNone() {
|
||||
if minApiLevel.LessThanOrEqualTo(android.ApiLevelOrPanic(ctx, "R")) {
|
||||
hiddenapiFlags = hiddenapiFlags + " --max-hiddenapi-level=max-target-r"
|
||||
}
|
||||
}
|
||||
|
||||
ctx.Build(pctx, android.BuildParams{
|
||||
Rule: hiddenAPIEncodeDexRule,
|
||||
Description: "hiddenapi encode dex",
|
||||
|
|
|
@ -1104,7 +1104,7 @@ func hiddenAPIRulesForBootclasspathFragment(ctx android.ModuleContext, contents
|
|||
for _, name := range android.SortedStringKeys(bootDexInfoByModule) {
|
||||
bootDexInfo := bootDexInfoByModule[name]
|
||||
unencodedDex := bootDexInfo.path
|
||||
encodedDex := hiddenAPIEncodeDex(ctx, unencodedDex, allFlagsCSV, bootDexInfo.uncompressDex, outputDir)
|
||||
encodedDex := hiddenAPIEncodeDex(ctx, unencodedDex, allFlagsCSV, bootDexInfo.uncompressDex, bootDexInfo.minSdkVersion, outputDir)
|
||||
encodedBootDexJarsByModule[name] = encodedDex
|
||||
}
|
||||
|
||||
|
@ -1188,6 +1188,9 @@ type bootDexInfo struct {
|
|||
|
||||
// Indicates whether the dex jar needs uncompressing before encoding.
|
||||
uncompressDex bool
|
||||
|
||||
// The minimum sdk version that the dex jar will be used on.
|
||||
minSdkVersion android.SdkSpec
|
||||
}
|
||||
|
||||
// bootDexInfoByModule is a map from module name (as returned by module.Name()) to the boot dex
|
||||
|
@ -1213,6 +1216,7 @@ func extractBootDexInfoFromModules(ctx android.ModuleContext, contents []android
|
|||
bootDexJarsByModule[module.Name()] = bootDexInfo{
|
||||
path: bootDexJar,
|
||||
uncompressDex: *hiddenAPIModule.uncompressDex(),
|
||||
minSdkVersion: hiddenAPIModule.MinSdkVersion(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2223,6 +2223,13 @@ func (module *SdkLibraryImport) UniqueApexVariations() bool {
|
|||
return module.uniqueApexVariations()
|
||||
}
|
||||
|
||||
// MinSdkVersion - Implements hiddenAPIModule
|
||||
func (module *SdkLibraryImport) MinSdkVersion(ctx android.EarlyModuleContext) android.SdkSpec {
|
||||
return android.SdkSpecNone
|
||||
}
|
||||
|
||||
var _ hiddenAPIModule = (*SdkLibraryImport)(nil)
|
||||
|
||||
func (module *SdkLibraryImport) OutputFiles(tag string) (android.Paths, error) {
|
||||
return module.commonOutputFiles(tag)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue