summaryrefslogtreecommitdiff
path: root/tools/aapt2/cmd/Link.cpp
diff options
context:
space:
mode:
authorDivya Sharma <divyash@codeaurora.org>2018-02-27 08:32:05 -0800
committerDivya Sharma <divyash@codeaurora.org>2018-02-27 08:32:05 -0800
commit4e4914b22b779e6376bb00ae20636175b2a70d8c (patch)
treef4ebc5eae2c99e20aceefcc9ffc3de19782f0fbe /tools/aapt2/cmd/Link.cpp
parentdbed40a3cd31af821ea99c605664908d67df2747 (diff)
parented5d4d06907844e1c87a6ee17c4f2868a8cc6d56 (diff)
PPR1.180219.001_AOSP_Merge
Conflicts: core/res/res/values/config.xml core/res/res/values/symbols.xml packages/SystemUI/res/values/config.xml packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java telecomm/java/android/telecom/Call.java telecomm/java/android/telecom/Connection.java telecomm/java/android/telecom/ConnectionService.java Change-Id: I524d38a61608069028b3496a189118d8eff75f4b
Diffstat (limited to 'tools/aapt2/cmd/Link.cpp')
-rw-r--r--tools/aapt2/cmd/Link.cpp39
1 files changed, 32 insertions, 7 deletions
diff --git a/tools/aapt2/cmd/Link.cpp b/tools/aapt2/cmd/Link.cpp
index c9e272c32eae..12ab88345411 100644
--- a/tools/aapt2/cmd/Link.cpp
+++ b/tools/aapt2/cmd/Link.cpp
@@ -450,7 +450,7 @@ static bool IsTransitionElement(const std::string& name) {
static bool IsVectorElement(const std::string& name) {
return name == "vector" || name == "animated-vector" || name == "pathInterpolator" ||
- name == "objectAnimator" || name == "gradient";
+ name == "objectAnimator" || name == "gradient" || name == "animated-selector";
}
template <typename T>
@@ -514,6 +514,17 @@ std::vector<std::unique_ptr<xml::XmlResource>> ResourceFileFlattener::LinkAndVer
return xml_compat_versioner.Process(context_, doc, api_range);
}
+ResourceFile::Type XmlFileTypeForOutputFormat(OutputFormat format) {
+ switch (format) {
+ case OutputFormat::kApk:
+ return ResourceFile::Type::kBinaryXml;
+ case OutputFormat::kProto:
+ return ResourceFile::Type::kProtoXml;
+ }
+ LOG_ALWAYS_FATAL("unreachable");
+ return ResourceFile::Type::kUnknown;
+}
+
bool ResourceFileFlattener::Flatten(ResourceTable* table, IArchiveWriter* archive_writer) {
bool error = false;
std::map<std::pair<ConfigDescription, StringPiece>, FileOperation> config_sorted_files;
@@ -587,6 +598,9 @@ bool ResourceFileFlattener::Flatten(ResourceTable* table, IArchiveWriter* archiv
}
}
+ // Update the type that this file will be written as.
+ file_ref->type = XmlFileTypeForOutputFormat(options_.output_format);
+
file_op.xml_to_flatten->file.config = config_value->config;
file_op.xml_to_flatten->file.source = file_ref->GetSource();
file_op.xml_to_flatten->file.name = ResourceName(pkg->name, type->type, entry->name);
@@ -625,12 +639,16 @@ bool ResourceFileFlattener::Flatten(ResourceTable* table, IArchiveWriter* archiv
<< config << "' -> '" << doc->file.config << "'");
}
- dst_path =
- ResourceUtils::BuildResourceFileName(doc->file, context_->GetNameMangler());
- bool result =
- table->AddFileReferenceMangled(doc->file.name, doc->file.config, doc->file.source,
- dst_path, nullptr, context_->GetDiagnostics());
- if (!result) {
+ const ResourceFile& file = doc->file;
+ dst_path = ResourceUtils::BuildResourceFileName(file, context_->GetNameMangler());
+
+ std::unique_ptr<FileReference> file_ref =
+ util::make_unique<FileReference>(table->string_pool.MakeRef(dst_path));
+ file_ref->SetSource(doc->file.source);
+ // Update the output format of this XML file.
+ file_ref->type = XmlFileTypeForOutputFormat(options_.output_format);
+ if (!table->AddResourceMangled(file.name, file.config, {}, std::move(file_ref),
+ context_->GetDiagnostics())) {
return false;
}
}
@@ -1446,6 +1464,13 @@ class LinkCommand {
ContainerReaderEntry* entry;
ContainerReader reader(input_stream.get());
+
+ if (reader.HadError()) {
+ context_->GetDiagnostics()->Error(DiagMessage(src)
+ << "failed to read file: " << reader.GetError());
+ return false;
+ }
+
while ((entry = reader.Next()) != nullptr) {
if (entry->Type() == ContainerEntryType::kResTable) {
pb::ResourceTable pb_table;