From 6e12625c0f630572df7af224deed99e2f8bb88aa Mon Sep 17 00:00:00 2001 From: atrost Date: Mon, 27 Jan 2020 17:01:16 +0000 Subject: [PATCH] Add support for compat config in APEX. apex module accepts PlatformCompatConfigIntf as prebuilt, and places it in the etc folder of the apex. Test: m Test: flash device with dummy config in mediaprovider APEX - the config is present Change-Id: Ifc62cd262f6c6571c1bf6c2943879aa20877ecad --- apex/apex.go | 10 +++++++++- apex/apex_test.go | 36 ++++++++++++++++++++++++++++++++++ java/platform_compat_config.go | 25 +++++++++++++++++------ 3 files changed, 64 insertions(+), 7 deletions(-) diff --git a/apex/apex.go b/apex/apex.go index 48cdedf3d..53bdc1249 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -1194,6 +1194,12 @@ func apexFileForPrebuiltEtc(ctx android.BaseModuleContext, prebuilt android.Preb return newApexFile(ctx, fileToCopy, depName, dirInApex, etc, prebuilt) } +func apexFileForCompatConfig(ctx android.BaseModuleContext, config java.PlatformCompatConfigIntf, depName string) apexFile { + dirInApex := filepath.Join("etc", config.SubDir()) + fileToCopy := config.CompatConfig() + return newApexFile(ctx, fileToCopy, depName, dirInApex, etc, config) +} + func apexFileForAndroidApp(ctx android.BaseModuleContext, aapp interface { android.Module Privileged() bool @@ -1361,8 +1367,10 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) { case prebuiltTag: if prebuilt, ok := child.(android.PrebuiltEtcModule); ok { filesInfo = append(filesInfo, apexFileForPrebuiltEtc(ctx, prebuilt, depName)) + } else if prebuilt, ok := child.(java.PlatformCompatConfigIntf); ok { + filesInfo = append(filesInfo, apexFileForCompatConfig(ctx, prebuilt, depName)) } else { - ctx.PropertyErrorf("prebuilts", "%q is not a prebuilt_etc module", depName) + ctx.PropertyErrorf("prebuilts", "%q is not a prebuilt_etc and not a platform_compat_config module", depName) } case testTag: if ccTest, ok := child.(*cc.Module); ok { diff --git a/apex/apex_test.go b/apex/apex_test.go index c7ecbc998..22f0f6f7d 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -299,6 +299,7 @@ func testApexContext(t *testing.T, bp string, handlers ...testCustomizer) (*andr ctx.RegisterModuleType("vndk_prebuilt_shared", cc.VndkPrebuiltSharedFactory) ctx.RegisterModuleType("vndk_libraries_txt", cc.VndkLibrariesTxtFactory) ctx.RegisterModuleType("prebuilt_etc", android.PrebuiltEtcFactory) + ctx.RegisterModuleType("platform_compat_config", java.PlatformCompatConfigFactory) ctx.RegisterModuleType("sh_binary", android.ShBinaryFactory) ctx.RegisterModuleType("filegroup", android.FileGroupFactory) java.RegisterJavaBuildComponents(ctx) @@ -3451,6 +3452,41 @@ func TestJavaSDKLibrary(t *testing.T) { ensureContains(t, xml.Args["content"], `