Merge Android 24Q2 Release (ab/11526283) to aosp-main-future

Bug: 337098550
Merged-In: I4a6dd1c5e48db7085ea41035def31f0844948a46
Change-Id: If8ad1d0d87495bbd685f5f9f03f5eb7ea78bf192
This commit is contained in:
Xin Li 2024-05-24 08:25:18 -07:00
commit 8a31520ef8
7 changed files with 264 additions and 261 deletions

View file

@ -33,4 +33,4 @@ package android
// * AOSP - xx9990000 // * AOSP - xx9990000
// * x-mainline-prod - xx9990000 // * x-mainline-prod - xx9990000
// * master - 990090000 // * master - 990090000
const DefaultUpdatableModuleVersion = "990090000" const DefaultUpdatableModuleVersion = "350090000"

View file

@ -181,8 +181,9 @@ type variableProperties struct {
// release_aidl_use_unfrozen is "true" when a device can // release_aidl_use_unfrozen is "true" when a device can
// use the unfrozen versions of AIDL interfaces. // use the unfrozen versions of AIDL interfaces.
Release_aidl_use_unfrozen struct { Release_aidl_use_unfrozen struct {
Cflags []string Cflags []string
Cmd *string Cmd *string
Vintf_fragments []string
} }
} `android:"arch_variant"` } `android:"arch_variant"`
} }

View file

@ -18,7 +18,6 @@ package apex
import ( import (
"fmt" "fmt"
"log"
"path/filepath" "path/filepath"
"regexp" "regexp"
"sort" "sort"
@ -994,10 +993,8 @@ func (a *apexBundle) ApexInfoMutator(mctx android.TopDownMutatorContext) {
} }
} }
//TODO: b/296491928 Vendor APEX should use libbinder.ndk instead of libbinder once VNDK is fully deprecated.
if useVndk && mctx.Config().IsVndkDeprecated() && child.Name() == "libbinder" { if useVndk && mctx.Config().IsVndkDeprecated() && child.Name() == "libbinder" {
log.Print("Libbinder is linked from Vendor APEX ", a.Name(), " with module ", parent.Name()) mctx.ModuleErrorf("Module %s in the vendor APEX %s should not use libbinder. Use libbinder_ndk instead.", parent.Name(), a.Name())
return false
} }
// By default, all the transitive dependencies are collected, unless filtered out // By default, all the transitive dependencies are collected, unless filtered out
@ -2198,10 +2195,6 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext,
return false return false
} }
//TODO: b/296491928 Vendor APEX should use libbinder.ndk instead of libbinder once VNDK is fully deprecated.
if ch.InVendorOrProduct() && ctx.Config().IsVndkDeprecated() && child.Name() == "libbinder" {
return false
}
af := apexFileForNativeLibrary(ctx, ch, vctx.handleSpecialLibs) af := apexFileForNativeLibrary(ctx, ch, vctx.handleSpecialLibs)
af.transitiveDep = true af.transitiveDep = true

View file

