summaryrefslogtreecommitdiff
path: root/tools/aapt2/LoadedApk.cpp
diff options
context:
space:
mode:
authorPierre Lecesne <lecesne@google.com>2017-02-03 19:15:03 +0000
committerPierre Lecesne <lecesne@google.com>2017-02-03 19:49:37 +0000
commitfa131d5312011fc1a95cc9a679dbe52f0a7dbe4d (patch)
treef488c2401aab2030859d822c11efe1d5838823af /tools/aapt2/LoadedApk.cpp
parent2a1232426826d08124502fc48101a8eae326fcc4 (diff)
Only compress files that were already compressed in the original APK.
Also fix a log message. Test: Manually. Unit tests pass. Change-Id: Iea236bbcfbe1a0a0894ce1bfce09c19208c5a0bc
Diffstat (limited to 'tools/aapt2/LoadedApk.cpp')
-rw-r--r--tools/aapt2/LoadedApk.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/tools/aapt2/LoadedApk.cpp b/tools/aapt2/LoadedApk.cpp
index 76792ced86b0..3d7bd9479ad8 100644
--- a/tools/aapt2/LoadedApk.cpp
+++ b/tools/aapt2/LoadedApk.cpp
@@ -86,8 +86,7 @@ bool LoadedApk::WriteToArchive(IAaptContext* context, IArchiveWriter* writer) {
if (path.find("res/") == 0 && referenced_resources.find(path) == referenced_resources.end()) {
if (context->IsVerbose()) {
context->GetDiagnostics()->Note(DiagMessage()
- << "Resource '" << path << "' not referenced in "
- << "resource table; removing from APK.");
+ << "Removing resource '" << path << "' from APK.");
}
continue;
}
@@ -110,8 +109,8 @@ bool LoadedApk::WriteToArchive(IAaptContext* context, IArchiveWriter* writer) {
}
std::unique_ptr<io::IData> data = file->OpenAsData();
- // TODO(lecesne): Only compress the files that were compressed in the original APK.
- if (!writer->StartEntry(path, ArchiveEntry::kCompress) ||
+ uint32_t compression_flags = file->WasCompressed() ? ArchiveEntry::kCompress : 0u;
+ if (!writer->StartEntry(path, compression_flags) ||
!writer->WriteEntry(data->data(), data->size()) || !writer->FinishEntry()) {
context->GetDiagnostics()->Error(DiagMessage()
<< "Error when writing file '" << path << "' in APK.");