From 45a96778c19fcc36debb06e3908b5db4d68fef71 Mon Sep 17 00:00:00 2001 From: Jooyung Han Date: Mon, 15 Jun 2020 14:59:42 +0900 Subject: [PATCH] VNDK APEX should not provide native libs While libz has stubs for other mainline modules, it doesn't provide stubs when it is used as a VNDK lib. In general, VNDK libs are only for vendor modules. So, we skip them even if they have stubs. Bug: 155456180 Test: m com.android.vndk.current provideNativeLibs of the APEX should be empty Change-Id: I22401a2b1732a8560802c5be850181682e183a8e --- apex/apex.go | 6 ++++-- apex/apex_test.go | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/apex/apex.go b/apex/apex.go index 3fef1ee41..891182514 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -1954,8 +1954,10 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) { fi := apexFileForNativeLibrary(ctx, c, handleSpecialLibs) fi.isJniLib = isJniLib filesInfo = append(filesInfo, fi) - // bootstrap bionic libs are treated as provided by system - if c.HasStubsVariants() && !cc.InstallToBootstrap(c.BaseModuleName(), ctx.Config()) { + // Collect the list of stub-providing libs except: + // - VNDK libs are only for vendors + // - bootstrap bionic libs are treated as provided by system + if c.HasStubsVariants() && !a.vndkApex && !cc.InstallToBootstrap(c.BaseModuleName(), ctx.Config()) { provideNativeLibs = append(provideNativeLibs, fi.Stem()) } return true // track transitive dependencies diff --git a/apex/apex_test.go b/apex/apex_test.go index 7159a4593..6a832af93 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -2817,6 +2817,40 @@ func TestVndkApexWithBinder32(t *testing.T) { }) } +func TestVndkApexShouldNotProvideNativeLibs(t *testing.T) { + ctx, _ := testApex(t, ` + apex_vndk { + name: "myapex", + key: "myapex.key", + file_contexts: ":myapex-file_contexts", + } + + apex_key { + name: "myapex.key", + public_key: "testkey.avbpubkey", + private_key: "testkey.pem", + } + + cc_library { + name: "libz", + vendor_available: true, + vndk: { + enabled: true, + }, + stubs: { + symbol_file: "libz.map.txt", + versions: ["30"], + } + } + `+vndkLibrariesTxtFiles("current"), withFiles(map[string][]byte{ + "libz.map.txt": nil, + })) + + apexManifestRule := ctx.ModuleForTests("myapex", "android_common_image").Rule("apexManifestRule") + provideNativeLibs := names(apexManifestRule.Args["provideNativeLibs"]) + ensureListEmpty(t, provideNativeLibs) +} + func TestDependenciesInApexManifest(t *testing.T) { ctx, _ := testApex(t, ` apex {