blob: 882dc0d71759b0a87c3bf62cd1fa74d390c1bef6 [file] [log] [blame]
Adam Lesinski7ad11102016-10-28 16:39:15 -07001/*
2 * Copyright (C) 2016 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
17#define ATRACE_TAG ATRACE_TAG_RESOURCES
18
19#include "androidfw/LoadedArsc.h"
20
Adam Lesinski73f6f9d2017-11-14 10:18:05 -080021#include <algorithm>
Adam Lesinski7ad11102016-10-28 16:39:15 -070022#include <cstddef>
23#include <limits>
24
25#include "android-base/logging.h"
26#include "android-base/stringprintf.h"
27#include "utils/ByteOrder.h"
28#include "utils/Trace.h"
29
30#ifdef _WIN32
31#ifdef ERROR
32#undef ERROR
33#endif
34#endif
35
Adam Lesinski7ad11102016-10-28 16:39:15 -070036#include "androidfw/ByteBucketArray.h"
Adam Lesinskida431a22016-12-29 16:08:16 -050037#include "androidfw/Chunk.h"
Adam Lesinski929d6512017-01-16 19:11:19 -080038#include "androidfw/ResourceUtils.h"
Adam Lesinski7ad11102016-10-28 16:39:15 -070039#include "androidfw/Util.h"
40
Adam Lesinski970bd8d2017-09-25 13:21:55 -070041using ::android::base::StringPrintf;
Adam Lesinski7ad11102016-10-28 16:39:15 -070042
43namespace android {
44
Adam Lesinskida431a22016-12-29 16:08:16 -050045constexpr const static int kAppPackageId = 0x7f;
Adam Lesinski7ad11102016-10-28 16:39:15 -070046
Adam Lesinskida431a22016-12-29 16:08:16 -050047namespace {
48
Adam Lesinski7ad11102016-10-28 16:39:15 -070049// Builder that helps accumulate Type structs and then create a single
50// contiguous block of memory to store both the TypeSpec struct and
51// the Type structs.
52class TypeSpecPtrBuilder {
53 public:
Adam Lesinski970bd8d2017-09-25 13:21:55 -070054 explicit TypeSpecPtrBuilder(const ResTable_typeSpec* header,
55 const IdmapEntry_header* idmap_header)
56 : header_(header), idmap_header_(idmap_header) {
57 }
Adam Lesinski7ad11102016-10-28 16:39:15 -070058
59 void AddType(const ResTable_type* type) {
Adam Lesinskibebfcc42018-02-12 14:27:46 -080060 types_.push_back(type);
Adam Lesinski7ad11102016-10-28 16:39:15 -070061 }
62
63 TypeSpecPtr Build() {
64 // Check for overflow.
Adam Lesinskibebfcc42018-02-12 14:27:46 -080065 using ElementType = const ResTable_type*;
66 if ((std::numeric_limits<size_t>::max() - sizeof(TypeSpec)) / sizeof(ElementType) <
67 types_.size()) {
Adam Lesinski7ad11102016-10-28 16:39:15 -070068 return {};
69 }
Adam Lesinskibebfcc42018-02-12 14:27:46 -080070 TypeSpec* type_spec =
71 (TypeSpec*)::malloc(sizeof(TypeSpec) + (types_.size() * sizeof(ElementType)));
Adam Lesinski7ad11102016-10-28 16:39:15 -070072 type_spec->type_spec = header_;
Adam Lesinski970bd8d2017-09-25 13:21:55 -070073 type_spec->idmap_entries = idmap_header_;
Adam Lesinski7ad11102016-10-28 16:39:15 -070074 type_spec->type_count = types_.size();
Adam Lesinskibebfcc42018-02-12 14:27:46 -080075 memcpy(type_spec + 1, types_.data(), types_.size() * sizeof(ElementType));
Adam Lesinski7ad11102016-10-28 16:39:15 -070076 return TypeSpecPtr(type_spec);
77 }
78
79 private:
80 DISALLOW_COPY_AND_ASSIGN(TypeSpecPtrBuilder);
81
82 const ResTable_typeSpec* header_;
Adam Lesinski970bd8d2017-09-25 13:21:55 -070083 const IdmapEntry_header* idmap_header_;
Adam Lesinskibebfcc42018-02-12 14:27:46 -080084 std::vector<const ResTable_type*> types_;
Adam Lesinski7ad11102016-10-28 16:39:15 -070085};
86
87} // namespace
88
Adam Lesinski1a1e9c22017-10-13 15:45:34 -070089LoadedPackage::LoadedPackage() = default;
90LoadedPackage::~LoadedPackage() = default;
91
92// Precondition: The header passed in has already been verified, so reading any fields and trusting
93// the ResChunk_header is safe.
94static bool VerifyResTableType(const ResTable_type* header) {
Adam Lesinski498f6052017-11-29 13:24:29 -080095 if (header->id == 0) {
96 LOG(ERROR) << "RES_TABLE_TYPE_TYPE has invalid ID 0.";
97 return false;
98 }
99
Adam Lesinski1a1e9c22017-10-13 15:45:34 -0700100 const size_t entry_count = dtohl(header->entryCount);
101 if (entry_count > std::numeric_limits<uint16_t>::max()) {
Adam Lesinski498f6052017-11-29 13:24:29 -0800102 LOG(ERROR) << "RES_TABLE_TYPE_TYPE has too many entries (" << entry_count << ").";
Adam Lesinski1a1e9c22017-10-13 15:45:34 -0700103 return false;
104 }
105
106 // Make sure that there is enough room for the entry offsets.
107 const size_t offsets_offset = dtohs(header->header.headerSize);
108 const size_t entries_offset = dtohl(header->entriesStart);
109 const size_t offsets_length = sizeof(uint32_t) * entry_count;
110
111 if (offsets_offset > entries_offset || entries_offset - offsets_offset < offsets_length) {
Adam Lesinski498f6052017-11-29 13:24:29 -0800112 LOG(ERROR) << "RES_TABLE_TYPE_TYPE entry offsets overlap actual entry data.";
Adam Lesinski1a1e9c22017-10-13 15:45:34 -0700113 return false;
114 }
115
116 if (entries_offset > dtohl(header->header.size)) {
Adam Lesinski498f6052017-11-29 13:24:29 -0800117 LOG(ERROR) << "RES_TABLE_TYPE_TYPE entry offsets extend beyond chunk.";
Adam Lesinski1a1e9c22017-10-13 15:45:34 -0700118 return false;
119 }
120
121 if (entries_offset & 0x03) {
Adam Lesinski498f6052017-11-29 13:24:29 -0800122 LOG(ERROR) << "RES_TABLE_TYPE_TYPE entries start at unaligned address.";
Adam Lesinski1a1e9c22017-10-13 15:45:34 -0700123 return false;
124 }
125 return true;
126}
127
Adam Lesinskibebfcc42018-02-12 14:27:46 -0800128static bool VerifyResTableEntry(const ResTable_type* type, uint32_t entry_offset) {
Adam Lesinski1a1e9c22017-10-13 15:45:34 -0700129 // Check that the offset is aligned.
130 if (entry_offset & 0x03) {
Adam Lesinskibebfcc42018-02-12 14:27:46 -0800131 LOG(ERROR) << "Entry at offset " << entry_offset << " is not 4-byte aligned.";
Adam Lesinski1a1e9c22017-10-13 15:45:34 -0700132 return false;
133 }
134
135 // Check that the offset doesn't overflow.
136 if (entry_offset > std::numeric_limits<uint32_t>::max() - dtohl(type->entriesStart)) {
137 // Overflow in offset.
Adam Lesinskibebfcc42018-02-12 14:27:46 -0800138 LOG(ERROR) << "Entry at offset " << entry_offset << " is too large.";
Adam Lesinski1a1e9c22017-10-13 15:45:34 -0700139 return false;
140 }
141
142 const size_t chunk_size = dtohl(type->header.size);
143
144 entry_offset += dtohl(type->entriesStart);
145 if (entry_offset > chunk_size - sizeof(ResTable_entry)) {
Adam Lesinskibebfcc42018-02-12 14:27:46 -0800146 LOG(ERROR) << "Entry at offset " << entry_offset
Adam Lesinski1a1e9c22017-10-13 15:45:34 -0700147 << " is too large. No room for ResTable_entry.";
148 return false;
149 }
150
151 const ResTable_entry* entry = reinterpret_cast<const ResTable_entry*>(
152 reinterpret_cast<const uint8_t*>(type) + entry_offset);
153
154 const size_t entry_size = dtohs(entry->size);
155 if (entry_size < sizeof(*entry)) {
Adam Lesinskibebfcc42018-02-12 14:27:46 -0800156 LOG(ERROR) << "ResTable_entry size " << entry_size << " at offset " << entry_offset
Adam Lesinski1a1e9c22017-10-13 15:45:34 -0700157 << " is too small.";
158 return false;
159 }
160
161 if (entry_size > chunk_size || entry_offset > chunk_size - entry_size) {
Adam Lesinskibebfcc42018-02-12 14:27:46 -0800162 LOG(ERROR) << "ResTable_entry size " << entry_size << " at offset " << entry_offset
Adam Lesinski1a1e9c22017-10-13 15:45:34 -0700163 << " is too large.";
164 return false;
165 }
166
167 if (entry_size < sizeof(ResTable_map_entry)) {
168 // There needs to be room for one Res_value struct.
169 if (entry_offset + entry_size > chunk_size - sizeof(Res_value)) {
Adam Lesinskibebfcc42018-02-12 14:27:46 -0800170 LOG(ERROR) << "No room for Res_value after ResTable_entry at offset " << entry_offset
Adam Lesinski1a1e9c22017-10-13 15:45:34 -0700171 << " for type " << (int)type->id << ".";
172 return false;
173 }
174
175 const Res_value* value =
176 reinterpret_cast<const Res_value*>(reinterpret_cast<const uint8_t*>(entry) + entry_size);
177 const size_t value_size = dtohs(value->size);
178 if (value_size < sizeof(Res_value)) {
Adam Lesinskibebfcc42018-02-12 14:27:46 -0800179 LOG(ERROR) << "Res_value at offset " << entry_offset << " is too small.";
Adam Lesinski1a1e9c22017-10-13 15:45:34 -0700180 return false;
181 }
182
183 if (value_size > chunk_size || entry_offset + entry_size > chunk_size - value_size) {
Adam Lesinskibebfcc42018-02-12 14:27:46 -0800184 LOG(ERROR) << "Res_value size " << value_size << " at offset " << entry_offset
Adam Lesinski1a1e9c22017-10-13 15:45:34 -0700185 << " is too large.";
186 return false;
187 }
188 } else {
189 const ResTable_map_entry* map = reinterpret_cast<const ResTable_map_entry*>(entry);
190 const size_t map_entry_count = dtohl(map->count);
191 size_t map_entries_start = entry_offset + entry_size;
192 if (map_entries_start & 0x03) {
Adam Lesinskibebfcc42018-02-12 14:27:46 -0800193 LOG(ERROR) << "Map entries at offset " << entry_offset << " start at unaligned offset.";
Adam Lesinski1a1e9c22017-10-13 15:45:34 -0700194 return false;
195 }
196
197 // Each entry is sizeof(ResTable_map) big.
198 if (map_entry_count > ((chunk_size - map_entries_start) / sizeof(ResTable_map))) {
Adam Lesinskibebfcc42018-02-12 14:27:46 -0800199 LOG(ERROR) << "Too many map entries in ResTable_map_entry at offset " << entry_offset << ".";
Adam Lesinski1a1e9c22017-10-13 15:45:34 -0700200 return false;
201 }
202 }
203 return true;
204}
205
MÃ¥rten Kongstad3f1f4fc2018-03-02 09:34:18 +0100206LoadedPackage::iterator::iterator(const LoadedPackage* lp, size_t ti, size_t ei)
207 : loadedPackage_(lp),
208 typeIndex_(ti),
209 entryIndex_(ei),
210 typeIndexEnd_(lp->resource_ids_.size() + 1) {
211 while (typeIndex_ < typeIndexEnd_ && loadedPackage_->resource_ids_[typeIndex_] == 0) {
212 typeIndex_++;
213 }
214}
215
216LoadedPackage::iterator& LoadedPackage::iterator::operator++() {
217 while (typeIndex_ < typeIndexEnd_) {
218 if (entryIndex_ + 1 < loadedPackage_->resource_ids_[typeIndex_]) {
219 entryIndex_++;
220 break;
221 }
222 entryIndex_ = 0;
223 typeIndex_++;
224 if (typeIndex_ < typeIndexEnd_ && loadedPackage_->resource_ids_[typeIndex_] != 0) {
225 break;
226 }
227 }
228 return *this;
229}
230
231uint32_t LoadedPackage::iterator::operator*() const {
232 if (typeIndex_ >= typeIndexEnd_) {
233 return 0;
234 }
235 return make_resid(loadedPackage_->package_id_, typeIndex_ + loadedPackage_->type_id_offset_,
236 entryIndex_);
237}
238
Adam Lesinskibebfcc42018-02-12 14:27:46 -0800239const ResTable_entry* LoadedPackage::GetEntry(const ResTable_type* type_chunk,
240 uint16_t entry_index) {
241 uint32_t entry_offset = GetEntryOffset(type_chunk, entry_index);
242 if (entry_offset == ResTable_type::NO_ENTRY) {
243 return nullptr;
244 }
245 return GetEntryFromOffset(type_chunk, entry_offset);
246}
Adam Lesinski1a1e9c22017-10-13 15:45:34 -0700247
Adam Lesinskibebfcc42018-02-12 14:27:46 -0800248uint32_t LoadedPackage::GetEntryOffset(const ResTable_type* type_chunk, uint16_t entry_index) {
249 // The configuration matches and is better than the previous selection.
250 // Find the entry value if it exists for this configuration.
251 const size_t entry_count = dtohl(type_chunk->entryCount);
252 const size_t offsets_offset = dtohs(type_chunk->header.headerSize);
Adam Lesinski1a1e9c22017-10-13 15:45:34 -0700253
Adam Lesinskibebfcc42018-02-12 14:27:46 -0800254 // Check if there is the desired entry in this type.
Adam Lesinski73f6f9d2017-11-14 10:18:05 -0800255
Adam Lesinskibebfcc42018-02-12 14:27:46 -0800256 if (type_chunk->flags & ResTable_type::FLAG_SPARSE) {
257 // This is encoded as a sparse map, so perform a binary search.
258 const ResTable_sparseTypeEntry* sparse_indices =
259 reinterpret_cast<const ResTable_sparseTypeEntry*>(
Adam Lesinski73f6f9d2017-11-14 10:18:05 -0800260 reinterpret_cast<const uint8_t*>(type_chunk) + offsets_offset);
Adam Lesinskibebfcc42018-02-12 14:27:46 -0800261 const ResTable_sparseTypeEntry* sparse_indices_end = sparse_indices + entry_count;
262 const ResTable_sparseTypeEntry* result =
263 std::lower_bound(sparse_indices, sparse_indices_end, entry_index,
264 [](const ResTable_sparseTypeEntry& entry, uint16_t entry_idx) {
265 return dtohs(entry.idx) < entry_idx;
266 });
Adam Lesinski73f6f9d2017-11-14 10:18:05 -0800267
Adam Lesinskibebfcc42018-02-12 14:27:46 -0800268 if (result == sparse_indices_end || dtohs(result->idx) != entry_index) {
269 // No entry found.
270 return ResTable_type::NO_ENTRY;
Adam Lesinski1a1e9c22017-10-13 15:45:34 -0700271 }
Adam Lesinskibebfcc42018-02-12 14:27:46 -0800272
273 // Extract the offset from the entry. Each offset must be a multiple of 4 so we store it as
274 // the real offset divided by 4.
275 return uint32_t{dtohs(result->offset)} * 4u;
Adam Lesinski1a1e9c22017-10-13 15:45:34 -0700276 }
277
Adam Lesinskibebfcc42018-02-12 14:27:46 -0800278 // This type is encoded as a dense array.
279 if (entry_index >= entry_count) {
280 // This entry cannot be here.
281 return ResTable_type::NO_ENTRY;
Adam Lesinski1a1e9c22017-10-13 15:45:34 -0700282 }
283
Adam Lesinskibebfcc42018-02-12 14:27:46 -0800284 const uint32_t* entry_offsets = reinterpret_cast<const uint32_t*>(
285 reinterpret_cast<const uint8_t*>(type_chunk) + offsets_offset);
286 return dtohl(entry_offsets[entry_index]);
Adam Lesinski1a1e9c22017-10-13 15:45:34 -0700287}
288
Adam Lesinskibebfcc42018-02-12 14:27:46 -0800289const ResTable_entry* LoadedPackage::GetEntryFromOffset(const ResTable_type* type_chunk,
290 uint32_t offset) {
291 if (UNLIKELY(!VerifyResTableEntry(type_chunk, offset))) {
292 return nullptr;
Adam Lesinski7ad11102016-10-28 16:39:15 -0700293 }
Adam Lesinskibebfcc42018-02-12 14:27:46 -0800294 return reinterpret_cast<const ResTable_entry*>(reinterpret_cast<const uint8_t*>(type_chunk) +
295 offset + dtohl(type_chunk->entriesStart));
Adam Lesinski7ad11102016-10-28 16:39:15 -0700296}
297
Adam Lesinski0c405242017-01-13 20:47:26 -0800298void LoadedPackage::CollectConfigurations(bool exclude_mipmap,
299 std::set<ResTable_config>* out_configs) const {
300 const static std::u16string kMipMap = u"mipmap";
301 const size_t type_count = type_specs_.size();
302 for (size_t i = 0; i < type_count; i++) {
Adam Lesinskibebfcc42018-02-12 14:27:46 -0800303 const TypeSpecPtr& type_spec = type_specs_[i];
Adam Lesinski0c405242017-01-13 20:47:26 -0800304 if (type_spec != nullptr) {
305 if (exclude_mipmap) {
306 const int type_idx = type_spec->type_spec->id - 1;
307 size_t type_name_len;
308 const char16_t* type_name16 = type_string_pool_.stringAt(type_idx, &type_name_len);
309 if (type_name16 != nullptr) {
310 if (kMipMap.compare(0, std::u16string::npos, type_name16, type_name_len) == 0) {
311 // This is a mipmap type, skip collection.
312 continue;
313 }
314 }
315 const char* type_name = type_string_pool_.string8At(type_idx, &type_name_len);
316 if (type_name != nullptr) {
317 if (strncmp(type_name, "mipmap", type_name_len) == 0) {
318 // This is a mipmap type, skip collection.
319 continue;
320 }
321 }
322 }
323
Adam Lesinskibebfcc42018-02-12 14:27:46 -0800324 const auto iter_end = type_spec->types + type_spec->type_count;
325 for (auto iter = type_spec->types; iter != iter_end; ++iter) {
326 ResTable_config config;
327 config.copyFromDtoH((*iter)->config);
328 out_configs->insert(config);
Adam Lesinski0c405242017-01-13 20:47:26 -0800329 }
330 }
331 }
332}
333
334void LoadedPackage::CollectLocales(bool canonicalize, std::set<std::string>* out_locales) const {
335 char temp_locale[RESTABLE_MAX_LOCALE_LEN];
336 const size_t type_count = type_specs_.size();
337 for (size_t i = 0; i < type_count; i++) {
Adam Lesinskibebfcc42018-02-12 14:27:46 -0800338 const TypeSpecPtr& type_spec = type_specs_[i];
Adam Lesinski0c405242017-01-13 20:47:26 -0800339 if (type_spec != nullptr) {
Adam Lesinskibebfcc42018-02-12 14:27:46 -0800340 const auto iter_end = type_spec->types + type_spec->type_count;
341 for (auto iter = type_spec->types; iter != iter_end; ++iter) {
342 ResTable_config configuration;
343 configuration.copyFromDtoH((*iter)->config);
Adam Lesinski0c405242017-01-13 20:47:26 -0800344 if (configuration.locale != 0) {
345 configuration.getBcp47Locale(temp_locale, canonicalize);
346 std::string locale(temp_locale);
347 out_locales->insert(std::move(locale));
348 }
349 }
350 }
351 }
352}
353
Adam Lesinski929d6512017-01-16 19:11:19 -0800354uint32_t LoadedPackage::FindEntryByName(const std::u16string& type_name,
355 const std::u16string& entry_name) const {
356 ssize_t type_idx = type_string_pool_.indexOfString(type_name.data(), type_name.size());
357 if (type_idx < 0) {
358 return 0u;
359 }
360
361 ssize_t key_idx = key_string_pool_.indexOfString(entry_name.data(), entry_name.size());
362 if (key_idx < 0) {
363 return 0u;
364 }
365
366 const TypeSpec* type_spec = type_specs_[type_idx].get();
367 if (type_spec == nullptr) {
368 return 0u;
369 }
370
Adam Lesinskibebfcc42018-02-12 14:27:46 -0800371 const auto iter_end = type_spec->types + type_spec->type_count;
372 for (auto iter = type_spec->types; iter != iter_end; ++iter) {
373 const ResTable_type* type = *iter;
374 size_t entry_count = dtohl(type->entryCount);
Adam Lesinski929d6512017-01-16 19:11:19 -0800375 for (size_t entry_idx = 0; entry_idx < entry_count; entry_idx++) {
376 const uint32_t* entry_offsets = reinterpret_cast<const uint32_t*>(
Adam Lesinskibebfcc42018-02-12 14:27:46 -0800377 reinterpret_cast<const uint8_t*>(type) + dtohs(type->header.headerSize));
Adam Lesinski929d6512017-01-16 19:11:19 -0800378 const uint32_t offset = dtohl(entry_offsets[entry_idx]);
379 if (offset != ResTable_type::NO_ENTRY) {
Adam Lesinskibebfcc42018-02-12 14:27:46 -0800380 const ResTable_entry* entry = reinterpret_cast<const ResTable_entry*>(
381 reinterpret_cast<const uint8_t*>(type) + dtohl(type->entriesStart) + offset);
Adam Lesinski929d6512017-01-16 19:11:19 -0800382 if (dtohl(entry->key.index) == static_cast<uint32_t>(key_idx)) {
383 // The package ID will be overridden by the caller (due to runtime assignment of package
384 // IDs for shared libraries).
385 return make_resid(0x00, type_idx + type_id_offset_ + 1, entry_idx);
386 }
387 }
388 }
389 }
390 return 0u;
391}
392
Adam Lesinskibebfcc42018-02-12 14:27:46 -0800393const LoadedPackage* LoadedArsc::GetPackageById(uint8_t package_id) const {
Adam Lesinski1a1e9c22017-10-13 15:45:34 -0700394 for (const auto& loaded_package : packages_) {
395 if (loaded_package->GetPackageId() == package_id) {
396 return loaded_package.get();
397 }
398 }
399 return nullptr;
400}
401
402std::unique_ptr<const LoadedPackage> LoadedPackage::Load(const Chunk& chunk,
403 const LoadedIdmap* loaded_idmap,
Winson9947f1e2019-08-16 10:20:39 -0700404 bool system,
405 bool load_as_shared_library,
406 bool for_loader) {
Adam Lesinskibebfcc42018-02-12 14:27:46 -0800407 ATRACE_NAME("LoadedPackage::Load");
Adam Lesinski1a1e9c22017-10-13 15:45:34 -0700408 std::unique_ptr<LoadedPackage> loaded_package(new LoadedPackage());
Adam Lesinskida431a22016-12-29 16:08:16 -0500409
Adam Lesinski970bd8d2017-09-25 13:21:55 -0700410 // typeIdOffset was added at some point, but we still must recognize apps built before this
411 // was added.
Adam Lesinski33af6c72017-03-29 13:00:35 -0700412 constexpr size_t kMinPackageSize =
413 sizeof(ResTable_package) - sizeof(ResTable_package::typeIdOffset);
414 const ResTable_package* header = chunk.header<ResTable_package, kMinPackageSize>();
Adam Lesinski7ad11102016-10-28 16:39:15 -0700415 if (header == nullptr) {
Adam Lesinski498f6052017-11-29 13:24:29 -0800416 LOG(ERROR) << "RES_TABLE_PACKAGE_TYPE too small.";
Adam Lesinskida431a22016-12-29 16:08:16 -0500417 return {};
Adam Lesinski7ad11102016-10-28 16:39:15 -0700418 }
419
Adam Lesinski1a1e9c22017-10-13 15:45:34 -0700420 loaded_package->system_ = system;
421
Adam Lesinski7ad11102016-10-28 16:39:15 -0700422 loaded_package->package_id_ = dtohl(header->id);
Adam Lesinski1a1e9c22017-10-13 15:45:34 -0700423 if (loaded_package->package_id_ == 0 ||
424 (loaded_package->package_id_ == kAppPackageId && load_as_shared_library)) {
Adam Lesinskida431a22016-12-29 16:08:16 -0500425 // Package ID of 0 means this is a shared library.
426 loaded_package->dynamic_ = true;
427 }
428
Adam Lesinski970bd8d2017-09-25 13:21:55 -0700429 if (loaded_idmap != nullptr) {
430 // This is an overlay and so it needs to pretend to be the target package.
431 loaded_package->package_id_ = loaded_idmap->TargetPackageId();
432 loaded_package->overlay_ = true;
433 }
434
Winson9947f1e2019-08-16 10:20:39 -0700435 if (for_loader) {
436 loaded_package->custom_loader_ = true;
437 }
438
Adam Lesinskic6aada92017-01-13 15:34:14 -0800439 if (header->header.headerSize >= sizeof(ResTable_package)) {
440 uint32_t type_id_offset = dtohl(header->typeIdOffset);
441 if (type_id_offset > std::numeric_limits<uint8_t>::max()) {
Adam Lesinski498f6052017-11-29 13:24:29 -0800442 LOG(ERROR) << "RES_TABLE_PACKAGE_TYPE type ID offset too large.";
Adam Lesinskic6aada92017-01-13 15:34:14 -0800443 return {};
444 }
445 loaded_package->type_id_offset_ = static_cast<int>(type_id_offset);
446 }
447
Adam Lesinskida431a22016-12-29 16:08:16 -0500448 util::ReadUtf16StringFromDevice(header->name, arraysize(header->name),
449 &loaded_package->package_name_);
Adam Lesinski7ad11102016-10-28 16:39:15 -0700450
Adam Lesinskibebfcc42018-02-12 14:27:46 -0800451 // A map of TypeSpec builders, each associated with an type index.
452 // We use these to accumulate the set of Types available for a TypeSpec, and later build a single,
453 // contiguous block of memory that holds all the Types together with the TypeSpec.
454 std::unordered_map<int, std::unique_ptr<TypeSpecPtrBuilder>> type_builder_map;
Adam Lesinski7ad11102016-10-28 16:39:15 -0700455
456 ChunkIterator iter(chunk.data_ptr(), chunk.data_size());
457 while (iter.HasNext()) {
458 const Chunk child_chunk = iter.Next();
459 switch (child_chunk.type()) {
460 case RES_STRING_POOL_TYPE: {
461 const uintptr_t pool_address =
462 reinterpret_cast<uintptr_t>(child_chunk.header<ResChunk_header>());
463 const uintptr_t header_address = reinterpret_cast<uintptr_t>(header);
464 if (pool_address == header_address + dtohl(header->typeStrings)) {
465 // This string pool is the type string pool.
466 status_t err = loaded_package->type_string_pool_.setTo(
467 child_chunk.header<ResStringPool_header>(), child_chunk.size());
468 if (err != NO_ERROR) {
Adam Lesinski498f6052017-11-29 13:24:29 -0800469 LOG(ERROR) << "RES_STRING_POOL_TYPE for types corrupt.";
Adam Lesinskida431a22016-12-29 16:08:16 -0500470 return {};
Adam Lesinski7ad11102016-10-28 16:39:15 -0700471 }
472 } else if (pool_address == header_address + dtohl(header->keyStrings)) {
473 // This string pool is the key string pool.
474 status_t err = loaded_package->key_string_pool_.setTo(
475 child_chunk.header<ResStringPool_header>(), child_chunk.size());
476 if (err != NO_ERROR) {
Adam Lesinski498f6052017-11-29 13:24:29 -0800477 LOG(ERROR) << "RES_STRING_POOL_TYPE for keys corrupt.";
Adam Lesinskida431a22016-12-29 16:08:16 -0500478 return {};
Adam Lesinski7ad11102016-10-28 16:39:15 -0700479 }
480 } else {
Adam Lesinski498f6052017-11-29 13:24:29 -0800481 LOG(WARNING) << "Too many RES_STRING_POOL_TYPEs found in RES_TABLE_PACKAGE_TYPE.";
Adam Lesinski7ad11102016-10-28 16:39:15 -0700482 }
483 } break;
484
485 case RES_TABLE_TYPE_SPEC_TYPE: {
Adam Lesinski7ad11102016-10-28 16:39:15 -0700486 const ResTable_typeSpec* type_spec = child_chunk.header<ResTable_typeSpec>();
487 if (type_spec == nullptr) {
Adam Lesinski498f6052017-11-29 13:24:29 -0800488 LOG(ERROR) << "RES_TABLE_TYPE_SPEC_TYPE too small.";
Adam Lesinskida431a22016-12-29 16:08:16 -0500489 return {};
Adam Lesinski7ad11102016-10-28 16:39:15 -0700490 }
491
492 if (type_spec->id == 0) {
Adam Lesinski498f6052017-11-29 13:24:29 -0800493 LOG(ERROR) << "RES_TABLE_TYPE_SPEC_TYPE has invalid ID 0.";
Adam Lesinskida431a22016-12-29 16:08:16 -0500494 return {};
Adam Lesinski7ad11102016-10-28 16:39:15 -0700495 }
496
Adam Lesinskic6aada92017-01-13 15:34:14 -0800497 if (loaded_package->type_id_offset_ + static_cast<int>(type_spec->id) >
498 std::numeric_limits<uint8_t>::max()) {
Adam Lesinski498f6052017-11-29 13:24:29 -0800499 LOG(ERROR) << "RES_TABLE_TYPE_SPEC_TYPE has out of range ID.";
Adam Lesinskic6aada92017-01-13 15:34:14 -0800500 return {};
501 }
502
Adam Lesinski7ad11102016-10-28 16:39:15 -0700503 // The data portion of this chunk contains entry_count 32bit entries,
504 // each one representing a set of flags.
505 // Here we only validate that the chunk is well formed.
506 const size_t entry_count = dtohl(type_spec->entryCount);
507
508 // There can only be 2^16 entries in a type, because that is the ID
509 // space for entries (EEEE) in the resource ID 0xPPTTEEEE.
510 if (entry_count > std::numeric_limits<uint16_t>::max()) {
Adam Lesinski498f6052017-11-29 13:24:29 -0800511 LOG(ERROR) << "RES_TABLE_TYPE_SPEC_TYPE has too many entries (" << entry_count << ").";
Adam Lesinskida431a22016-12-29 16:08:16 -0500512 return {};
Adam Lesinski7ad11102016-10-28 16:39:15 -0700513 }
514
515 if (entry_count * sizeof(uint32_t) > chunk.data_size()) {
Adam Lesinski498f6052017-11-29 13:24:29 -0800516 LOG(ERROR) << "RES_TABLE_TYPE_SPEC_TYPE too small to hold entries.";
Adam Lesinskida431a22016-12-29 16:08:16 -0500517 return {};
Adam Lesinski7ad11102016-10-28 16:39:15 -0700518 }
519
Adam Lesinski970bd8d2017-09-25 13:21:55 -0700520 // If this is an overlay, associate the mapping of this type to the target type
521 // from the IDMAP.
522 const IdmapEntry_header* idmap_entry_header = nullptr;
523 if (loaded_idmap != nullptr) {
524 idmap_entry_header = loaded_idmap->GetEntryMapForType(type_spec->id);
525 }
526
Adam Lesinskibebfcc42018-02-12 14:27:46 -0800527 std::unique_ptr<TypeSpecPtrBuilder>& builder_ptr = type_builder_map[type_spec->id - 1];
528 if (builder_ptr == nullptr) {
529 builder_ptr = util::make_unique<TypeSpecPtrBuilder>(type_spec, idmap_entry_header);
MÃ¥rten Kongstad3f1f4fc2018-03-02 09:34:18 +0100530 loaded_package->resource_ids_.set(type_spec->id, entry_count);
Adam Lesinskibebfcc42018-02-12 14:27:46 -0800531 } else {
532 LOG(WARNING) << StringPrintf("RES_TABLE_TYPE_SPEC_TYPE already defined for ID %02x",
533 type_spec->id);
534 }
Adam Lesinski7ad11102016-10-28 16:39:15 -0700535 } break;
536
537 case RES_TABLE_TYPE_TYPE: {
Adam Lesinski136fd072017-03-03 13:50:21 -0800538 const ResTable_type* type = child_chunk.header<ResTable_type, kResTableTypeMinSize>();
Adam Lesinski7ad11102016-10-28 16:39:15 -0700539 if (type == nullptr) {
Adam Lesinski498f6052017-11-29 13:24:29 -0800540 LOG(ERROR) << "RES_TABLE_TYPE_TYPE too small.";
Adam Lesinskida431a22016-12-29 16:08:16 -0500541 return {};
Adam Lesinski7ad11102016-10-28 16:39:15 -0700542 }
543
Adam Lesinski498f6052017-11-29 13:24:29 -0800544 if (!VerifyResTableType(type)) {
Adam Lesinskida431a22016-12-29 16:08:16 -0500545 return {};
Adam Lesinski7ad11102016-10-28 16:39:15 -0700546 }
547
548 // Type chunks must be preceded by their TypeSpec chunks.
Adam Lesinskibebfcc42018-02-12 14:27:46 -0800549 std::unique_ptr<TypeSpecPtrBuilder>& builder_ptr = type_builder_map[type->id - 1];
550 if (builder_ptr != nullptr) {
551 builder_ptr->AddType(type);
552 } else {
553 LOG(ERROR) << StringPrintf(
554 "RES_TABLE_TYPE_TYPE with ID %02x found without preceding RES_TABLE_TYPE_SPEC_TYPE.",
555 type->id);
Adam Lesinskida431a22016-12-29 16:08:16 -0500556 return {};
Adam Lesinski7ad11102016-10-28 16:39:15 -0700557 }
Adam Lesinski7ad11102016-10-28 16:39:15 -0700558 } break;
559
Adam Lesinskida431a22016-12-29 16:08:16 -0500560 case RES_TABLE_LIBRARY_TYPE: {
561 const ResTable_lib_header* lib = child_chunk.header<ResTable_lib_header>();
562 if (lib == nullptr) {
Adam Lesinski498f6052017-11-29 13:24:29 -0800563 LOG(ERROR) << "RES_TABLE_LIBRARY_TYPE too small.";
Adam Lesinskida431a22016-12-29 16:08:16 -0500564 return {};
565 }
566
567 if (child_chunk.data_size() / sizeof(ResTable_lib_entry) < dtohl(lib->count)) {
Adam Lesinski498f6052017-11-29 13:24:29 -0800568 LOG(ERROR) << "RES_TABLE_LIBRARY_TYPE too small to hold entries.";
Adam Lesinskida431a22016-12-29 16:08:16 -0500569 return {};
570 }
571
572 loaded_package->dynamic_package_map_.reserve(dtohl(lib->count));
573
574 const ResTable_lib_entry* const entry_begin =
575 reinterpret_cast<const ResTable_lib_entry*>(child_chunk.data_ptr());
576 const ResTable_lib_entry* const entry_end = entry_begin + dtohl(lib->count);
577 for (auto entry_iter = entry_begin; entry_iter != entry_end; ++entry_iter) {
578 std::string package_name;
579 util::ReadUtf16StringFromDevice(entry_iter->packageName,
580 arraysize(entry_iter->packageName), &package_name);
581
582 if (dtohl(entry_iter->packageId) >= std::numeric_limits<uint8_t>::max()) {
Adam Lesinskibebfcc42018-02-12 14:27:46 -0800583 LOG(ERROR) << StringPrintf(
Adam Lesinskida431a22016-12-29 16:08:16 -0500584 "Package ID %02x in RES_TABLE_LIBRARY_TYPE too large for package '%s'.",
585 dtohl(entry_iter->packageId), package_name.c_str());
586 return {};
587 }
588
589 loaded_package->dynamic_package_map_.emplace_back(std::move(package_name),
590 dtohl(entry_iter->packageId));
591 }
Ryan Mitchell75e20dd2018-11-06 16:39:36 -0800592 } break;
Adam Lesinskida431a22016-12-29 16:08:16 -0500593
Ryan Mitchell75e20dd2018-11-06 16:39:36 -0800594 case RES_TABLE_OVERLAYABLE_TYPE: {
595 const ResTable_overlayable_header* header =
596 child_chunk.header<ResTable_overlayable_header>();
597 if (header == nullptr) {
598 LOG(ERROR) << "RES_TABLE_OVERLAYABLE_TYPE too small.";
599 return {};
600 }
601
Ryan Mitchellef5673a2018-12-12 18:45:34 -0800602 std::string name;
603 util::ReadUtf16StringFromDevice(header->name, arraysize(header->name), &name);
604 std::string actor;
605 util::ReadUtf16StringFromDevice(header->actor, arraysize(header->actor), &actor);
606
MÃ¥rten Kongstadc92c4dd2019-02-05 01:29:59 +0100607 if (loaded_package->overlayable_map_.find(name) !=
608 loaded_package->overlayable_map_.end()) {
609 LOG(ERROR) << "Multiple <overlayable> blocks with the same name '" << name << "'.";
610 return {};
611 }
612 loaded_package->overlayable_map_.emplace(name, actor);
613
Ryan Mitchellef5673a2018-12-12 18:45:34 -0800614 // Iterate over the overlayable policy chunks contained within the overlayable chunk data
Ryan Mitchell75e20dd2018-11-06 16:39:36 -0800615 ChunkIterator overlayable_iter(child_chunk.data_ptr(), child_chunk.data_size());
616 while (overlayable_iter.HasNext()) {
617 const Chunk overlayable_child_chunk = overlayable_iter.Next();
618
619 switch (overlayable_child_chunk.type()) {
620 case RES_TABLE_OVERLAYABLE_POLICY_TYPE: {
621 const ResTable_overlayable_policy_header* policy_header =
622 overlayable_child_chunk.header<ResTable_overlayable_policy_header>();
623 if (policy_header == nullptr) {
624 LOG(ERROR) << "RES_TABLE_OVERLAYABLE_POLICY_TYPE too small.";
625 return {};
626 }
627
628 if ((overlayable_child_chunk.data_size() / sizeof(ResTable_ref))
629 < dtohl(policy_header->entry_count)) {
630 LOG(ERROR) << "RES_TABLE_OVERLAYABLE_POLICY_TYPE too small to hold entries.";
631 return {};
632 }
633
Ryan Mitchellef5673a2018-12-12 18:45:34 -0800634 // Retrieve all the resource ids belonging to this policy chunk
Ryan Mitchell75e20dd2018-11-06 16:39:36 -0800635 std::unordered_set<uint32_t> ids;
636 const auto ids_begin =
637 reinterpret_cast<const ResTable_ref*>(overlayable_child_chunk.data_ptr());
638 const auto ids_end = ids_begin + dtohl(policy_header->entry_count);
639 for (auto id_iter = ids_begin; id_iter != ids_end; ++id_iter) {
640 ids.insert(dtohl(id_iter->ident));
641 }
642
Ryan Mitchellef5673a2018-12-12 18:45:34 -0800643 // Add the pairing of overlayable properties and resource ids to the package
Ryan Mitchell54237ff2018-12-13 15:44:29 -0800644 OverlayableInfo overlayable_info{};
Ryan Mitchellef5673a2018-12-12 18:45:34 -0800645 overlayable_info.name = name;
646 overlayable_info.actor = actor;
Ryan Mitchell75e20dd2018-11-06 16:39:36 -0800647 overlayable_info.policy_flags = policy_header->policy_flags;
648 loaded_package->overlayable_infos_.push_back(std::make_pair(overlayable_info, ids));
Ryan Mitchell19823452019-01-29 12:01:24 -0800649 loaded_package->defines_overlayable_ = true;
Ryan Mitchell75e20dd2018-11-06 16:39:36 -0800650 break;
651 }
652
653 default:
654 LOG(WARNING) << StringPrintf("Unknown chunk type '%02x'.", chunk.type());
655 break;
656 }
657 }
658
659 if (overlayable_iter.HadError()) {
Ryan Mitchellef5673a2018-12-12 18:45:34 -0800660 LOG(ERROR) << StringPrintf("Error parsing RES_TABLE_OVERLAYABLE_TYPE: %s",
Ryan Mitchell75e20dd2018-11-06 16:39:36 -0800661 overlayable_iter.GetLastError().c_str());
662 if (overlayable_iter.HadFatalError()) {
663 return {};
664 }
665 }
Adam Lesinskida431a22016-12-29 16:08:16 -0500666 } break;
667
Adam Lesinski7ad11102016-10-28 16:39:15 -0700668 default:
Adam Lesinskibebfcc42018-02-12 14:27:46 -0800669 LOG(WARNING) << StringPrintf("Unknown chunk type '%02x'.", chunk.type());
Adam Lesinski7ad11102016-10-28 16:39:15 -0700670 break;
671 }
672 }
673
Adam Lesinskibebfcc42018-02-12 14:27:46 -0800674 if (iter.HadError()) {
675 LOG(ERROR) << iter.GetLastError();
Todd Kennedy28e663c2018-07-12 13:15:54 -0700676 if (iter.HadFatalError()) {
677 return {};
678 }
Adam Lesinskibebfcc42018-02-12 14:27:46 -0800679 }
680
681 // Flatten and construct the TypeSpecs.
682 for (auto& entry : type_builder_map) {
683 uint8_t type_idx = static_cast<uint8_t>(entry.first);
684 TypeSpecPtr type_spec_ptr = entry.second->Build();
Adam Lesinski7ad11102016-10-28 16:39:15 -0700685 if (type_spec_ptr == nullptr) {
686 LOG(ERROR) << "Too many type configurations, overflow detected.";
Adam Lesinskida431a22016-12-29 16:08:16 -0500687 return {};
Adam Lesinski7ad11102016-10-28 16:39:15 -0700688 }
Adam Lesinski970bd8d2017-09-25 13:21:55 -0700689
690 // We only add the type to the package if there is no IDMAP, or if the type is
691 // overlaying something.
692 if (loaded_idmap == nullptr || type_spec_ptr->idmap_entries != nullptr) {
693 // If this is an overlay, insert it at the target type ID.
694 if (type_spec_ptr->idmap_entries != nullptr) {
Adam Lesinskibebfcc42018-02-12 14:27:46 -0800695 type_idx = dtohs(type_spec_ptr->idmap_entries->target_type_id) - 1;
Adam Lesinski970bd8d2017-09-25 13:21:55 -0700696 }
Adam Lesinskibebfcc42018-02-12 14:27:46 -0800697 loaded_package->type_specs_.editItemAt(type_idx) = std::move(type_spec_ptr);
Adam Lesinski970bd8d2017-09-25 13:21:55 -0700698 }
Adam Lesinski7ad11102016-10-28 16:39:15 -0700699 }
700
Adam Lesinski1a1e9c22017-10-13 15:45:34 -0700701 return std::move(loaded_package);
702}
703
Adam Lesinski970bd8d2017-09-25 13:21:55 -0700704bool LoadedArsc::LoadTable(const Chunk& chunk, const LoadedIdmap* loaded_idmap,
Winson9947f1e2019-08-16 10:20:39 -0700705 bool load_as_shared_library, bool for_loader) {
Adam Lesinski7ad11102016-10-28 16:39:15 -0700706 const ResTable_header* header = chunk.header<ResTable_header>();
707 if (header == nullptr) {
Adam Lesinski498f6052017-11-29 13:24:29 -0800708 LOG(ERROR) << "RES_TABLE_TYPE too small.";
Adam Lesinski7ad11102016-10-28 16:39:15 -0700709 return false;
710 }
711
712 const size_t package_count = dtohl(header->packageCount);
713 size_t packages_seen = 0;
714
715 packages_.reserve(package_count);
716
717 ChunkIterator iter(chunk.data_ptr(), chunk.data_size());
718 while (iter.HasNext()) {
719 const Chunk child_chunk = iter.Next();
720 switch (child_chunk.type()) {
721 case RES_STRING_POOL_TYPE:
722 // Only use the first string pool. Ignore others.
723 if (global_string_pool_.getError() == NO_INIT) {
724 status_t err = global_string_pool_.setTo(child_chunk.header<ResStringPool_header>(),
725 child_chunk.size());
726 if (err != NO_ERROR) {
Adam Lesinski498f6052017-11-29 13:24:29 -0800727 LOG(ERROR) << "RES_STRING_POOL_TYPE corrupt.";
Adam Lesinski7ad11102016-10-28 16:39:15 -0700728 return false;
729 }
730 } else {
Adam Lesinski498f6052017-11-29 13:24:29 -0800731 LOG(WARNING) << "Multiple RES_STRING_POOL_TYPEs found in RES_TABLE_TYPE.";
Adam Lesinski7ad11102016-10-28 16:39:15 -0700732 }
733 break;
734
735 case RES_TABLE_PACKAGE_TYPE: {
736 if (packages_seen + 1 > package_count) {
737 LOG(ERROR) << "More package chunks were found than the " << package_count
Adam Lesinski970bd8d2017-09-25 13:21:55 -0700738 << " declared in the header.";
Adam Lesinski7ad11102016-10-28 16:39:15 -0700739 return false;
740 }
741 packages_seen++;
742
Adam Lesinski1a1e9c22017-10-13 15:45:34 -0700743 std::unique_ptr<const LoadedPackage> loaded_package =
Winson9947f1e2019-08-16 10:20:39 -0700744 LoadedPackage::Load(child_chunk,
745 loaded_idmap,
746 system_,
747 load_as_shared_library,
748 for_loader);
Adam Lesinskida431a22016-12-29 16:08:16 -0500749 if (!loaded_package) {
Adam Lesinski7ad11102016-10-28 16:39:15 -0700750 return false;
751 }
752 packages_.push_back(std::move(loaded_package));
753 } break;
754
755 default:
Adam Lesinskibebfcc42018-02-12 14:27:46 -0800756 LOG(WARNING) << StringPrintf("Unknown chunk type '%02x'.", chunk.type());
Adam Lesinski7ad11102016-10-28 16:39:15 -0700757 break;
758 }
759 }
760
761 if (iter.HadError()) {
762 LOG(ERROR) << iter.GetLastError();
Todd Kennedy28e663c2018-07-12 13:15:54 -0700763 if (iter.HadFatalError()) {
764 return false;
765 }
Adam Lesinski7ad11102016-10-28 16:39:15 -0700766 }
767 return true;
768}
769
Adam Lesinski970bd8d2017-09-25 13:21:55 -0700770std::unique_ptr<const LoadedArsc> LoadedArsc::Load(const StringPiece& data,
Winson9947f1e2019-08-16 10:20:39 -0700771 const LoadedIdmap* loaded_idmap,
772 bool system,
773 bool load_as_shared_library,
774 bool for_loader) {
775 ATRACE_NAME("LoadedArsc::Load");
Adam Lesinski7ad11102016-10-28 16:39:15 -0700776
777 // Not using make_unique because the constructor is private.
778 std::unique_ptr<LoadedArsc> loaded_arsc(new LoadedArsc());
Adam Lesinski0c405242017-01-13 20:47:26 -0800779 loaded_arsc->system_ = system;
Adam Lesinski7ad11102016-10-28 16:39:15 -0700780
Adam Lesinski970bd8d2017-09-25 13:21:55 -0700781 ChunkIterator iter(data.data(), data.size());
Adam Lesinski7ad11102016-10-28 16:39:15 -0700782 while (iter.HasNext()) {
783 const Chunk chunk = iter.Next();
784 switch (chunk.type()) {
785 case RES_TABLE_TYPE:
Winson9947f1e2019-08-16 10:20:39 -0700786 if (!loaded_arsc->LoadTable(chunk,
787 loaded_idmap,
788 load_as_shared_library,
789 for_loader)) {
Adam Lesinski7ad11102016-10-28 16:39:15 -0700790 return {};
791 }
792 break;
793
794 default:
Adam Lesinskibebfcc42018-02-12 14:27:46 -0800795 LOG(WARNING) << StringPrintf("Unknown chunk type '%02x'.", chunk.type());
Adam Lesinski7ad11102016-10-28 16:39:15 -0700796 break;
797 }
798 }
799
800 if (iter.HadError()) {
801 LOG(ERROR) << iter.GetLastError();
Todd Kennedy28e663c2018-07-12 13:15:54 -0700802 if (iter.HadFatalError()) {
803 return {};
804 }
Adam Lesinski7ad11102016-10-28 16:39:15 -0700805 }
Adam Lesinski0c405242017-01-13 20:47:26 -0800806
807 // Need to force a move for mingw32.
808 return std::move(loaded_arsc);
Adam Lesinski7ad11102016-10-28 16:39:15 -0700809}
810
Adam Lesinski970bd8d2017-09-25 13:21:55 -0700811std::unique_ptr<const LoadedArsc> LoadedArsc::CreateEmpty() {
812 return std::unique_ptr<LoadedArsc>(new LoadedArsc());
813}
814
Adam Lesinski7ad11102016-10-28 16:39:15 -0700815} // namespace android