android_app APEX_GLOBAL_MIN_SDK_VERSION_OVERRIDE
Currently the product variable that is controlled by
APEX_GLOBAL_MIN_SDK_VERSION_OVERRIDE only overrides apexes, but it
doesn't apply to android_apps. This commit allows android_apps which set
updatable: true in their Android.bp to have their min_sdk_version be
overriden by this product variable.
Bug: 295311875
Test: go test
Change-Id: If3cb82a17cae4553b577dd1a4637ee13c3c95302
diff --git a/java/app_test.go b/java/app_test.go
index 8474ea7..fc57f44 100644
--- a/java/app_test.go
+++ b/java/app_test.go
@@ -4137,3 +4137,49 @@
"\\S+soong/.intermediates/foo/android_common_bar/privapp_allowlist_com.google.android.foo.xml:\\S+/target/product/test_device/system/etc/permissions/bar.xml",
)
}
+
+func TestApexGlobalMinSdkVersionOverride(t *testing.T) {
+ result := android.GroupFixturePreparers(
+ PrepareForTestWithJavaDefaultModules,
+ android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
+ variables.ApexGlobalMinSdkVersionOverride = proptools.StringPtr("Tiramisu")
+ }),
+ ).RunTestWithBp(t, `
+ android_app {
+ name: "com.android.bar",
+ srcs: ["a.java"],
+ sdk_version: "current",
+ }
+ android_app {
+ name: "com.android.foo",
+ srcs: ["a.java"],
+ sdk_version: "current",
+ min_sdk_version: "S",
+ updatable: true,
+ }
+ override_android_app {
+ name: "com.android.go.foo",
+ base: "com.android.foo",
+ }
+ `)
+ foo := result.ModuleForTests("com.android.foo", "android_common").Rule("manifestFixer")
+ fooOverride := result.ModuleForTests("com.android.foo", "android_common_com.android.go.foo").Rule("manifestFixer")
+ bar := result.ModuleForTests("com.android.bar", "android_common").Rule("manifestFixer")
+
+ android.AssertStringDoesContain(t,
+ "expected manifest fixer to set com.android.bar minSdkVersion to S",
+ bar.BuildParams.Args["args"],
+ "--minSdkVersion S",
+ )
+ android.AssertStringDoesContain(t,
+ "com.android.foo: expected manifest fixer to set minSdkVersion to T",
+ foo.BuildParams.Args["args"],
+ "--minSdkVersion T",
+ )
+ android.AssertStringDoesContain(t,
+ "com.android.go.foo: expected manifest fixer to set minSdkVersion to T",
+ fooOverride.BuildParams.Args["args"],
+ "--minSdkVersion T",
+ )
+
+}