APK-in-APEX should set use_embedded_native_libs: true
So far, we automatically have embedded JNI libs for APKs in APEX, even if use_embedded_native_libs was not set or set to false. With this change, such APKs should explicitly set the property. This is in preparation for an upcoming change for using different dependency tags to JNI deps depending on whether they are embedded (thus no install is needed), or not (thus installation to the partition is needed). shouldEmbedJni function now doesn't make use of the ApexInfoProvider which is not available during deps mutator. Bug: N/A Test: m Change-Id: I836171aacba19dbfa0e09f16a773ae498c56d60b
This commit is contained in:
@@ -5908,6 +5908,7 @@ func TestApexWithApps(t *testing.T) {
|
|||||||
srcs: ["foo/bar/MyClass.java"],
|
srcs: ["foo/bar/MyClass.java"],
|
||||||
sdk_version: "current",
|
sdk_version: "current",
|
||||||
system_modules: "none",
|
system_modules: "none",
|
||||||
|
use_embedded_native_libs: true,
|
||||||
jni_libs: ["libjni"],
|
jni_libs: ["libjni"],
|
||||||
stl: "none",
|
stl: "none",
|
||||||
apex_available: [ "myapex" ],
|
apex_available: [ "myapex" ],
|
||||||
|
16
java/app.go
16
java/app.go
@@ -334,6 +334,7 @@ func (a *AndroidTestHelperApp) GenerateAndroidBuildActions(ctx android.ModuleCon
|
|||||||
|
|
||||||
func (a *AndroidApp) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
func (a *AndroidApp) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||||
a.checkAppSdkVersions(ctx)
|
a.checkAppSdkVersions(ctx)
|
||||||
|
a.checkEmbedJnis(ctx)
|
||||||
a.generateAndroidBuildActions(ctx)
|
a.generateAndroidBuildActions(ctx)
|
||||||
a.generateJavaUsedByApex(ctx)
|
a.generateJavaUsedByApex(ctx)
|
||||||
}
|
}
|
||||||
@@ -378,6 +379,17 @@ func (a *AndroidApp) checkAppSdkVersions(ctx android.ModuleContext) {
|
|||||||
a.checkSdkVersions(ctx)
|
a.checkSdkVersions(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ensures that use_embedded_native_libs are set for apk-in-apex
|
||||||
|
func (a *AndroidApp) checkEmbedJnis(ctx android.BaseModuleContext) {
|
||||||
|
apexInfo, _ := android.ModuleProvider(ctx, android.ApexInfoProvider)
|
||||||
|
apkInApex := !apexInfo.IsForPlatform()
|
||||||
|
hasJnis := len(a.appProperties.Jni_libs) > 0
|
||||||
|
|
||||||
|
if apkInApex && hasJnis && !Bool(a.appProperties.Use_embedded_native_libs) {
|
||||||
|
ctx.ModuleErrorf("APK in APEX should have use_embedded_native_libs: true")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If an updatable APK sets min_sdk_version, min_sdk_vesion of JNI libs should match with it.
|
// If an updatable APK sets min_sdk_version, min_sdk_vesion of JNI libs should match with it.
|
||||||
// This check is enforced for "updatable" APKs (including APK-in-APEX).
|
// This check is enforced for "updatable" APKs (including APK-in-APEX).
|
||||||
func (a *AndroidApp) checkJniLibsSdkVersion(ctx android.ModuleContext, minSdkVersion android.ApiLevel) {
|
func (a *AndroidApp) checkJniLibsSdkVersion(ctx android.ModuleContext, minSdkVersion android.ApiLevel) {
|
||||||
@@ -433,9 +445,9 @@ func (a *AndroidApp) shouldUncompressDex(ctx android.ModuleContext) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *AndroidApp) shouldEmbedJnis(ctx android.BaseModuleContext) bool {
|
func (a *AndroidApp) shouldEmbedJnis(ctx android.BaseModuleContext) bool {
|
||||||
apexInfo, _ := android.ModuleProvider(ctx, android.ApexInfoProvider)
|
|
||||||
return ctx.Config().UnbundledBuild() || Bool(a.appProperties.Use_embedded_native_libs) ||
|
return ctx.Config().UnbundledBuild() || Bool(a.appProperties.Use_embedded_native_libs) ||
|
||||||
!apexInfo.IsForPlatform() || a.appProperties.AlwaysPackageNativeLibs
|
Bool(a.appProperties.Updatable) ||
|
||||||
|
a.appProperties.AlwaysPackageNativeLibs
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateAaptRenamePackageFlags(packageName string, renameResourcesPackage bool) []string {
|
func generateAaptRenamePackageFlags(packageName string, renameResourcesPackage bool) []string {
|
||||||
|
Reference in New Issue
Block a user