Make manifest and APK agree on uncompressed native libs

Only put uncompressed native libs in an APK if the min_sdk_version
supports it (>= 23, Marshmallow), and set
android:extractNativeLibs="false" in the AndroidManifest.xml so
that the platform won't extract them anyways.

Bug: 117618214
Test: m checkbuild
Change-Id: I760017e48bf3c6b618aabde0982df45995765d48
This commit is contained in:
Colin Cross
2019-02-05 21:55:21 -08:00
parent 129b9ceeb1
commit e4246abd7f
8 changed files with 118 additions and 14 deletions

View File

@@ -15,12 +15,13 @@
package java
import (
"android/soong/java/config"
"fmt"
"strings"
"github.com/google/blueprint"
"android/soong/android"
"android/soong/java/config"
)
var manifestFixerRule = pctx.AndroidStaticRule("manifestFixer",
@@ -43,11 +44,22 @@ var manifestMergerRule = pctx.AndroidStaticRule("manifestMerger",
"libs")
func manifestMerger(ctx android.ModuleContext, manifest android.Path, sdkContext sdkContext,
staticLibManifests android.Paths, isLibrary bool) android.Path {
staticLibManifests android.Paths, isLibrary bool, uncompressedJNI bool) android.Path {
var args []string
if isLibrary {
args = append(args, "--library")
} else {
minSdkVersion, err := sdkVersionToNumber(ctx, sdkContext.minSdkVersion())
if err != nil {
ctx.ModuleErrorf("invalid minSdkVersion: %s", err)
}
if minSdkVersion >= 23 {
args = append(args, fmt.Sprintf("--extract-native-libs=%v", !uncompressedJNI))
} else if uncompressedJNI {
ctx.ModuleErrorf("module attempted to store uncompressed native libraries, but minSdkVersion=%d doesn't support it",
minSdkVersion)
}
}
// Inject minSdkVersion into the manifest