Do verify_uses_libraries check for APKs after patching library names.

Some of the `uses_libs`/`optional_uses_libs` libraries may have a
library name that is different from the module name. In that case it is
necessary to patch these properties after `provides_uses_lib` for the
library is applied.

Bug: 132357300
Test: m nothing
Change-Id: I2e2248053787557f955a6b363c22e3bad0301ec7
This commit is contained in:
Ulya Trafimovich 2021-02-26 14:36:48 +00:00
parent eea486a580
commit fe927a265e
2 changed files with 5 additions and 7 deletions

View file

@ -244,10 +244,6 @@ func (a *AndroidAppImport) generateAndroidBuildActions(ctx android.ModuleContext
srcApk := a.prebuilt.SingleSourcePath(ctx)
if a.usesLibrary.enforceUsesLibraries() {
srcApk = a.usesLibrary.verifyUsesLibrariesAPK(ctx, srcApk)
}
// TODO: Install or embed JNI libraries
// Uncompress JNI libraries in the apk
@ -276,6 +272,10 @@ func (a *AndroidAppImport) generateAndroidBuildActions(ctx android.ModuleContext
a.dexpreopter.enforceUsesLibs = a.usesLibrary.enforceUsesLibraries()
a.dexpreopter.classLoaderContexts = a.usesLibrary.classLoaderContextForUsesLibDeps(ctx)
if a.usesLibrary.enforceUsesLibraries() {
srcApk = a.usesLibrary.verifyUsesLibrariesAPK(ctx, srcApk)
}
a.dexpreopter.dexpreopt(ctx, jnisUncompressed)
if a.dexpreopter.uncompressedDex {
dexUncompressed := android.PathForModuleOut(ctx, "dex-uncompressed", ctx.ModuleName()+".apk")

View file

@ -2335,9 +2335,7 @@ func TestUsesLibraries(t *testing.T) {
// Test that all libraries are verified for an APK (library order matters).
verifyApkCmd := prebuilt.Rule("verify_uses_libraries").RuleParams.Command
// TODO(b/132357300): "non-sdk-lib" should not be here
// TODO(b/132357300): "com.non.sdk.lib" should be here
verifyApkReqLibs := `uses_library_names="foo non-sdk-lib android.test.runner"`
verifyApkReqLibs := `uses_library_names="foo com.non.sdk.lib android.test.runner"`
verifyApkOptLibs := `optional_uses_library_names="bar baz"`
if !strings.Contains(verifyApkCmd, verifyApkReqLibs) {
t.Errorf("wanted %q in %q", verifyApkReqLibs, verifyApkCmd)