diff options
author | Jaewoong Jung <jungjw@google.com> | 2019-05-02 14:55:29 -0700 |
---|---|---|
committer | Michael Bestas <mkbestas@lineageos.org> | 2019-12-11 19:03:32 +0200 |
commit | 73e34b4dbd146f344637319e86d0a9bf4bed28c9 (patch) | |
tree | 712bcc26de71eabef139b1902b5f56d339e6d7a8 | |
parent | 658828c00f17e8b8852f11a7a76da369b7ce21e6 (diff) | |
download | build_soong-73e34b4dbd146f344637319e86d0a9bf4bed28c9.tar.gz build_soong-73e34b4dbd146f344637319e86d0a9bf4bed28c9.tar.bz2 build_soong-73e34b4dbd146f344637319e86d0a9bf4bed28c9.zip |
uncompressedDex option for android_app_import.
This also partially consolidates shouldUncompressDex implementations.
Bug: 128610294
Test: TreeHugger
Change-Id: I7cea5a3890ddd473f63c0738a35af067455b5c4d
-rw-r--r-- | java/app.go | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/java/app.go b/java/app.go index cad90b03..bbe034d1 100644 --- a/java/app.go +++ b/java/app.go @@ -189,24 +189,16 @@ func (a *AndroidApp) shouldUncompressDex(ctx android.ModuleContext) bool { return true } - // Uncompress dex in APKs of privileged apps, and modules used by privileged apps - // (even for unbundled builds, they may be preinstalled as prebuilts). - if ctx.Config().UncompressPrivAppDex() && - (Bool(a.appProperties.Privileged) || - inList(ctx.ModuleName(), ctx.Config().ModulesLoadedByPrivilegedModules())) { - return true - } - if ctx.Config().UnbundledBuild() { return false } - // Uncompress if the dex files is preopted on /system. - if !a.dexpreopter.dexpreoptDisabled(ctx) && (ctx.Host() || !odexOnSystemOther(ctx, a.dexpreopter.installPath)) { + // Uncompress dex in APKs of privileged apps + if ctx.Config().UncompressPrivAppDex() && Bool(a.appProperties.Privileged) { return true } - return false + return shouldUncompressDex(ctx, &a.dexpreopter) } func (a *AndroidApp) aaptBuildActions(ctx android.ModuleContext) { @@ -744,6 +736,20 @@ func (a *AndroidAppImport) uncompressEmbeddedJniLibs( rule.Build(pctx, ctx, "uncompress-embedded-jni-libs", "Uncompress embedded JIN libs") } +// Returns whether this module should have the dex file stored uncompressed in the APK. +func (a *AndroidAppImport) shouldUncompressDex(ctx android.ModuleContext) bool { + if ctx.Config().UnbundledBuild() { + return false + } + + // Uncompress dex in APKs of privileged apps + if ctx.Config().UncompressPrivAppDex() && Bool(a.properties.Privileged) { + return true + } + + return shouldUncompressDex(ctx, &a.dexpreopter) +} + func (a *AndroidAppImport) GenerateAndroidBuildActions(ctx android.ModuleContext) { if String(a.properties.Certificate) == "" && !Bool(a.properties.Presigned) { ctx.PropertyErrorf("certificate", "No certificate specified for prebuilt") @@ -766,12 +772,11 @@ func (a *AndroidAppImport) GenerateAndroidBuildActions(ctx android.ModuleContext jnisUncompressed := android.PathForModuleOut(ctx, "jnis-uncompressed", ctx.ModuleName()+".apk") a.uncompressEmbeddedJniLibs(ctx, srcApk, jnisUncompressed.OutputPath) - // TODO: Uncompress dex if applicable - installDir := android.PathForModuleInstall(ctx, "app", a.BaseModuleName()) a.dexpreopter.installPath = installDir.Join(ctx, a.BaseModuleName()+".apk") a.dexpreopter.isInstallable = true a.dexpreopter.isPresignedPrebuilt = Bool(a.properties.Presigned) + a.dexpreopter.uncompressedDex = a.shouldUncompressDex(ctx) dexOutput := a.dexpreopter.dexpreopt(ctx, jnisUncompressed) // Sign or align the package |