summaryrefslogtreecommitdiff
path: root/tools/aapt2/LoadedApk.cpp
diff options
context:
space:
mode:
authorAdam Lesinski <adamlesinski@google.com>2017-04-03 18:12:45 -0700
committerAdam Lesinski <adamlesinski@google.com>2017-04-10 11:59:18 -0700
commitd0f492db038c6210c1138865d816bfb134376538 (patch)
tree1d4ed362037758111a28ecb453d527403d5d6815 /tools/aapt2/LoadedApk.cpp
parent0015a153536c51cdd66dce5e9f08d19eb517fab8 (diff)
AAPT2: Share split functionality between link and optimize
Generating splits should be possible to do from the optimize command. This means that a lot of infrastructure around split APKs can be shared by both the optimize and link phase. Bug: 35925830 Change-Id: Ia88b9e4bff300a56353b2f7a4a2547c8eb43a299 Test: manual
Diffstat (limited to 'tools/aapt2/LoadedApk.cpp')
-rw-r--r--tools/aapt2/LoadedApk.cpp22
1 files changed, 9 insertions, 13 deletions
diff --git a/tools/aapt2/LoadedApk.cpp b/tools/aapt2/LoadedApk.cpp
index b855f8f80c58..8a8f8be205e7 100644
--- a/tools/aapt2/LoadedApk.cpp
+++ b/tools/aapt2/LoadedApk.cpp
@@ -21,6 +21,7 @@
#include "flatten/Archive.h"
#include "flatten/TableFlattener.h"
#include "io/BigBufferInputStream.h"
+#include "io/Util.h"
namespace aapt {
@@ -47,11 +48,10 @@ std::unique_ptr<LoadedApk> LoadedApk::LoadApkFromPath(IAaptContext* context,
}
std::unique_ptr<ResourceTable> table = util::make_unique<ResourceTable>();
- BinaryResourceParser parser(context, table.get(), source, data->data(), data->size());
+ BinaryResourceParser parser(context, table.get(), source, data->data(), data->size(), apk.get());
if (!parser.Parse()) {
return {};
}
-
return util::make_unique<LoadedApk>(source, std::move(apk), std::move(table));
}
@@ -100,20 +100,16 @@ bool LoadedApk::WriteToArchive(IAaptContext* context, const TableFlattenerOption
}
io::BigBufferInputStream input_stream(&buffer);
- if (!writer->WriteFile(path, ArchiveEntry::kAlign, &input_stream)) {
- context->GetDiagnostics()->Error(DiagMessage()
- << "Error when writing file '" << path << "' in APK.");
+ if (!io::CopyInputStreamToArchive(context, &input_stream, path, ArchiveEntry::kAlign,
+ writer)) {
return false;
}
- continue;
- }
- std::unique_ptr<io::IData> data = file->OpenAsData();
- uint32_t compression_flags = file->WasCompressed() ? ArchiveEntry::kCompress : 0u;
- if (!writer->WriteFile(path, compression_flags, data.get())) {
- context->GetDiagnostics()->Error(DiagMessage()
- << "Error when writing file '" << path << "' in APK.");
- return false;
+ } else {
+ uint32_t compression_flags = file->WasCompressed() ? ArchiveEntry::kCompress : 0u;
+ if (!io::CopyFileToArchive(context, file, path, compression_flags, writer)) {
+ return false;
+ }
}
}
return true;