Overridden APEX doesn't contribute to the file contexts
This change fixes the problem that when an apex module is overridden by
another override_apex, the <apex_name>-file_contexts are duplicated when
creating the system-level file-contexts.
Fixing this by not emitting the file_context info for the overridden
apex.
In doing so, OverridableModule interface was extended to have
GetOverriddenBy() method which can be used to test whether a module is
an overridden one or not.
Bug: 144338929
Test: m (apex_test amended)
Test: add "override_apex {name:"com.googlge.android.tzdata",
Change-Id: I5e9401c32899bb9987c90cba4185f571dc1a87f0
base:"com.android.tzdata"}" and the build is successful
diff --git a/apex/apex_test.go b/apex/apex_test.go
index 509d760..c5aeb8d 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -2977,6 +2977,15 @@
}
`)
+ originalVariant := ctx.ModuleForTests("myapex", "android_common_myapex_image").Module().(android.OverridableModule)
+ overriddenVariant := ctx.ModuleForTests("myapex", "android_common_override_myapex_myapex_image").Module().(android.OverridableModule)
+ if originalVariant.GetOverriddenBy() != "" {
+ t.Errorf("GetOverriddenBy should be empty, but was %q", originalVariant.GetOverriddenBy())
+ }
+ if overriddenVariant.GetOverriddenBy() != "override_myapex" {
+ t.Errorf("GetOverriddenBy should be \"override_myapex\", but was %q", overriddenVariant.GetOverriddenBy())
+ }
+
module := ctx.ModuleForTests("myapex", "android_common_override_myapex_myapex_image")
apexRule := module.Rule("apexRule")
copyCmds := apexRule.Args["copy_commands"]