Merge "Do verify_uses_libraries check for APKs after patching library names."

This commit is contained in:
Ulyana Trafimovich 2021-03-02 13:49:34 +00:00 committed by Gerrit Code Review
commit 97df5e65b0
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) srcApk := a.prebuilt.SingleSourcePath(ctx)
if a.usesLibrary.enforceUsesLibraries() {
srcApk = a.usesLibrary.verifyUsesLibrariesAPK(ctx, srcApk)
}
// TODO: Install or embed JNI libraries // TODO: Install or embed JNI libraries
// Uncompress JNI libraries in the apk // 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.enforceUsesLibs = a.usesLibrary.enforceUsesLibraries()
a.dexpreopter.classLoaderContexts = a.usesLibrary.classLoaderContextForUsesLibDeps(ctx) a.dexpreopter.classLoaderContexts = a.usesLibrary.classLoaderContextForUsesLibDeps(ctx)
if a.usesLibrary.enforceUsesLibraries() {
srcApk = a.usesLibrary.verifyUsesLibrariesAPK(ctx, srcApk)
}
a.dexpreopter.dexpreopt(ctx, jnisUncompressed) a.dexpreopter.dexpreopt(ctx, jnisUncompressed)
if a.dexpreopter.uncompressedDex { if a.dexpreopter.uncompressedDex {
dexUncompressed := android.PathForModuleOut(ctx, "dex-uncompressed", ctx.ModuleName()+".apk") dexUncompressed := android.PathForModuleOut(ctx, "dex-uncompressed", ctx.ModuleName()+".apk")

View file

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