Enforce min_sdk_version of apex(use_vendor:true)

Even though use_vendor:true is prohibited, there is media.swcodec apex
which is still use_vendor: true and also needs to support Android10.
(min_sdk_version: 29)

Because LLNDK stubs were provided only for the current VNDK version,
media.swcodec couldn't be built against min_sdk_version: 29.

This change introduces additional versions for LLNDK stubs which are
enforced when an apex with use_vendor: true sets min_sdk_version.

To make things easier, the versions of LLNDK stubs are borrowed from its
implementation libraries.

Bug: 147450930
Bug: 149591522
Test: TARGET_BUILD_APPS=com.android.media.swcodec m
      (with min_sdk_version: 29 set)
      check if liblog/libc/libm/libdl stubs are 29
      check if 29 stubs don't have new symbols.

Merged-In: I79946cbb4da6617138a96d2b254349d3a298e77b
Change-Id: I79946cbb4da6617138a96d2b254349d3a298e77b
(cherry picked from commit 380fc3615c)
This commit is contained in:
Jooyung Han
2020-03-13 15:23:36 +09:00
parent 89124ba39b
commit 67a96cd7cb
6 changed files with 189 additions and 63 deletions

View File

@@ -848,58 +848,89 @@ func TestApexWithRuntimeLibsDependency(t *testing.T) {
}
func TestApexDependencyToLLNDK(t *testing.T) {
ctx, _ := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
use_vendor: true,
native_shared_libs: ["mylib"],
}
func TestApexDependsOnLLNDKTransitively(t *testing.T) {
testcases := []struct {
name string
minSdkVersion string
shouldLink string
shouldNotLink []string
}{
{
name: "should link to test latest",
minSdkVersion: "current",
shouldLink: "30",
shouldNotLink: []string{"29"},
},
{
name: "should link to llndk#29",
minSdkVersion: "29",
shouldLink: "29",
shouldNotLink: []string{"30"},
},
}
for _, tc := range testcases {
t.Run(tc.name, func(t *testing.T) {
ctx, _ := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
use_vendor: true,
native_shared_libs: ["mylib"],
min_sdk_version: "`+tc.minSdkVersion+`",
}
apex_key {
name: "myapex.key",
public_key: "testkey.avbpubkey",
private_key: "testkey.pem",
}
apex_key {
name: "myapex.key",
public_key: "testkey.avbpubkey",
private_key: "testkey.pem",
}
cc_library {
name: "mylib",
srcs: ["mylib.cpp"],
vendor_available: true,
shared_libs: ["libbar"],
system_shared_libs: [],
stl: "none",
apex_available: [ "myapex" ],
}
cc_library {
name: "mylib",
srcs: ["mylib.cpp"],
vendor_available: true,
shared_libs: ["libbar"],
system_shared_libs: [],
stl: "none",
apex_available: [ "myapex" ],
}
cc_library {
name: "libbar",
srcs: ["mylib.cpp"],
system_shared_libs: [],
stl: "none",
}
cc_library {
name: "libbar",
srcs: ["mylib.cpp"],
system_shared_libs: [],
stl: "none",
stubs: { versions: ["29","30"] },
}
llndk_library {
name: "libbar",
symbol_file: "",
}
`, func(fs map[string][]byte, config android.Config) {
setUseVendorWhitelistForTest(config, []string{"myapex"})
})
llndk_library {
name: "libbar",
symbol_file: "",
}
`, func(fs map[string][]byte, config android.Config) {
setUseVendorWhitelistForTest(config, []string{"myapex"})
}, withUnbundledBuild)
apexRule := ctx.ModuleForTests("myapex", "android_common_myapex_image").Rule("apexRule")
copyCmds := apexRule.Args["copy_commands"]
// Ensure that LLNDK dep is not included
ensureExactContents(t, ctx, "myapex", "android_common_myapex_image", []string{
"lib64/mylib.so",
})
// Ensure that LLNDK dep is not included
ensureNotContains(t, copyCmds, "image.apex/lib64/libbar.so")
// Ensure that LLNDK dep is required
apexManifestRule := ctx.ModuleForTests("myapex", "android_common_myapex_image").Rule("apexManifestRule")
ensureListEmpty(t, names(apexManifestRule.Args["provideNativeLibs"]))
ensureListContains(t, names(apexManifestRule.Args["requireNativeLibs"]), "libbar.so")
apexManifestRule := ctx.ModuleForTests("myapex", "android_common_myapex_image").Rule("apexManifestRule")
ensureListEmpty(t, names(apexManifestRule.Args["provideNativeLibs"]))
// Ensure that LLNDK dep is required
ensureListContains(t, names(apexManifestRule.Args["requireNativeLibs"]), "libbar.so")
mylibLdFlags := ctx.ModuleForTests("mylib", "android_vendor.VER_arm64_armv8-a_shared_myapex").Rule("ld").Args["libFlags"]
ensureContains(t, mylibLdFlags, "libbar.llndk/android_vendor.VER_arm64_armv8-a_shared_"+tc.shouldLink+"/libbar.so")
for _, ver := range tc.shouldNotLink {
ensureNotContains(t, mylibLdFlags, "libbar.llndk/android_vendor.VER_arm64_armv8-a_shared_"+ver+"/libbar.so")
}
mylibCFlags := ctx.ModuleForTests("mylib", "android_vendor.VER_arm64_armv8-a_static_myapex").Rule("cc").Args["cFlags"]
ensureContains(t, mylibCFlags, "__LIBBAR_API__="+tc.shouldLink)
})
}
}
func TestApexWithSystemLibsStubs(t *testing.T) {
@@ -1229,10 +1260,6 @@ func TestQTargetApexUseStaticUnwinder(t *testing.T) {
// note that platform variant is not.
cm = ctx.ModuleForTests("libc++", "android_arm64_armv8-a_shared").Module().(*cc.Module)
ensureListNotContains(t, cm.Properties.AndroidMkStaticLibs, "libgcc_stripped")
libFlags := ctx.ModuleForTests("libx", "android_arm64_armv8-a_shared_myapex").Rule("ld").Args["libFlags"]
ensureContains(t, libFlags, "android_arm64_armv8-a_shared_myapex/libc++.so")
ensureContains(t, libFlags, "android_arm64_armv8-a_shared_29/libc.so") // min_sdk_version applied
}
func TestInvalidMinSdkVersion(t *testing.T) {