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
This commit is contained in:
Jiyong Park
2019-12-05 13:20:58 +09:00
parent 7b34ebf447
commit 317645e84c
3 changed files with 32 additions and 7 deletions

View File

@@ -2977,6 +2977,15 @@ func TestOverrideApex(t *testing.T) {
}
`)
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"]