diff options
| author | 2024-05-05 10:05:09 +0900 | |
|---|---|---|
| committer | 2024-05-05 10:49:22 +0900 | |
| commit | 4bc5231f6115c71aaa0aaaa3d575e5015f01bc5d (patch) | |
| tree | adf7dfe1ecc011b82f48b32ea72b6fb068e965f5 /java | |
| parent | 3eea67d8ebb8051d1d2976a65c84efe54571fa45 (diff) | |
Collect transitve deps of jni libs only for bundled apps
We do this because otherwise we will be embedding platform libs in the
bundled apps bloating their size.
Bug: 330276359
Test: Build Galery2 and check if libc++.so is not included there.
Change-Id: Ie866b192e9816bcb71b7ca3d74331d14d85592a4
Diffstat (limited to 'java')
| -rw-r--r-- | java/app.go | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/java/app.go b/java/app.go index 0170ea186..254fbf4fd 100644 --- a/java/app.go +++ b/java/app.go @@ -440,6 +440,21 @@ func (a *AndroidApp) shouldEmbedJnis(ctx android.BaseModuleContext) bool { return true } +func (a *AndroidApp) shouldCollectRecursiveNativeDeps(ctx android.ModuleContext) bool { + // JNI libs are always embedded, but whether to embed their transitive dependencies as well + // or not is determined here. For most of the apps built here (using the platform build + // system), we don't need to collect the transitive deps because they will anyway be + // available in the partition image where the app will be installed to. + // + // Collecting transitive dependencies is required only for unbundled apps. + apexInfo, _ := android.ModuleProvider(ctx, android.ApexInfoProvider) + apkInApex := !apexInfo.IsForPlatform() + testApp := a.appProperties.AllowCompressingNativeLibs + unbundledApp := ctx.Config().UnbundledBuild() || apkInApex || testApp + + return a.shouldEmbedJnis(ctx) && unbundledApp +} + func generateAaptRenamePackageFlags(packageName string, renameResourcesPackage bool) []string { aaptFlags := []string{"--rename-manifest-package " + packageName} if renameResourcesPackage { @@ -831,7 +846,7 @@ func (a *AndroidApp) generateAndroidBuildActions(ctx android.ModuleContext) { dexJarFile, packageResources := a.dexBuildActions(ctx) - jniLibs, prebuiltJniPackages, certificates := collectAppDeps(ctx, a, a.shouldEmbedJnis(ctx), !Bool(a.appProperties.Jni_uses_platform_apis)) + jniLibs, prebuiltJniPackages, certificates := collectAppDeps(ctx, a, a.shouldCollectRecursiveNativeDeps(ctx), !Bool(a.appProperties.Jni_uses_platform_apis)) jniJarFile := a.jniBuildActions(jniLibs, prebuiltJniPackages, ctx) if ctx.Failed() { |