@ -9807,188 +9807,196 @@ func ensureDoesNotContainRequiredDeps(t *testing.T, ctx *android.TestContext, mo
} }
} }
// TODO(b/193460475): Re-enable this test func TestApexStrictUpdtabilityLint(t *testing.T) {
//func TestApexStrictUpdtabilityLint(t *testing.T) { bpTemplate := `
// bpTemplate := ` apex {
// apex { name: "myapex",
// name: "myapex", key: "myapex.key",
// key: "myapex.key", java_libs: ["myjavalib"],
// java_libs: ["myjavalib"], updatable: %v,
// updatable: %v, min_sdk_version: "29",
// min_sdk_version: "29", }
// } apex_key {
// apex_key { name: "myapex.key",
// name: "myapex.key", }
// } java_library {
// java_library { name: "myjavalib",
// name: "myjavalib", srcs: ["MyClass.java"],
// srcs: ["MyClass.java"], apex_available: [ "myapex" ],
// apex_available: [ "myapex" ], lint: {
// lint: { strict_updatability_linting: %v,
// strict_updatability_linting: %v, %s
// }, },
// sdk_version: "current", sdk_version: "current",
// min_sdk_version: "29", min_sdk_version: "29",
// } }
// ` `
// fs := android.MockFS{ fs := android.MockFS{
// "lint-baseline.xml": nil, "lint-baseline.xml": nil,
// } }
//
// testCases := []struct { testCases := []struct {
// testCaseName string testCaseName string
// apexUpdatable bool apexUpdatable bool
// javaStrictUpdtabilityLint bool javaStrictUpdtabilityLint bool
// lintFileExists bool lintFileExists bool
// disallowedFlagExpected bool disallowedFlagExpected bool
// }{ }{
// { {
// testCaseName: "lint-baseline.xml does not exist, no disallowed flag necessary in lint cmd", testCaseName: "lint-baseline.xml does not exist, no disallowed flag necessary in lint cmd",
// apexUpdatable: true, apexUpdatable: true,
// javaStrictUpdtabilityLint: true, javaStrictUpdtabilityLint: true,
// lintFileExists: false, lintFileExists: false,
// disallowedFlagExpected: false, disallowedFlagExpected: false,
// }, },
// { {
// testCaseName: "non-updatable apex respects strict_updatability of javalib", testCaseName: "non-updatable apex respects strict_updatability of javalib",
// apexUpdatable: false, apexUpdatable: false,
// javaStrictUpdtabilityLint: false, javaStrictUpdtabilityLint: false,
// lintFileExists: true, lintFileExists: true,
// disallowedFlagExpected: false, disallowedFlagExpected: false,
// }, },
// { {
// testCaseName: "non-updatable apex respects strict updatability of javalib", testCaseName: "non-updatable apex respects strict updatability of javalib",
// apexUpdatable: false, apexUpdatable: false,
// javaStrictUpdtabilityLint: true, javaStrictUpdtabilityLint: true,
// lintFileExists: true, lintFileExists: true,
// disallowedFlagExpected: true, disallowedFlagExpected: true,
// }, },
// { {
// testCaseName: "updatable apex sets strict updatability of javalib to true", testCaseName: "updatable apex sets strict updatability of javalib to true",
// apexUpdatable: true, apexUpdatable: true,
// javaStrictUpdtabilityLint: false, // will be set to true by mutator javaStrictUpdtabilityLint: false, // will be set to true by mutator
// lintFileExists: true, lintFileExists: true,
// disallowedFlagExpected: true, disallowedFlagExpected: true,
// }, },
// } }
//
// for _, testCase := range testCases { for _, testCase := range testCases {
// bp := fmt.Sprintf(bpTemplate, testCase.apexUpdatable, testCase.javaStrictUpdtabilityLint) fixtures := []android.FixturePreparer{}
// fixtures := []android.FixturePreparer{} baselineProperty := ""
// if testCase.lintFileExists { if testCase.lintFileExists {
// fixtures = append(fixtures, fs.AddToFixture()) fixtures = append(fixtures, fs.AddToFixture())
// } baselineProperty = "baseline_filename: \"lint-baseline.xml\""
// }
// result := testApex(t, bp, fixtures...) bp := fmt.Sprintf(bpTemplate, testCase.apexUpdatable, testCase.javaStrictUpdtabilityLint, baselineProperty)
// myjavalib := result.ModuleForTests("myjavalib", "android_common_apex29")
// sboxProto := android.RuleBuilderSboxProtoForTests(t, myjavalib.Output("lint.sbox.textproto")) result := testApex(t, bp, fixtures...)
// disallowedFlagActual := strings.Contains(*sboxProto.Commands[0].Command, "--baseline lint-baseline.xml --disallowed_issues NewApi") myjavalib := result.ModuleForTests("myjavalib", "android_common_apex29")
// sboxProto := android.RuleBuilderSboxProtoForTests(t, result, myjavalib.Output("lint.sbox.textproto"))
// if disallowedFlagActual != testCase.disallowedFlagExpected { disallowedFlagActual := strings.Contains(*sboxProto.Commands[0].Command, "--baseline lint-baseline.xml --disallowed_issues NewApi")
// t.Errorf("Failed testcase: %v \nActual lint cmd: %v", testCase.testCaseName, *sboxProto.Commands[0].Command)
// } if disallowedFlagActual != testCase.disallowedFlagExpected {
// } t.Errorf("Failed testcase: %v \nActual lint cmd: %v", testCase.testCaseName, *sboxProto.Commands[0].Command)
//} }
// }
//func TestUpdatabilityLintSkipLibcore(t *testing.T) { }
// bp := `
// apex { func TestUpdatabilityLintSkipLibcore(t *testing.T) {
// name: "myapex", bp := `
// key: "myapex.key", apex {
// java_libs: ["myjavalib"], name: "myapex",
// updatable: true, key: "myapex.key",
// min_sdk_version: "29", java_libs: ["myjavalib"],
// } updatable: true,
// apex_key { min_sdk_version: "29",
// name: "myapex.key", }
// } apex_key {
// java_library { name: "myapex.key",
// name: "myjavalib", }
// srcs: ["MyClass.java"], java_library {
// apex_available: [ "myapex" ], name: "myjavalib",
// sdk_version: "current", srcs: ["MyClass.java"],
// min_sdk_version: "29", apex_available: [ "myapex" ],
// } sdk_version: "current",
// ` min_sdk_version: "29",
// lint: {
// testCases := []struct { baseline_filename: "lint-baseline.xml",
// testCaseName string }
// moduleDirectory string }
// disallowedFlagExpected bool `
// }{
// { testCases := []struct {
// testCaseName: "lintable module defined outside libcore", testCaseName string
// moduleDirectory: "", moduleDirectory string
// disallowedFlagExpected: true, disallowedFlagExpected bool
// }, }{
// { {
// testCaseName: "lintable module defined in libcore root directory", testCaseName: "lintable module defined outside libcore",
// moduleDirectory: "libcore/", moduleDirectory: "",
// disallowedFlagExpected: false, disallowedFlagExpected: true,
// }, },
// { {
// testCaseName: "lintable module defined in libcore child directory", testCaseName: "lintable module defined in libcore root directory",
// moduleDirectory: "libcore/childdir/", moduleDirectory: "libcore/",
// disallowedFlagExpected: true, disallowedFlagExpected: false,
// }, },
// } {
// testCaseName: "lintable module defined in libcore child directory",
// for _, testCase := range testCases { moduleDirectory: "libcore/childdir/",
// lintFileCreator := android.FixtureAddTextFile(testCase.moduleDirectory+"lint-baseline.xml", "") disallowedFlagExpected: true,
// bpFileCreator := android.FixtureAddTextFile(testCase.moduleDirectory+"Android.bp", bp) },
// result := testApex(t, "", lintFileCreator, bpFileCreator) }
// myjavalib := result.ModuleForTests("myjavalib", "android_common_apex29")
// sboxProto := android.RuleBuilderSboxProtoForTests(t, myjavalib.Output("lint.sbox.textproto")) for _, testCase := range testCases {
// cmdFlags := fmt.Sprintf("--baseline %vlint-baseline.xml --disallowed_issues NewApi", testCase.moduleDirectory) lintFileCreator := android.FixtureAddTextFile(testCase.moduleDirectory+"lint-baseline.xml", "")
// disallowedFlagActual := strings.Contains(*sboxProto.Commands[0].Command, cmdFlags) bpFileCreator := android.FixtureAddTextFile(testCase.moduleDirectory+"Android.bp", bp)
// result := testApex(t, "", lintFileCreator, bpFileCreator)
// if disallowedFlagActual != testCase.disallowedFlagExpected { myjavalib := result.ModuleForTests("myjavalib", "android_common_apex29")
// t.Errorf("Failed testcase: %v \nActual lint cmd: %v", testCase.testCaseName, *sboxProto.Commands[0].Command) sboxProto := android.RuleBuilderSboxProtoForTests(t, result, myjavalib.Output("lint.sbox.textproto"))
// } cmdFlags := fmt.Sprintf("--baseline %vlint-baseline.xml --disallowed_issues NewApi", testCase.moduleDirectory)
// } disallowedFlagActual := strings.Contains(*sboxProto.Commands[0].Command, cmdFlags)
//}
// if disallowedFlagActual != testCase.disallowedFlagExpected {
//// checks transtive deps of an apex coming from bootclasspath_fragment t.Errorf("Failed testcase: %v \nActual lint cmd: %v", testCase.testCaseName, *sboxProto.Commands[0].Command)
//func TestApexStrictUpdtabilityLintBcpFragmentDeps(t *testing.T) { }
// bp := ` }
// apex { }
// name: "myapex",
// key: "myapex.key", // checks transtive deps of an apex coming from bootclasspath_fragment
// bootclasspath_fragments: ["mybootclasspathfragment"], func TestApexStrictUpdtabilityLintBcpFragmentDeps(t *testing.T) {
// updatable: true, bp := `
// min_sdk_version: "29", apex {
// } name: "myapex",
// apex_key { key: "myapex.key",
// name: "myapex.key", bootclasspath_fragments: ["mybootclasspathfragment"],
// } updatable: true,
// bootclasspath_fragment { min_sdk_version: "29",
// name: "mybootclasspathfragment", }
// contents: ["myjavalib"], apex_key {
// apex_available: ["myapex"], name: "myapex.key",
// hidden_api: { }
// split_packages: ["*"], bootclasspath_fragment {
// }, name: "mybootclasspathfragment",
// } contents: ["myjavalib"],
// java_library { apex_available: ["myapex"],
// name: "myjavalib", hidden_api: {
// srcs: ["MyClass.java"], split_packages: ["*"],
// apex_available: [ "myapex" ], },
// sdk_version: "current", }
// min_sdk_version: "29", java_library {
// compile_dex: true, name: "myjavalib",
// } srcs: ["MyClass.java"],
// ` apex_available: [ "myapex" ],
// fs := android.MockFS{ sdk_version: "current",
// "lint-baseline.xml": nil, min_sdk_version: "29",
// } compile_dex: true,
// lint: {
// result := testApex(t, bp, dexpreopt.FixtureSetApexBootJars("myapex:myjavalib"), fs.AddToFixture()) baseline_filename: "lint-baseline.xml",
// myjavalib := result.ModuleForTests("myjavalib", "android_common_apex29") }
// sboxProto := android.RuleBuilderSboxProtoForTests(t, myjavalib.Output("lint.sbox.textproto")) }
// if !strings.Contains(*sboxProto.Commands[0].Command, "--baseline lint-baseline.xml --disallowed_issues NewApi") { `
// t.Errorf("Strict updabality lint missing in myjavalib coming from bootclasspath_fragment mybootclasspath-fragment\nActual lint cmd: %v", *sboxProto.Commands[0].Command) fs := android.MockFS{
// } "lint-baseline.xml": nil,
//} }
result := testApex(t, bp, dexpreopt.FixtureSetApexBootJars("myapex:myjavalib"), fs.AddToFixture())
myjavalib := result.ModuleForTests("myjavalib", "android_common_apex29")
sboxProto := android.RuleBuilderSboxProtoForTests(t, result, myjavalib.Output("lint.sbox.textproto"))
if !strings.Contains(*sboxProto.Commands[0].Command, "--baseline lint-baseline.xml --disallowed_issues NewApi") {
t.Errorf("Strict updabality lint missing in myjavalib coming from bootclasspath_fragment mybootclasspath-fragment\nActual lint cmd: %v", *sboxProto.Commands[0].Command)
}
}
// updatable apexes should propagate updatable=true to its apps // updatable apexes should propagate updatable=true to its apps
func TestUpdatableApexEnforcesAppUpdatability(t *testing.T) { func TestUpdatableApexEnforcesAppUpdatability(t *testing.T) {

View file

@ -94,6 +94,9 @@ type CommonProperties struct {
// if not blank, used as prefix to generate repackage rule // if not blank, used as prefix to generate repackage rule
Jarjar_prefix *string Jarjar_prefix *string
// if set to true, skip the jarjar repackaging
Skip_jarjar_repackage *bool
// If not blank, set the java version passed to javac as -source and -target // If not blank, set the java version passed to javac as -source and -target
Java_version *string Java_version *string
@ -1109,11 +1112,13 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath
jarjarProviderData := j.collectJarJarRules(ctx) jarjarProviderData := j.collectJarJarRules(ctx)
if jarjarProviderData != nil { if jarjarProviderData != nil {
android.SetProvider(ctx, JarJarProvider, *jarjarProviderData) android.SetProvider(ctx, JarJarProvider, *jarjarProviderData)
text := getJarJarRuleText(jarjarProviderData) if !proptools.Bool(j.properties.Skip_jarjar_repackage) {
if text != "" { text := getJarJarRuleText(jarjarProviderData)
ruleTextFile := android.PathForModuleOut(ctx, "repackaged-jarjar", "repackaging.txt") if text != "" {
android.WriteFileRule(ctx, ruleTextFile, text) ruleTextFile := android.PathForModuleOut(ctx, "repackaged-jarjar", "repackaging.txt")
j.repackageJarjarRules = ruleTextFile android.WriteFileRule(ctx, ruleTextFile, text)
j.repackageJarjarRules = ruleTextFile
}
} }
} }

View file

@ -319,25 +319,19 @@ func (l *linter) writeLintProjectXML(ctx android.ModuleContext, rule *android.Ru
cmd.FlagWithInput("@", cmd.FlagWithInput("@",
android.PathForSource(ctx, "build/soong/java/lint_defaults.txt")) android.PathForSource(ctx, "build/soong/java/lint_defaults.txt"))
if l.compileSdkKind == android.SdkPublic { cmd.FlagForEachArg("--error_check ", l.extraMainlineLintErrors)
cmd.FlagForEachArg("--error_check ", l.extraMainlineLintErrors)
} else {
// TODO(b/268261262): Remove this branch. We're demoting NewApi to a warning due to pre-existing issues that need to be fixed.
cmd.FlagForEachArg("--warning_check ", l.extraMainlineLintErrors)
}
cmd.FlagForEachArg("--disable_check ", l.properties.Lint.Disabled_checks) cmd.FlagForEachArg("--disable_check ", l.properties.Lint.Disabled_checks)
cmd.FlagForEachArg("--warning_check ", l.properties.Lint.Warning_checks) cmd.FlagForEachArg("--warning_check ", l.properties.Lint.Warning_checks)
cmd.FlagForEachArg("--error_check ", l.properties.Lint.Error_checks) cmd.FlagForEachArg("--error_check ", l.properties.Lint.Error_checks)
cmd.FlagForEachArg("--fatal_check ", l.properties.Lint.Fatal_checks) cmd.FlagForEachArg("--fatal_check ", l.properties.Lint.Fatal_checks)
// TODO(b/193460475): Re-enable strict updatability linting if l.GetStrictUpdatabilityLinting() {
//if l.GetStrictUpdatabilityLinting() { // Verify the module does not baseline issues that endanger safe updatability.
// // Verify the module does not baseline issues that endanger safe updatability. if l.properties.Lint.Baseline_filename != nil {
// if baselinePath := l.getBaselineFilepath(ctx); baselinePath.Valid() { cmd.FlagWithInput("--baseline ", android.PathForModuleSrc(ctx, *l.properties.Lint.Baseline_filename))
// cmd.FlagWithInput("--baseline ", baselinePath.Path()) cmd.FlagForEachArg("--disallowed_issues ", updatabilityChecks)
// cmd.FlagForEachArg("--disallowed_issues ", updatabilityChecks) }
// } }
//}
return lintPaths{ return lintPaths{
projectXML: projectXMLPath, projectXML: projectXMLPath,

View file

@ -91,9 +91,8 @@ func TestJavaLintUsesCorrectBpConfig(t *testing.T) {
t.Error("did not use the correct file for baseline") t.Error("did not use the correct file for baseline")
} }
if !strings.Contains(*sboxProto.Commands[0].Command, "--warning_check NewApi") { if !strings.Contains(*sboxProto.Commands[0].Command, "--error_check NewApi") {
// TODO(b/268261262): Change this to check for --error_check t.Error("should check NewApi errors")
t.Error("should check NewApi warnings")
} }
if !strings.Contains(*sboxProto.Commands[0].Command, "--error_check SomeCheck") { if !strings.Contains(*sboxProto.Commands[0].Command, "--error_check SomeCheck") {
@ -153,52 +152,55 @@ func TestJavaLintBypassUpdatableChecks(t *testing.T) {
} }
} }
// TODO(b/193460475): Re-enable this test func TestJavaLintStrictUpdatabilityLinting(t *testing.T) {
//func TestJavaLintStrictUpdatabilityLinting(t *testing.T) { bp := `
// bp := ` java_library {
// java_library { name: "foo",
// name: "foo", srcs: [
// srcs: [ "a.java",
// "a.java", ],
// ], static_libs: ["bar"],
// static_libs: ["bar"], min_sdk_version: "29",
// min_sdk_version: "29", sdk_version: "current",
// sdk_version: "current", lint: {
// lint: { strict_updatability_linting: true,
// strict_updatability_linting: true, baseline_filename: "lint-baseline.xml",
// }, },
// } }
//
// java_library { java_library {
// name: "bar", name: "bar",
// srcs: [ srcs: [
// "a.java", "a.java",
// ], ],
// min_sdk_version: "29", min_sdk_version: "29",
// sdk_version: "current", sdk_version: "current",
// } lint: {
// ` baseline_filename: "lint-baseline.xml",
// fs := android.MockFS{ }
// "lint-baseline.xml": nil, }
// } `
// fs := android.MockFS{
// result := android.GroupFixturePreparers(PrepareForTestWithJavaDefaultModules, fs.AddToFixture()). "lint-baseline.xml": nil,
// RunTestWithBp(t, bp) }
//
// foo := result.ModuleForTests("foo", "android_common") result := android.GroupFixturePreparers(PrepareForTestWithJavaDefaultModules, fs.AddToFixture()).
// sboxProto := android.RuleBuilderSboxProtoForTests(t, foo.Output("lint.sbox.textproto")) RunTestWithBp(t, bp)
// if !strings.Contains(*sboxProto.Commands[0].Command,
// "--baseline lint-baseline.xml --disallowed_issues NewApi") { foo := result.ModuleForTests("foo", "android_common")
// t.Error("did not restrict baselining NewApi") sboxProto := android.RuleBuilderSboxProtoForTests(t, result.TestContext, foo.Output("lint.sbox.textproto"))
// } if !strings.Contains(*sboxProto.Commands[0].Command,
// "--baseline lint-baseline.xml --disallowed_issues NewApi") {
// bar := result.ModuleForTests("bar", "android_common") t.Error("did not restrict baselining NewApi")
// sboxProto = android.RuleBuilderSboxProtoForTests(t, bar.Output("lint.sbox.textproto")) }
// if !strings.Contains(*sboxProto.Commands[0].Command,
// "--baseline lint-baseline.xml --disallowed_issues NewApi") { bar := result.ModuleForTests("bar", "android_common")
// t.Error("did not restrict baselining NewApi") sboxProto = android.RuleBuilderSboxProtoForTests(t, result.TestContext, bar.Output("lint.sbox.textproto"))
// } if !strings.Contains(*sboxProto.Commands[0].Command,
//} "--baseline lint-baseline.xml --disallowed_issues NewApi") {
t.Error("did not restrict baselining NewApi")
}
}
func TestJavaLintDatabaseSelectionFull(t *testing.T) { func TestJavaLintDatabaseSelectionFull(t *testing.T) {
testCases := []struct { testCases := []struct {