aapt: enforce 0 compression
In extension to the commit f0e2610c81d(aapt: default to 0 compression),
this commit now enforces 0 compression for every contents inside an apk.
Change-Id: Idd5a1b4da9f35f7a29f5595ed51fcb2e66b73816
Signed-off-by: Park Ju Hyung <qkrwngud825@gmail.com>
diff --git a/tools/aapt/Android.mk b/tools/aapt/Android.mk
index f10ff9f..8a8d8c9 100644
--- a/tools/aapt/Android.mk
+++ b/tools/aapt/Android.mk
@@ -68,7 +68,7 @@
aaptCFlags += -Wall -Werror
ifeq ($(TARGET_WANTS_AAPT_COMPRESS),true)
-aaptCFlags += -DAAPT_COMPRESS=1
+aaptCFlags += -DAAPT_COMPRESS
endif
aaptHostLdLibs_linux := -lrt -ldl -lpthread
diff --git a/tools/aapt/Main.cpp b/tools/aapt/Main.cpp
index c54081a..ef63c02 100644
--- a/tools/aapt/Main.cpp
+++ b/tools/aapt/Main.cpp
@@ -266,7 +266,7 @@
int tolerance = 0;
/* default to 0 compression, unless the target opted out*/
-#if AAPT_COMPRESS
+#ifdef AAPT_COMPRESS
bundle.setCompressionMethod(ZipEntry::kCompressDeflated);
#else
bundle.setCompressionMethod(ZipEntry::kCompressStored);
diff --git a/tools/aapt/Package.cpp b/tools/aapt/Package.cpp
index d631f35..a67fbba 100644
--- a/tools/aapt/Package.cpp
+++ b/tools/aapt/Package.cpp
@@ -323,11 +323,16 @@
if (fromGzip) {
result = zip->addGzip(file->getSourceFile().string(), storageName.string(), &entry);
} else if (!hasData) {
+ int compressionMethod;
+#ifdef AAPT_COMPRESS
/* don't compress certain files, e.g. PNGs */
- int compressionMethod = bundle->getCompressionMethod();
+ compressionMethod = bundle->getCompressionMethod();
if (!okayToCompress(bundle, storageName)) {
compressionMethod = ZipEntry::kCompressStored;
}
+#else
+ compressionMethod = ZipEntry::kCompressStored;
+#endif
result = zip->add(file->getSourceFile().string(), storageName.string(), compressionMethod,
&entry);
} else {
diff --git a/tools/aapt/Resource.cpp b/tools/aapt/Resource.cpp
index fc38f82..6572fe7 100644
--- a/tools/aapt/Resource.cpp
+++ b/tools/aapt/Resource.cpp
@@ -1149,7 +1149,11 @@
if (err < NO_ERROR) {
return err;
}
+#ifdef AAPT_COMPRESS
outFile->setCompressionMethod(ZipEntry::kCompressDeflated);
+#else
+ outFile->setCompressionMethod(ZipEntry::kCompressStored);
+#endif
return NO_ERROR;
}
diff --git a/tools/aapt/ResourceTable.cpp b/tools/aapt/ResourceTable.cpp
index b9ec575..6efae6f 100644
--- a/tools/aapt/ResourceTable.cpp
+++ b/tools/aapt/ResourceTable.cpp
@@ -133,8 +133,12 @@
printXMLBlock(&tree);
}
+#ifdef AAPT_COMPRESS
target->setCompressionMethod(ZipEntry::kCompressDeflated);
-
+#else
+ target->setCompressionMethod(ZipEntry::kCompressStored);
+#endif
+
return err;
}