Reland: JNI lib is always embedded for APKs in APEX
If a JNI lib is depended on by an APK that is included in an APEX, the
lib is embedded inside the APK.
This change also fixes a bug that APKs are not mutated for APEXes.
Bug: 144135069
Test: m (apex_test.go amended)
Change-Id: I21ac24412b30c05afc03385655c6b196130dffe3
diff --git a/java/app.go b/java/app.go
index d53d626..e9ef9eb 100644
--- a/java/app.go
+++ b/java/app.go
@@ -78,8 +78,9 @@
// Store native libraries uncompressed in the APK and set the android:extractNativeLibs="false" manifest
// flag so that they are used from inside the APK at runtime. Defaults to true for android_test modules unless
- // sdk_version or min_sdk_version is set to a version that doesn't support it (<23), defaults to false for other
- // module types where the native libraries are generally preinstalled outside the APK.
+ // sdk_version or min_sdk_version is set to a version that doesn't support it (<23), defaults to true for
+ // android_app modules that are embedded to APEXes, defaults to false for other module types where the native
+ // libraries are generally preinstalled outside the APK.
Use_embedded_native_libs *bool
// Store dex files uncompressed in the APK and set the android:useEmbeddedDex="true" manifest attribute so that
@@ -217,7 +218,8 @@
ctx.PropertyErrorf("min_sdk_version", "invalid value %q: %s", a.minSdkVersion(), err)
}
- return minSdkVersion >= 23 && Bool(a.appProperties.Use_embedded_native_libs)
+ return (minSdkVersion >= 23 && Bool(a.appProperties.Use_embedded_native_libs)) ||
+ !a.IsForPlatform()
}
// Returns whether this module should have the dex file stored uncompressed in the APK.
@@ -241,7 +243,7 @@
func (a *AndroidApp) shouldEmbedJnis(ctx android.BaseModuleContext) bool {
return ctx.Config().UnbundledBuild() || Bool(a.appProperties.Use_embedded_native_libs) ||
- a.appProperties.AlwaysPackageNativeLibs
+ !a.IsForPlatform() || a.appProperties.AlwaysPackageNativeLibs
}
func (a *AndroidApp) aaptBuildActions(ctx android.ModuleContext) {
@@ -585,6 +587,7 @@
android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibCommon)
android.InitDefaultableModule(module)
android.InitOverridableModule(module, &module.appProperties.Overrides)
+ android.InitApexModule(module)
return module
}