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

@@ -476,7 +476,7 @@ func (a *apexBundle) buildFlattenedApex(ctx android.ModuleContext) {
apexName := proptools.StringDefault(a.properties.Apex_name, ctx.ModuleName())
a.outputFile = android.PathForModuleInstall(&factx, "apex", apexName)
if a.installable() {
if a.installable() && a.GetOverriddenBy() == "" {
installPath := android.PathForModuleInstall(ctx, "apex", apexName)
devicePath := android.InstallPathToOnDevicePath(ctx, installPath)
addFlattenedFileContextsInfos(ctx, apexName+":"+devicePath+":"+a.fileContexts.String())