From f491dde8ea62e8a7e900eec62ff2bce7778a87d6 Mon Sep 17 00:00:00 2001 From: Ulya Trafimovich Date: Fri, 24 Jan 2020 12:19:45 +0000 Subject: [PATCH] Store uncompressed and aligned DEX files for java libs in APEXes. Test: aosp_walleye-userdebug boots. Test: In internal, cherry-picked this CL, walleye-userdebug boots. Test: In internal, ensure that DEX file wifi-service.jar in the com.android.wifi APEX is now stored uncompressed: $ zipinfo out/target/product/walleye/apex/com.android.wifi/javalib/wifi-service.jar Archive: out/target/product/walleye/apex/com.android.wifi/javalib/wifi-service.jar Zip file size: 3086879 bytes, number of entries: 3 -rw---- 2.0 fat 3086304 b- stor 08-Jan-01 00:00 classes.dex -rw---- 2.0 fat 339 b- defN 80-Feb-01 00:00 META-INF/proguard/androidx-annotations.pro -rw---- 2.0 fat 45 b- defN 08-Jan-01 00:00 META-INF/MANIFEST.MF 3 files, 3086688 bytes uncompressed, 3086480 bytes compressed: 0.0% Before the change it was: $ zipinfo out/target/product/walleye/apex/com.android.wifi/javalib/wifi-service.jar Archive: out/target/product/walleye/apex/com.android.wifi/javalib/wifi-service.jar Zip file size: 1241938 bytes, number of entries: 3 -rw---- 2.0 fat 3086304 bl defN 08-Jan-01 00:00 classes.dex -rw---- 2.0 fat 339 b- defN 80-Feb-01 00:00 META-INF/proguard/androidx-annotations.pro -rw---- 2.0 fat 45 b- defN 08-Jan-01 00:00 META-INF/MANIFEST.MF 3 files, 3086688 bytes uncompressed, 1241526 bytes compressed: 59.8% Bug: 148099857 Bug: 146984232 Change-Id: Ia302967b280be85665032cc870c5d5d2419586fc --- apex/apex_test.go | 2 +- java/java.go | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/apex/apex_test.go b/apex/apex_test.go index b7dd7fb5f..c7ecbc998 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -3014,7 +3014,7 @@ func TestApexWithApps(t *testing.T) { ensureContains(t, copyCmds, "image.apex/priv-app/AppFooPriv/AppFooPriv.apk") // JNI libraries are embedded inside APK - appZipRule := ctx.ModuleForTests("AppFoo", "android_common_myapex").Rule("zip") + appZipRule := ctx.ModuleForTests("AppFoo", "android_common_myapex").Description("zip jni lib") libjniOutput := ctx.ModuleForTests("libjni", "android_arm64_armv8-a_shared_myapex").Module().(*cc.Module).OutputFile() ensureListContains(t, appZipRule.Implicits.Strings(), libjniOutput.String()) // ... uncompressed diff --git a/java/java.go b/java/java.go index 4c6a5a5ac..1007a979c 100644 --- a/java/java.go +++ b/java/java.go @@ -1741,6 +1741,11 @@ type Library struct { } func shouldUncompressDex(ctx android.ModuleContext, dexpreopter *dexpreopter) bool { + // Store uncompressed (and aligned) any dex files from jars in APEXes. + if am, ok := ctx.Module().(android.ApexModule); ok && !am.IsForPlatform() { + return true + } + // Store uncompressed (and do not strip) dex files from boot class path jars. if inList(ctx.ModuleName(), ctx.Config().BootJars()) { return true