Revert "Revert "APK-in-APEX should set use_embedded_native_libs:..."

Revert submission 3094658-revert-3088867-QEHDREAABY

Reason for revert: not a regression
Reverted changes: /q/submissionid:3094658-revert-3088867-QEHDREAABY

Change-Id: Ie1e4a196f181643a3e64e573b132d52d7455461b
This commit is contained in:
Jiyong Park 2024-05-17 22:58:54 +00:00
parent 25b9222a43
commit 970c524ab5
2 changed files with 15 additions and 2 deletions

View file

@ -5922,6 +5922,7 @@ func TestApexWithApps(t *testing.T) {
srcs: ["foo/bar/MyClass.java"],
sdk_version: "current",
system_modules: "none",
use_embedded_native_libs: true,
jni_libs: ["libjni"],
stl: "none",
apex_available: [ "myapex" ],

View file

@ -334,6 +334,7 @@ func (a *AndroidTestHelperApp) GenerateAndroidBuildActions(ctx android.ModuleCon
func (a *AndroidApp) GenerateAndroidBuildActions(ctx android.ModuleContext) {
a.checkAppSdkVersions(ctx)
a.checkEmbedJnis(ctx)
a.generateAndroidBuildActions(ctx)
a.generateJavaUsedByApex(ctx)
}
@ -378,6 +379,17 @@ func (a *AndroidApp) checkAppSdkVersions(ctx android.ModuleContext) {
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.
// This check is enforced for "updatable" APKs (including APK-in-APEX).
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 {
apexInfo, _ := android.ModuleProvider(ctx, android.ApexInfoProvider)
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 {