summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Spandan Das <spandandas@google.com> 2024-05-28 23:40:17 +0000
committer Spandan Das <spandandas@google.com> 2024-05-29 00:06:32 +0000
commit0b28fa0b8408261ea74ed60691eb7be6da14db82 (patch)
tree43b691e3d37cb14f5711e9a11dcc7c102a5cffe6
parent1705676dd0ccaf56724ea6e0cfbddd0a73c2b802 (diff)
Override modules should always override source modules
Since overrides are implemented as variants of the source module, the override module should not be replaced with prebuilts of the source module even when the prebuilt is preferred. Test: go test ./apex Change-Id: I26e97f700276e7beaf6d1bd61b164f11d57a5e09
-rw-r--r--android/override_module.go9
-rw-r--r--apex/apex_test.go35
2 files changed, 44 insertions, 0 deletions
diff --git a/android/override_module.go b/android/override_module.go
index 55f384f1f..f69f96309 100644
--- a/android/override_module.go
+++ b/android/override_module.go
@@ -253,6 +253,15 @@ type overrideBaseDependencyTag struct {
var overrideBaseDepTag overrideBaseDependencyTag
+// Override module should always override the source module.
+// Overrides are implemented as a variant of the overridden module, and the build actions are created in the
+// module context of the overridden module.
+// If we replace override module with the prebuilt of the overridden module, `GenerateAndroidBuildActions` for
+// the override module will have a very different meaning.
+func (tag overrideBaseDependencyTag) ReplaceSourceWithPrebuilt() bool {
+ return false
+}
+
// Adds dependency on the base module to the overriding module so that they can be visited in the
// next phase.
func overrideModuleDepsMutator(ctx BottomUpMutatorContext) {
diff --git a/apex/apex_test.go b/apex/apex_test.go
index 4cac0ccd4..c60ee73cd 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -11671,3 +11671,38 @@ func TestApexMinSdkVersionOverride(t *testing.T) {
checkMinSdkVersion(t, overridingModuleDifferentMinSdkVersion, "31")
checkHasDep(t, ctx, overridingModuleDifferentMinSdkVersion.Module(), javalibApex31Variant.Module())
}
+
+func TestOverrideApexWithPrebuiltApexPreferred(t *testing.T) {
+ context := android.GroupFixturePreparers(
+ android.PrepareForIntegrationTestWithAndroid,
+ PrepareForTestWithApexBuildComponents,
+ android.FixtureMergeMockFs(android.MockFS{
+ "system/sepolicy/apex/foo-file_contexts": nil,
+ }),
+ )
+ res := context.RunTestWithBp(t, `
+ apex {
+ name: "foo",
+ key: "myapex.key",
+ apex_available_name: "com.android.foo",
+ variant_version: "0",
+ updatable: false,
+ }
+ apex_key {
+ name: "myapex.key",
+ public_key: "testkey.avbpubkey",
+ private_key: "testkey.pem",
+ }
+ prebuilt_apex {
+ name: "foo",
+ src: "foo.apex",
+ prefer: true,
+ }
+ override_apex {
+ name: "myoverrideapex",
+ base: "foo",
+ }
+ `)
+
+ java.CheckModuleHasDependency(t, res.TestContext, "myoverrideapex", "android_common_myoverrideapex_myoverrideapex", "foo")
+}