blob: 200e2d4685004195586060c0803ed5bc9fb580df [file] [log] [blame]
Adam Lesinski1ab598f2015-08-14 14:26:04 -07001/*
2 * Copyright (C) 2015 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Adam Lesinski46708052017-09-29 14:49:15 -070017#include "format/binary/TableFlattener.h"
Adam Lesinski1ab598f2015-08-14 14:26:04 -070018
Adam Lesinski803c7c82016-04-06 16:09:43 -070019#include <algorithm>
Adam Lesinskicacb28f2016-10-19 12:18:14 -070020#include <numeric>
Adam Lesinskid0f116b2016-07-08 15:00:32 -070021#include <sstream>
Adam Lesinski1ab598f2015-08-14 14:26:04 -070022#include <type_traits>
Adam Lesinski1ab598f2015-08-14 14:26:04 -070023
Adam Lesinskice5e56e22016-10-21 17:56:45 -070024#include "android-base/logging.h"
25#include "android-base/macros.h"
Adam Lesinski490595a2017-11-07 17:08:07 -080026#include "android-base/stringprintf.h"
Ryan Mitchell75e20dd2018-11-06 16:39:36 -080027#include "androidfw/ResourceUtils.h"
Adam Lesinskice5e56e22016-10-21 17:56:45 -070028
29#include "ResourceTable.h"
30#include "ResourceValues.h"
Adam Lesinskic8f71aa2017-02-08 07:03:50 -080031#include "SdkConstants.h"
Adam Lesinskice5e56e22016-10-21 17:56:45 -070032#include "ValueVisitor.h"
Adam Lesinski46708052017-09-29 14:49:15 -070033#include "format/binary/ChunkWriter.h"
34#include "format/binary/ResourceTypeExtensions.h"
Adam Lesinskice5e56e22016-10-21 17:56:45 -070035#include "util/BigBuffer.h"
36
Adam Lesinski1ab598f2015-08-14 14:26:04 -070037using namespace android;
38
39namespace aapt {
40
41namespace {
42
43template <typename T>
Adam Lesinskice5e56e22016-10-21 17:56:45 -070044static bool cmp_ids(const T* a, const T* b) {
Adam Lesinskicacb28f2016-10-19 12:18:14 -070045 return a->id.value() < b->id.value();
Adam Lesinski1ab598f2015-08-14 14:26:04 -070046}
47
48static void strcpy16_htod(uint16_t* dst, size_t len, const StringPiece16& src) {
Adam Lesinskicacb28f2016-10-19 12:18:14 -070049 if (len == 0) {
50 return;
51 }
Adam Lesinski1ab598f2015-08-14 14:26:04 -070052
Adam Lesinskicacb28f2016-10-19 12:18:14 -070053 size_t i;
Adam Lesinskice5e56e22016-10-21 17:56:45 -070054 const char16_t* src_data = src.data();
Adam Lesinskicacb28f2016-10-19 12:18:14 -070055 for (i = 0; i < len - 1 && i < src.size(); i++) {
Adam Lesinskice5e56e22016-10-21 17:56:45 -070056 dst[i] = util::HostToDevice16((uint16_t)src_data[i]);
Adam Lesinskicacb28f2016-10-19 12:18:14 -070057 }
58 dst[i] = 0;
Adam Lesinski1ab598f2015-08-14 14:26:04 -070059}
60
Adam Lesinskice5e56e22016-10-21 17:56:45 -070061static bool cmp_style_entries(const Style::Entry& a, const Style::Entry& b) {
Adam Lesinskicacb28f2016-10-19 12:18:14 -070062 if (a.key.id) {
63 if (b.key.id) {
64 return a.key.id.value() < b.key.id.value();
65 }
66 return true;
67 } else if (!b.key.id) {
68 return a.key.name.value() < b.key.name.value();
69 }
70 return false;
Adam Lesinski59e04c62016-02-04 15:59:23 -080071}
72
Adam Lesinski1ab598f2015-08-14 14:26:04 -070073struct FlatEntry {
Adam Lesinskicacb28f2016-10-19 12:18:14 -070074 ResourceEntry* entry;
75 Value* value;
Adam Lesinski3b4cd942015-10-30 16:31:42 -070076
Adam Lesinskicacb28f2016-10-19 12:18:14 -070077 // The entry string pool index to the entry's name.
Adam Lesinskice5e56e22016-10-21 17:56:45 -070078 uint32_t entry_key;
Adam Lesinski1ab598f2015-08-14 14:26:04 -070079};
80
Adam Lesinskid3ffa8442017-09-28 13:34:35 -070081class MapFlattenVisitor : public ValueVisitor {
Adam Lesinskicacb28f2016-10-19 12:18:14 -070082 public:
Adam Lesinskid3ffa8442017-09-28 13:34:35 -070083 using ValueVisitor::Visit;
Adam Lesinski1ab598f2015-08-14 14:26:04 -070084
Adam Lesinskice5e56e22016-10-21 17:56:45 -070085 MapFlattenVisitor(ResTable_entry_ext* out_entry, BigBuffer* buffer)
Adam Lesinski46708052017-09-29 14:49:15 -070086 : out_entry_(out_entry), buffer_(buffer) {
87 }
Adam Lesinskicacb28f2016-10-19 12:18:14 -070088
Adam Lesinskice5e56e22016-10-21 17:56:45 -070089 void Visit(Attribute* attr) override {
Adam Lesinskicacb28f2016-10-19 12:18:14 -070090 {
91 Reference key = Reference(ResourceId(ResTable_map::ATTR_TYPE));
Adam Lesinskice5e56e22016-10-21 17:56:45 -070092 BinaryPrimitive val(Res_value::TYPE_INT_DEC, attr->type_mask);
93 FlattenEntry(&key, &val);
Adam Lesinski28cacf02015-11-23 14:22:47 -080094 }
95
Adam Lesinskice5e56e22016-10-21 17:56:45 -070096 if (attr->min_int != std::numeric_limits<int32_t>::min()) {
Adam Lesinskicacb28f2016-10-19 12:18:14 -070097 Reference key = Reference(ResourceId(ResTable_map::ATTR_MIN));
Adam Lesinski46708052017-09-29 14:49:15 -070098 BinaryPrimitive val(Res_value::TYPE_INT_DEC, static_cast<uint32_t>(attr->min_int));
Adam Lesinskice5e56e22016-10-21 17:56:45 -070099 FlattenEntry(&key, &val);
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700100 }
101
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700102 if (attr->max_int != std::numeric_limits<int32_t>::max()) {
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700103 Reference key = Reference(ResourceId(ResTable_map::ATTR_MAX));
Adam Lesinski46708052017-09-29 14:49:15 -0700104 BinaryPrimitive val(Res_value::TYPE_INT_DEC, static_cast<uint32_t>(attr->max_int));
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700105 FlattenEntry(&key, &val);
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700106 }
107
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700108 for (Attribute::Symbol& s : attr->symbols) {
109 BinaryPrimitive val(Res_value::TYPE_INT_DEC, s.value);
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700110 FlattenEntry(&s.symbol, &val);
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700111 }
112 }
Adam Lesinski59e04c62016-02-04 15:59:23 -0800113
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700114 void Visit(Style* style) override {
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700115 if (style->parent) {
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700116 const Reference& parent_ref = style->parent.value();
117 CHECK(bool(parent_ref.id)) << "parent has no ID";
118 out_entry_->parent.ident = util::HostToDevice32(parent_ref.id.value().id);
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700119 }
120
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700121 // Sort the style.
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700122 std::sort(style->entries.begin(), style->entries.end(), cmp_style_entries);
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700123
124 for (Style::Entry& entry : style->entries) {
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700125 FlattenEntry(&entry.key, entry.value.get());
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700126 }
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700127 }
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700128
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700129 void Visit(Styleable* styleable) override {
130 for (auto& attr_ref : styleable->entries) {
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700131 BinaryPrimitive val(Res_value{});
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700132 FlattenEntry(&attr_ref, &val);
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700133 }
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700134 }
Adam Lesinski59e04c62016-02-04 15:59:23 -0800135
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700136 void Visit(Array* array) override {
Ryan Mitchell0f7da5e2018-08-16 16:10:00 -0700137 const size_t count = array->elements.size();
138 for (size_t i = 0; i < count; i++) {
139 Reference key(android::ResTable_map::ATTR_MIN + i);
140 FlattenEntry(&key, array->elements[i].get());
Adam Lesinski59e04c62016-02-04 15:59:23 -0800141 }
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700142 }
Adam Lesinski59e04c62016-02-04 15:59:23 -0800143
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700144 void Visit(Plural* plural) override {
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700145 const size_t count = plural->values.size();
146 for (size_t i = 0; i < count; i++) {
147 if (!plural->values[i]) {
148 continue;
149 }
150
151 ResourceId q;
152 switch (i) {
153 case Plural::Zero:
154 q.id = android::ResTable_map::ATTR_ZERO;
155 break;
156
157 case Plural::One:
158 q.id = android::ResTable_map::ATTR_ONE;
159 break;
160
161 case Plural::Two:
162 q.id = android::ResTable_map::ATTR_TWO;
163 break;
164
165 case Plural::Few:
166 q.id = android::ResTable_map::ATTR_FEW;
167 break;
168
169 case Plural::Many:
170 q.id = android::ResTable_map::ATTR_MANY;
171 break;
172
173 case Plural::Other:
174 q.id = android::ResTable_map::ATTR_OTHER;
175 break;
176
177 default:
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700178 LOG(FATAL) << "unhandled plural type";
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700179 break;
180 }
181
182 Reference key(q);
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700183 FlattenEntry(&key, plural->values[i].get());
Adam Lesinski59e04c62016-02-04 15:59:23 -0800184 }
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700185 }
Adam Lesinski59e04c62016-02-04 15:59:23 -0800186
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700187 /**
188 * Call this after visiting a Value. This will finish any work that
189 * needs to be done to prepare the entry.
190 */
Adam Lesinski46708052017-09-29 14:49:15 -0700191 void Finish() {
192 out_entry_->count = util::HostToDevice32(entry_count_);
193 }
Adam Lesinski59e04c62016-02-04 15:59:23 -0800194
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700195 private:
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700196 DISALLOW_COPY_AND_ASSIGN(MapFlattenVisitor);
197
198 void FlattenKey(Reference* key, ResTable_map* out_entry) {
199 CHECK(bool(key->id)) << "key has no ID";
200 out_entry->name.ident = util::HostToDevice32(key->id.value().id);
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700201 }
Adam Lesinski59e04c62016-02-04 15:59:23 -0800202
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700203 void FlattenValue(Item* value, ResTable_map* out_entry) {
204 CHECK(value->Flatten(&out_entry->value)) << "flatten failed";
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700205 }
206
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700207 void FlattenEntry(Reference* key, Item* value) {
208 ResTable_map* out_entry = buffer_->NextBlock<ResTable_map>();
209 FlattenKey(key, out_entry);
210 FlattenValue(value, out_entry);
211 out_entry->value.size = util::HostToDevice16(sizeof(out_entry->value));
212 entry_count_++;
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700213 }
214
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700215 ResTable_entry_ext* out_entry_;
216 BigBuffer* buffer_;
217 size_t entry_count_ = 0;
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700218};
219
Ryan Mitchell75e20dd2018-11-06 16:39:36 -0800220struct PolicyChunk {
221 uint32_t policy_flags;
222 std::set<ResourceId> ids;
223};
224
Adam Lesinski9ba47d82015-10-13 11:37:10 -0700225class PackageFlattener {
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700226 public:
Adam Lesinskiceb9b2f2017-02-16 12:05:42 -0800227 PackageFlattener(IAaptContext* context, ResourceTablePackage* package,
Luke Nicholsonb0643302017-12-01 15:29:03 -0800228 const std::map<size_t, std::string>* shared_libs, bool use_sparse_entries,
229 bool collapse_key_stringpool, const std::set<std::string>& whitelisted_resources)
Adam Lesinskic8f71aa2017-02-08 07:03:50 -0800230 : context_(context),
231 diag_(context->GetDiagnostics()),
232 package_(package),
Adam Lesinskiceb9b2f2017-02-16 12:05:42 -0800233 shared_libs_(shared_libs),
Luke Nicholsonb0643302017-12-01 15:29:03 -0800234 use_sparse_entries_(use_sparse_entries),
235 collapse_key_stringpool_(collapse_key_stringpool),
236 whitelisted_resources_(whitelisted_resources) {
Adam Lesinski46708052017-09-29 14:49:15 -0700237 }
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700238
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700239 bool FlattenPackage(BigBuffer* buffer) {
240 ChunkWriter pkg_writer(buffer);
Adam Lesinskiceb9b2f2017-02-16 12:05:42 -0800241 ResTable_package* pkg_header = pkg_writer.StartChunk<ResTable_package>(RES_TABLE_PACKAGE_TYPE);
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700242 pkg_header->id = util::HostToDevice32(package_->id.value());
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700243
Adam Lesinskib522f042017-04-21 16:57:59 -0700244 // AAPT truncated the package name, so do the same.
245 // Shared libraries require full package names, so don't truncate theirs.
246 if (context_->GetPackageType() != PackageType::kApp &&
247 package_->name.size() >= arraysize(pkg_header->name)) {
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700248 diag_->Error(DiagMessage() << "package name '" << package_->name
Adam Lesinskib522f042017-04-21 16:57:59 -0700249 << "' is too long. "
250 "Shared libraries cannot have truncated package names");
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700251 return false;
Adam Lesinski9ba47d82015-10-13 11:37:10 -0700252 }
253
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700254 // Copy the package name in device endianness.
Adam Lesinskib522f042017-04-21 16:57:59 -0700255 strcpy16_htod(pkg_header->name, arraysize(pkg_header->name), util::Utf8ToUtf16(package_->name));
Adam Lesinski9ba47d82015-10-13 11:37:10 -0700256
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700257 // Serialize the types. We do this now so that our type and key strings
258 // are populated. We write those first.
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700259 BigBuffer type_buffer(1024);
260 FlattenTypes(&type_buffer);
Adam Lesinski9ba47d82015-10-13 11:37:10 -0700261
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700262 pkg_header->typeStrings = util::HostToDevice32(pkg_writer.size());
Ryan Mitchella15c2a82018-03-26 11:05:31 -0700263 StringPool::FlattenUtf16(pkg_writer.buffer(), type_pool_, diag_);
Adam Lesinski9ba47d82015-10-13 11:37:10 -0700264
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700265 pkg_header->keyStrings = util::HostToDevice32(pkg_writer.size());
Ryan Mitchella15c2a82018-03-26 11:05:31 -0700266 StringPool::FlattenUtf8(pkg_writer.buffer(), key_pool_, diag_);
Adam Lesinski9ba47d82015-10-13 11:37:10 -0700267
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700268 // Append the types.
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700269 buffer->AppendBuffer(std::move(type_buffer));
Adam Lesinski9ba47d82015-10-13 11:37:10 -0700270
Adam Lesinskiceb9b2f2017-02-16 12:05:42 -0800271 // If there are libraries (or if the package ID is 0x00), encode a library chunk.
272 if (package_->id.value() == 0x00 || !shared_libs_->empty()) {
273 FlattenLibrarySpec(buffer);
274 }
275
Ryan Mitchell75e20dd2018-11-06 16:39:36 -0800276 FlattenOverlayable(buffer);
277
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700278 pkg_writer.Finish();
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700279 return true;
280 }
Adam Lesinski9ba47d82015-10-13 11:37:10 -0700281
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700282 private:
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700283 DISALLOW_COPY_AND_ASSIGN(PackageFlattener);
Adam Lesinski9ba47d82015-10-13 11:37:10 -0700284
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700285 template <typename T, bool IsItem>
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700286 T* WriteEntry(FlatEntry* entry, BigBuffer* buffer) {
Adam Lesinski46708052017-09-29 14:49:15 -0700287 static_assert(
288 std::is_same<ResTable_entry, T>::value || std::is_same<ResTable_entry_ext, T>::value,
289 "T must be ResTable_entry or ResTable_entry_ext");
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700290
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700291 T* result = buffer->NextBlock<T>();
292 ResTable_entry* out_entry = (ResTable_entry*)result;
Adam Lesinski71be7052017-12-12 16:48:07 -0800293 if (entry->entry->visibility.level == Visibility::Level::kPublic) {
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700294 out_entry->flags |= ResTable_entry::FLAG_PUBLIC;
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700295 }
296
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700297 if (entry->value->IsWeak()) {
298 out_entry->flags |= ResTable_entry::FLAG_WEAK;
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700299 }
300
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700301 if (!IsItem) {
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700302 out_entry->flags |= ResTable_entry::FLAG_COMPLEX;
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700303 }
304
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700305 out_entry->flags = util::HostToDevice16(out_entry->flags);
306 out_entry->key.index = util::HostToDevice32(entry->entry_key);
307 out_entry->size = util::HostToDevice16(sizeof(T));
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700308 return result;
309 }
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700310
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700311 bool FlattenValue(FlatEntry* entry, BigBuffer* buffer) {
312 if (Item* item = ValueCast<Item>(entry->value)) {
313 WriteEntry<ResTable_entry, true>(entry, buffer);
314 Res_value* outValue = buffer->NextBlock<Res_value>();
315 CHECK(item->Flatten(outValue)) << "flatten failed";
316 outValue->size = util::HostToDevice16(sizeof(*outValue));
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700317 } else {
Adam Lesinski46708052017-09-29 14:49:15 -0700318 ResTable_entry_ext* out_entry = WriteEntry<ResTable_entry_ext, false>(entry, buffer);
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700319 MapFlattenVisitor visitor(out_entry, buffer);
320 entry->value->Accept(&visitor);
321 visitor.Finish();
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700322 }
323 return true;
324 }
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700325
Adam Lesinskic8f71aa2017-02-08 07:03:50 -0800326 bool FlattenConfig(const ResourceTableType* type, const ConfigDescription& config,
327 const size_t num_total_entries, std::vector<FlatEntry>* entries,
328 BigBuffer* buffer) {
329 CHECK(num_total_entries != 0);
330 CHECK(num_total_entries <= std::numeric_limits<uint16_t>::max());
331
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700332 ChunkWriter type_writer(buffer);
Adam Lesinski46708052017-09-29 14:49:15 -0700333 ResTable_type* type_header = type_writer.StartChunk<ResTable_type>(RES_TABLE_TYPE_TYPE);
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700334 type_header->id = type->id.value();
335 type_header->config = config;
336 type_header->config.swapHtoD();
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700337
Adam Lesinskic8f71aa2017-02-08 07:03:50 -0800338 std::vector<uint32_t> offsets;
339 offsets.resize(num_total_entries, 0xffffffffu);
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700340
Adam Lesinskic8f71aa2017-02-08 07:03:50 -0800341 BigBuffer values_buffer(512);
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700342 for (FlatEntry& flat_entry : *entries) {
Adam Lesinskic8f71aa2017-02-08 07:03:50 -0800343 CHECK(static_cast<size_t>(flat_entry.entry->id.value()) < num_total_entries);
344 offsets[flat_entry.entry->id.value()] = values_buffer.size();
345 if (!FlattenValue(&flat_entry, &values_buffer)) {
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700346 diag_->Error(DiagMessage()
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700347 << "failed to flatten resource '"
Adam Lesinskic8f71aa2017-02-08 07:03:50 -0800348 << ResourceNameRef(package_->name, type->type, flat_entry.entry->name)
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700349 << "' for configuration '" << config << "'");
350 return false;
351 }
352 }
Adam Lesinskic8f71aa2017-02-08 07:03:50 -0800353
354 bool sparse_encode = use_sparse_entries_;
355
356 // Only sparse encode if the entries will be read on platforms O+.
357 sparse_encode =
358 sparse_encode && (context_->GetMinSdkVersion() >= SDK_O || config.sdkVersion >= SDK_O);
359
360 // Only sparse encode if the offsets are representable in 2 bytes.
361 sparse_encode =
362 sparse_encode && (values_buffer.size() / 4u) <= std::numeric_limits<uint16_t>::max();
363
364 // Only sparse encode if the ratio of populated entries to total entries is below some
365 // threshold.
366 sparse_encode =
367 sparse_encode && ((100 * entries->size()) / num_total_entries) < kSparseEncodingThreshold;
368
369 if (sparse_encode) {
370 type_header->entryCount = util::HostToDevice32(entries->size());
371 type_header->flags |= ResTable_type::FLAG_SPARSE;
372 ResTable_sparseTypeEntry* indices =
373 type_writer.NextBlock<ResTable_sparseTypeEntry>(entries->size());
374 for (size_t i = 0; i < num_total_entries; i++) {
375 if (offsets[i] != ResTable_type::NO_ENTRY) {
376 CHECK((offsets[i] & 0x03) == 0);
377 indices->idx = util::HostToDevice16(i);
378 indices->offset = util::HostToDevice16(offsets[i] / 4u);
379 indices++;
380 }
381 }
382 } else {
383 type_header->entryCount = util::HostToDevice32(num_total_entries);
384 uint32_t* indices = type_writer.NextBlock<uint32_t>(num_total_entries);
385 for (size_t i = 0; i < num_total_entries; i++) {
386 indices[i] = util::HostToDevice32(offsets[i]);
387 }
388 }
389
390 type_header->entriesStart = util::HostToDevice32(type_writer.size());
391 type_writer.buffer()->AppendBuffer(std::move(values_buffer));
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700392 type_writer.Finish();
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700393 return true;
394 }
395
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700396 std::vector<ResourceTableType*> CollectAndSortTypes() {
397 std::vector<ResourceTableType*> sorted_types;
398 for (auto& type : package_->types) {
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700399 if (type->type == ResourceType::kStyleable) {
400 // Styleables aren't real Resource Types, they are represented in the
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700401 // R.java file.
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700402 continue;
403 }
404
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700405 CHECK(bool(type->id)) << "type must have an ID set";
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700406
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700407 sorted_types.push_back(type.get());
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700408 }
Adam Lesinski46708052017-09-29 14:49:15 -0700409 std::sort(sorted_types.begin(), sorted_types.end(), cmp_ids<ResourceTableType>);
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700410 return sorted_types;
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700411 }
412
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700413 std::vector<ResourceEntry*> CollectAndSortEntries(ResourceTableType* type) {
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700414 // Sort the entries by entry ID.
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700415 std::vector<ResourceEntry*> sorted_entries;
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700416 for (auto& entry : type->entries) {
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700417 CHECK(bool(entry->id)) << "entry must have an ID set";
418 sorted_entries.push_back(entry.get());
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700419 }
Adam Lesinskic8f71aa2017-02-08 07:03:50 -0800420 std::sort(sorted_entries.begin(), sorted_entries.end(), cmp_ids<ResourceEntry>);
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700421 return sorted_entries;
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700422 }
423
Ryan Mitchell75e20dd2018-11-06 16:39:36 -0800424 void FlattenOverlayable(BigBuffer* buffer) {
425 std::vector<PolicyChunk> policies;
426
427 CHECK(bool(package_->id)) << "package must have an ID set when flattening <overlayable>";
428 for (auto& type : package_->types) {
429 CHECK(bool(type->id)) << "type must have an ID set when flattening <overlayable>";
430 for (auto& entry : type->entries) {
431 CHECK(bool(type->id)) << "entry must have an ID set when flattening <overlayable>";
Ryan Mitchell1bb1fe02018-11-16 11:21:41 -0800432 if (!entry->overlayable) {
433 continue;
Ryan Mitchell75e20dd2018-11-06 16:39:36 -0800434 }
Ryan Mitchell1bb1fe02018-11-16 11:21:41 -0800435
436 Overlayable overlayable = entry->overlayable.value();
437 uint32_t policy_flags = Overlayable::Policy::kNone;
438 if (overlayable.policies & Overlayable::Policy::kPublic) {
439 policy_flags |= ResTable_overlayable_policy_header::POLICY_PUBLIC;
440 }
441 if (overlayable.policies & Overlayable::Policy::kSystem) {
442 policy_flags |= ResTable_overlayable_policy_header::POLICY_SYSTEM_PARTITION;
443 }
444 if (overlayable.policies & Overlayable::Policy::kVendor) {
445 policy_flags |= ResTable_overlayable_policy_header::POLICY_VENDOR_PARTITION;
446 }
447 if (overlayable.policies & Overlayable::Policy::kProduct) {
448 policy_flags |= ResTable_overlayable_policy_header::POLICY_PRODUCT_PARTITION;
449 }
450 if (overlayable.policies & Overlayable::Policy::kProductServices) {
451 policy_flags |= ResTable_overlayable_policy_header::POLICY_PRODUCT_SERVICES_PARTITION;
452 }
453
454 if (overlayable.policies == Overlayable::Policy::kNone) {
455 // Encode overlayable entries defined without a policy as publicly overlayable
456 policy_flags |= ResTable_overlayable_policy_header::POLICY_PUBLIC;
457 }
458
459 // Find the overlayable policy chunk with the same policies as the entry
460 PolicyChunk* policy_chunk = nullptr;
461 for (PolicyChunk& policy : policies) {
462 if (policy.policy_flags == policy_flags) {
463 policy_chunk = &policy;
464 break;
465 }
466 }
467
468 // Create a new policy chunk if an existing one with the same policy cannot be found
469 if (policy_chunk == nullptr) {
470 PolicyChunk p;
471 p.policy_flags = policy_flags;
472 policies.push_back(p);
473 policy_chunk = &policies.back();
474 }
475
476 policy_chunk->ids.insert(android::make_resid(package_->id.value(), type->id.value(),
477 entry->id.value()));
Ryan Mitchell75e20dd2018-11-06 16:39:36 -0800478 }
479 }
480
481 if (policies.empty()) {
482 // Only write the overlayable chunk if the APK has overlayable entries
483 return;
484 }
485
486 ChunkWriter writer(buffer);
487 writer.StartChunk<ResTable_overlayable_header>(RES_TABLE_OVERLAYABLE_TYPE);
488
489 // Write each policy block for the overlayable
490 for (PolicyChunk& policy : policies) {
491 ChunkWriter policy_writer(buffer);
492 ResTable_overlayable_policy_header* policy_type =
493 policy_writer.StartChunk<ResTable_overlayable_policy_header>(
494 RES_TABLE_OVERLAYABLE_POLICY_TYPE);
495 policy_type->policy_flags = util::HostToDevice32(policy.policy_flags);
496 policy_type->entry_count = util::HostToDevice32(static_cast<uint32_t>(policy.ids.size()));
497
498 // Write the ids after the policy header
499 ResTable_ref* id_block = policy_writer.NextBlock<ResTable_ref>(policy.ids.size());
500 for (const ResourceId& id : policy.ids) {
501 id_block->ident = util::HostToDevice32(id.id);
502 id_block++;
503 }
504
505 policy_writer.Finish();
506 }
507
508 writer.Finish();
509 }
510
Adam Lesinski46708052017-09-29 14:49:15 -0700511 bool FlattenTypeSpec(ResourceTableType* type, std::vector<ResourceEntry*>* sorted_entries,
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700512 BigBuffer* buffer) {
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700513 ChunkWriter type_spec_writer(buffer);
514 ResTable_typeSpec* spec_header =
Adam Lesinski46708052017-09-29 14:49:15 -0700515 type_spec_writer.StartChunk<ResTable_typeSpec>(RES_TABLE_TYPE_SPEC_TYPE);
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700516 spec_header->id = type->id.value();
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700517
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700518 if (sorted_entries->empty()) {
519 type_spec_writer.Finish();
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700520 return true;
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700521 }
522
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700523 // We can't just take the size of the vector. There may be holes in the
524 // entry ID space.
525 // Since the entries are sorted by ID, the last one will be the biggest.
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700526 const size_t num_entries = sorted_entries->back()->id.value() + 1;
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700527
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700528 spec_header->entryCount = util::HostToDevice32(num_entries);
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700529
530 // Reserve space for the masks of each resource in this type. These
531 // show for which configuration axis the resource changes.
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700532 uint32_t* config_masks = type_spec_writer.NextBlock<uint32_t>(num_entries);
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700533
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700534 const size_t actual_num_entries = sorted_entries->size();
535 for (size_t entryIndex = 0; entryIndex < actual_num_entries; entryIndex++) {
536 ResourceEntry* entry = sorted_entries->at(entryIndex);
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700537
538 // Populate the config masks for this entry.
539
Adam Lesinski71be7052017-12-12 16:48:07 -0800540 if (entry->visibility.level == Visibility::Level::kPublic) {
Adam Lesinski46708052017-09-29 14:49:15 -0700541 config_masks[entry->id.value()] |= util::HostToDevice32(ResTable_typeSpec::SPEC_PUBLIC);
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700542 }
543
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700544 const size_t config_count = entry->values.size();
545 for (size_t i = 0; i < config_count; i++) {
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700546 const ConfigDescription& config = entry->values[i]->config;
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700547 for (size_t j = i + 1; j < config_count; j++) {
548 config_masks[entry->id.value()] |=
549 util::HostToDevice32(config.diff(entry->values[j]->config));
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700550 }
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700551 }
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700552 }
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700553 type_spec_writer.Finish();
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700554 return true;
555 }
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700556
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700557 bool FlattenTypes(BigBuffer* buffer) {
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700558 // Sort the types by their IDs. They will be inserted into the StringPool in
559 // this order.
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700560 std::vector<ResourceTableType*> sorted_types = CollectAndSortTypes();
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700561
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700562 size_t expected_type_id = 1;
563 for (ResourceTableType* type : sorted_types) {
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700564 // If there is a gap in the type IDs, fill in the StringPool
565 // with empty values until we reach the ID we expect.
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700566 while (type->id.value() > expected_type_id) {
567 std::stringstream type_name;
568 type_name << "?" << expected_type_id;
569 type_pool_.MakeRef(type_name.str());
570 expected_type_id++;
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700571 }
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700572 expected_type_id++;
Adam Lesinski93190b72017-11-03 15:20:17 -0700573 type_pool_.MakeRef(to_string(type->type));
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700574
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700575 std::vector<ResourceEntry*> sorted_entries = CollectAndSortEntries(type);
Adam Lesinskiceb9b2f2017-02-16 12:05:42 -0800576 if (sorted_entries.empty()) {
577 continue;
578 }
579
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700580 if (!FlattenTypeSpec(type, &sorted_entries, buffer)) {
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700581 return false;
582 }
583
Adam Lesinskic8f71aa2017-02-08 07:03:50 -0800584 // Since the entries are sorted by ID, the last ID will be the largest.
585 const size_t num_entries = sorted_entries.back()->id.value() + 1;
586
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700587 // The binary resource table lists resource entries for each
588 // configuration.
589 // We store them inverted, where a resource entry lists the values for
590 // each
591 // configuration available. Here we reverse this to match the binary
592 // table.
Adam Lesinskic8f71aa2017-02-08 07:03:50 -0800593 std::map<ConfigDescription, std::vector<FlatEntry>> config_to_entry_list_map;
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700594
Luke Nicholsonb0643302017-12-01 15:29:03 -0800595 // hardcoded string uses characters which make it an invalid resource name
596 const std::string obfuscated_resource_name = "0_resource_name_obfuscated";
597
598 for (ResourceEntry* entry : sorted_entries) {
599 uint32_t local_key_index;
600 if (!collapse_key_stringpool_ ||
601 whitelisted_resources_.find(entry->name) != whitelisted_resources_.end()) {
602 local_key_index = (uint32_t)key_pool_.MakeRef(entry->name).index();
603 } else {
604 // resource isn't whitelisted, add it as obfuscated value
605 local_key_index = (uint32_t)key_pool_.MakeRef(obfuscated_resource_name).index();
606 }
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700607 // Group values by configuration.
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700608 for (auto& config_value : entry->values) {
609 config_to_entry_list_map[config_value->config].push_back(
Luke Nicholsonb0643302017-12-01 15:29:03 -0800610 FlatEntry{entry, config_value->value.get(), local_key_index});
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700611 }
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700612 }
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700613
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700614 // Flatten a configuration value.
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700615 for (auto& entry : config_to_entry_list_map) {
Adam Lesinskic8f71aa2017-02-08 07:03:50 -0800616 if (!FlattenConfig(type, entry.first, num_entries, &entry.second, buffer)) {
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700617 return false;
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700618 }
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700619 }
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700620 }
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700621 return true;
622 }
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700623
Adam Lesinskiceb9b2f2017-02-16 12:05:42 -0800624 void FlattenLibrarySpec(BigBuffer* buffer) {
625 ChunkWriter lib_writer(buffer);
626 ResTable_lib_header* lib_header =
627 lib_writer.StartChunk<ResTable_lib_header>(RES_TABLE_LIBRARY_TYPE);
628
629 const size_t num_entries = (package_->id.value() == 0x00 ? 1 : 0) + shared_libs_->size();
630 CHECK(num_entries > 0);
631
632 lib_header->count = util::HostToDevice32(num_entries);
633
634 ResTable_lib_entry* lib_entry = buffer->NextBlock<ResTable_lib_entry>(num_entries);
635 if (package_->id.value() == 0x00) {
636 // Add this package
637 lib_entry->packageId = util::HostToDevice32(0x00);
638 strcpy16_htod(lib_entry->packageName, arraysize(lib_entry->packageName),
639 util::Utf8ToUtf16(package_->name));
640 ++lib_entry;
641 }
642
643 for (auto& map_entry : *shared_libs_) {
644 lib_entry->packageId = util::HostToDevice32(map_entry.first);
645 strcpy16_htod(lib_entry->packageName, arraysize(lib_entry->packageName),
646 util::Utf8ToUtf16(map_entry.second));
647 ++lib_entry;
648 }
649 lib_writer.Finish();
650 }
651
Adam Lesinskic8f71aa2017-02-08 07:03:50 -0800652 IAaptContext* context_;
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700653 IDiagnostics* diag_;
654 ResourceTablePackage* package_;
Adam Lesinskiceb9b2f2017-02-16 12:05:42 -0800655 const std::map<size_t, std::string>* shared_libs_;
Adam Lesinskic8f71aa2017-02-08 07:03:50 -0800656 bool use_sparse_entries_;
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700657 StringPool type_pool_;
658 StringPool key_pool_;
Luke Nicholsonb0643302017-12-01 15:29:03 -0800659 bool collapse_key_stringpool_;
660 const std::set<std::string>& whitelisted_resources_;
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700661};
662
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700663} // namespace
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700664
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700665bool TableFlattener::Consume(IAaptContext* context, ResourceTable* table) {
Ryan Mitchell4e9a9222018-11-13 10:40:07 -0800666 if (options_.sort_stringpool_entries) {
667 // We must do this before writing the resources, since the string pool IDs may change.
668 table->string_pool.Prune();
669 table->string_pool.Sort([](const StringPool::Context &a, const StringPool::Context &b) -> int {
670 int diff = util::compare(a.priority, b.priority);
671 if (diff == 0) {
672 diff = a.config.compare(b.config);
673 }
674 return diff;
675 });
676 }
Adam Lesinski9ba47d82015-10-13 11:37:10 -0700677
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700678 // Write the ResTable header.
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700679 ChunkWriter table_writer(buffer_);
Adam Lesinski4ca56972017-04-26 21:49:53 -0700680 ResTable_header* table_header = table_writer.StartChunk<ResTable_header>(RES_TABLE_TYPE);
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700681 table_header->packageCount = util::HostToDevice32(table->packages.size());
Adam Lesinski9ba47d82015-10-13 11:37:10 -0700682
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700683 // Flatten the values string pool.
Ryan Mitchella15c2a82018-03-26 11:05:31 -0700684 StringPool::FlattenUtf8(table_writer.buffer(), table->string_pool,
685 context->GetDiagnostics());
Adam Lesinski9ba47d82015-10-13 11:37:10 -0700686
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700687 BigBuffer package_buffer(1024);
Adam Lesinski9ba47d82015-10-13 11:37:10 -0700688
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700689 // Flatten each package.
690 for (auto& package : table->packages) {
Adam Lesinski8780eb62017-10-31 17:44:39 -0700691 if (context->GetPackageType() == PackageType::kApp) {
692 // Write a self mapping entry for this package if the ID is non-standard (0x7f).
693 const uint8_t package_id = package->id.value();
694 if (package_id != kFrameworkPackageId && package_id != kAppPackageId) {
Adam Lesinski490595a2017-11-07 17:08:07 -0800695 auto result = table->included_packages_.insert({package_id, package->name});
696 if (!result.second && result.first->second != package->name) {
697 // A mapping for this package ID already exists, and is a different package. Error!
698 context->GetDiagnostics()->Error(
699 DiagMessage() << android::base::StringPrintf(
700 "can't map package ID %02x to '%s'. Already mapped to '%s'", package_id,
701 package->name.c_str(), result.first->second.c_str()));
702 return false;
703 }
Adam Lesinski8780eb62017-10-31 17:44:39 -0700704 }
705 }
706
Adam Lesinskiceb9b2f2017-02-16 12:05:42 -0800707 PackageFlattener flattener(context, package.get(), &table->included_packages_,
Luke Nicholsonb0643302017-12-01 15:29:03 -0800708 options_.use_sparse_entries, options_.collapse_key_stringpool,
709 options_.whitelisted_resources);
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700710 if (!flattener.FlattenPackage(&package_buffer)) {
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700711 return false;
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700712 }
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700713 }
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700714
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700715 // Finally merge all the packages into the main buffer.
Adam Lesinskice5e56e22016-10-21 17:56:45 -0700716 table_writer.buffer()->AppendBuffer(std::move(package_buffer));
717 table_writer.Finish();
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700718 return true;
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700719}
720
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700721} // namespace aapt