blob: 7ae5368d80bdef6df5bb7ae6ba3bee81fb3ca6de [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001//
2// Copyright 2006 The Android Open Source Project
3//
4// Information about assets being operated on.
5//
6#ifndef __AAPT_ASSETS_H
7#define __AAPT_ASSETS_H
8
Mathias Agopianb13b9bd2012-02-17 18:27:36 -08009#include <androidfw/AssetManager.h>
10#include <androidfw/ResourceTypes.h>
Adam Lesinskifab50872014-04-16 14:40:42 -070011#include <stdlib.h>
12#include <set>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080013#include <utils/KeyedVector.h>
Mathias Agopianb13b9bd2012-02-17 18:27:36 -080014#include <utils/RefBase.h>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080015#include <utils/SortedVector.h>
16#include <utils/String8.h>
17#include <utils/Vector.h>
Adam Lesinskifab50872014-04-16 14:40:42 -070018
19#include "AaptConfig.h"
20#include "Bundle.h"
21#include "ConfigDescription.h"
22#include "SourcePos.h"
Mathias Agopian55e3d602009-06-05 14:56:35 -070023#include "ZipFile.h"
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080024
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080025using namespace android;
26
Raphael Moll90897ed2012-05-07 16:16:46 -070027extern const char * const gDefaultIgnoreAssets;
28extern const char * gUserIgnoreAssets;
29
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080030bool valid_symbol_name(const String8& str);
31
Dianne Hackborne6b68032011-10-13 16:26:02 -070032class AaptAssets;
33
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080034enum {
35 AXIS_NONE = 0,
36 AXIS_MCC = 1,
37 AXIS_MNC,
Narayan Kamath91447d82014-01-21 15:32:36 +000038 AXIS_LOCALE,
Dianne Hackbornc4db95c2009-07-21 17:46:02 -070039 AXIS_SCREENLAYOUTSIZE,
40 AXIS_SCREENLAYOUTLONG,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080041 AXIS_ORIENTATION,
Tobias Haamel27b28b32010-02-09 23:09:17 +010042 AXIS_UIMODETYPE,
43 AXIS_UIMODENIGHT,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080044 AXIS_DENSITY,
45 AXIS_TOUCHSCREEN,
46 AXIS_KEYSHIDDEN,
47 AXIS_KEYBOARD,
Dianne Hackborn93e462b2009-09-15 22:50:40 -070048 AXIS_NAVHIDDEN,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080049 AXIS_NAVIGATION,
50 AXIS_SCREENSIZE,
Dianne Hackborn69cb8752011-05-19 18:13:32 -070051 AXIS_SMALLESTSCREENWIDTHDP,
Dianne Hackbornebff8f92011-05-12 18:07:47 -070052 AXIS_SCREENWIDTHDP,
53 AXIS_SCREENHEIGHTDP,
Fabrice Di Meglio5f797992012-06-15 20:16:41 -070054 AXIS_LAYOUTDIR,
Dianne Hackborne6b68032011-10-13 16:26:02 -070055 AXIS_VERSION,
56
57 AXIS_START = AXIS_MCC,
58 AXIS_END = AXIS_VERSION,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080059};
60
Narayan Kamath91447d82014-01-21 15:32:36 +000061struct AaptLocaleValue {
62 char language[4];
63 char region[4];
64 char script[4];
65 char variant[8];
66
67 AaptLocaleValue() {
68 memset(this, 0, sizeof(AaptLocaleValue));
69 }
70
71 // Initialize this AaptLocaleValue from a config string.
72 bool initFromFilterString(const String8& config);
73
74 int initFromDirName(const Vector<String8>& parts, const int startIndex);
75
76 // Initialize this AaptLocaleValue from a ResTable_config.
77 void initFromResTable(const ResTable_config& config);
78
79 void writeTo(ResTable_config* out) const;
80
81 String8 toDirName() const;
82
83 int compare(const AaptLocaleValue& other) const {
84 return memcmp(this, &other, sizeof(AaptLocaleValue));
85 }
86
Narayan Kamath91447d82014-01-21 15:32:36 +000087 inline bool operator<(const AaptLocaleValue& o) const { return compare(o) < 0; }
88 inline bool operator<=(const AaptLocaleValue& o) const { return compare(o) <= 0; }
89 inline bool operator==(const AaptLocaleValue& o) const { return compare(o) == 0; }
90 inline bool operator!=(const AaptLocaleValue& o) const { return compare(o) != 0; }
91 inline bool operator>=(const AaptLocaleValue& o) const { return compare(o) >= 0; }
92 inline bool operator>(const AaptLocaleValue& o) const { return compare(o) > 0; }
93private:
94 void setLanguage(const char* language);
95 void setRegion(const char* language);
96 void setScript(const char* script);
97 void setVariant(const char* variant);
98};
99
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800100/**
101 * This structure contains a specific variation of a single file out
102 * of all the variations it can have that we can have.
103 */
104struct AaptGroupEntry
105{
106public:
Adam Lesinskie572c012014-09-19 15:10:04 -0700107 AaptGroupEntry() {}
108 AaptGroupEntry(const ConfigDescription& config) : mParams(config) {}
109
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800110 bool initFromDirName(const char* dir, String8* resType);
111
Adam Lesinskifab50872014-04-16 14:40:42 -0700112 inline const ConfigDescription& toParams() const { return mParams; }
Dianne Hackborne6b68032011-10-13 16:26:02 -0700113
Adam Lesinskifab50872014-04-16 14:40:42 -0700114 inline int compare(const AaptGroupEntry& o) const { return mParams.compareLogical(o.mParams); }
Narayan Kamath91447d82014-01-21 15:32:36 +0000115 inline bool operator<(const AaptGroupEntry& o) const { return compare(o) < 0; }
116 inline bool operator<=(const AaptGroupEntry& o) const { return compare(o) <= 0; }
117 inline bool operator==(const AaptGroupEntry& o) const { return compare(o) == 0; }
118 inline bool operator!=(const AaptGroupEntry& o) const { return compare(o) != 0; }
119 inline bool operator>=(const AaptGroupEntry& o) const { return compare(o) >= 0; }
120 inline bool operator>(const AaptGroupEntry& o) const { return compare(o) > 0; }
121
Adam Lesinskifab50872014-04-16 14:40:42 -0700122 String8 toString() const { return mParams.toString(); }
Narayan Kamath91447d82014-01-21 15:32:36 +0000123 String8 toDirName(const String8& resType) const;
124
Adam Lesinskifab50872014-04-16 14:40:42 -0700125 const String8 getVersionString() const { return AaptConfig::getVersion(mParams); }
Narayan Kamath91447d82014-01-21 15:32:36 +0000126
127private:
Adam Lesinskifab50872014-04-16 14:40:42 -0700128 ConfigDescription mParams;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800129};
130
131inline int compare_type(const AaptGroupEntry& lhs, const AaptGroupEntry& rhs)
132{
133 return lhs.compare(rhs);
134}
135
136inline int strictly_order_type(const AaptGroupEntry& lhs, const AaptGroupEntry& rhs)
137{
138 return compare_type(lhs, rhs) < 0;
139}
140
141class AaptGroup;
Josiah Gaskin9bf34ca2011-06-14 13:57:09 -0700142class FilePathStore;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800143
144/**
145 * A single asset file we know about.
146 */
147class AaptFile : public RefBase
148{
149public:
150 AaptFile(const String8& sourceFile, const AaptGroupEntry& groupEntry,
151 const String8& resType)
152 : mGroupEntry(groupEntry)
153 , mResourceType(resType)
154 , mSourceFile(sourceFile)
155 , mData(NULL)
156 , mDataSize(0)
157 , mBufferSize(0)
158 , mCompression(ZipEntry::kCompressStored)
159 {
160 //printf("new AaptFile created %s\n", (const char*)sourceFile);
161 }
Marco Nelissen6a1fade2009-04-20 16:16:01 -0700162 virtual ~AaptFile() {
163 free(mData);
164 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800165
166 const String8& getPath() const { return mPath; }
167 const AaptGroupEntry& getGroupEntry() const { return mGroupEntry; }
168
169 // Data API. If there is data attached to the file,
170 // getSourceFile() is not used.
171 bool hasData() const { return mData != NULL; }
172 const void* getData() const { return mData; }
173 size_t getSize() const { return mDataSize; }
174 void* editData(size_t size);
175 void* editData(size_t* outSize = NULL);
Adam Lesinskide898ff2014-01-29 18:20:45 -0800176 void* editDataInRange(size_t offset, size_t size);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800177 void* padData(size_t wordSize);
178 status_t writeData(const void* data, size_t size);
179 void clearData();
180
181 const String8& getResourceType() const { return mResourceType; }
182
183 // File API. If the file does not hold raw data, this is
184 // a full path to a file on the filesystem that holds its data.
185 const String8& getSourceFile() const { return mSourceFile; }
186
187 String8 getPrintableSource() const;
188
189 // Desired compression method, as per utils/ZipEntry.h. For example,
190 // no compression is ZipEntry::kCompressStored.
191 int getCompressionMethod() const { return mCompression; }
192 void setCompressionMethod(int c) { mCompression = c; }
193private:
194 friend class AaptGroup;
195
196 String8 mPath;
197 AaptGroupEntry mGroupEntry;
198 String8 mResourceType;
199 String8 mSourceFile;
200 void* mData;
201 size_t mDataSize;
202 size_t mBufferSize;
203 int mCompression;
204};
205
206/**
207 * A group of related files (the same file, with different
208 * vendor/locale variations).
209 */
210class AaptGroup : public RefBase
211{
212public:
213 AaptGroup(const String8& leaf, const String8& path)
214 : mLeaf(leaf), mPath(path) { }
215 virtual ~AaptGroup() { }
216
217 const String8& getLeaf() const { return mLeaf; }
218
219 // Returns the relative path after the AaptGroupEntry dirs.
220 const String8& getPath() const { return mPath; }
221
222 const DefaultKeyedVector<AaptGroupEntry, sp<AaptFile> >& getFiles() const
223 { return mFiles; }
224
Adam Lesinski09384302014-01-22 16:07:42 -0800225 status_t addFile(const sp<AaptFile>& file, const bool overwriteDuplicate=false);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800226 void removeFile(size_t index);
227
Dianne Hackborne6b68032011-10-13 16:26:02 -0700228 void print(const String8& prefix) const;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800229
230 String8 getPrintableSource() const;
231
232private:
233 String8 mLeaf;
234 String8 mPath;
235
236 DefaultKeyedVector<AaptGroupEntry, sp<AaptFile> > mFiles;
237};
238
239/**
Dianne Hackborne6b68032011-10-13 16:26:02 -0700240 * A single directory of assets, which can contain files and other
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800241 * sub-directories.
242 */
243class AaptDir : public RefBase
244{
245public:
246 AaptDir(const String8& leaf, const String8& path)
247 : mLeaf(leaf), mPath(path) { }
248 virtual ~AaptDir() { }
249
250 const String8& getLeaf() const { return mLeaf; }
251
252 const String8& getPath() const { return mPath; }
253
254 const DefaultKeyedVector<String8, sp<AaptGroup> >& getFiles() const { return mFiles; }
255 const DefaultKeyedVector<String8, sp<AaptDir> >& getDirs() const { return mDirs; }
256
Dianne Hackborne6b68032011-10-13 16:26:02 -0700257 virtual status_t addFile(const String8& name, const sp<AaptGroup>& file);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800258
259 void removeFile(const String8& name);
260 void removeDir(const String8& name);
261
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800262 /*
263 * Perform some sanity checks on the names of files and directories here.
264 * In particular:
265 * - Check for illegal chars in filenames.
266 * - Check filename length.
267 * - Check for presence of ".gz" and non-".gz" copies of same file.
268 * - Check for multiple files whose names match in a case-insensitive
269 * fashion (problematic for some systems).
270 *
271 * Comparing names against all other names is O(n^2). We could speed
272 * it up some by sorting the entries and being smarter about what we
273 * compare against, but I'm not expecting to have enough files in a
274 * single directory to make a noticeable difference in speed.
275 *
276 * Note that sorting here is not enough to guarantee that the package
277 * contents are sorted -- subsequent updates can rearrange things.
278 */
279 status_t validate() const;
280
Dianne Hackborne6b68032011-10-13 16:26:02 -0700281 void print(const String8& prefix) const;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800282
283 String8 getPrintableSource() const;
284
285private:
Dianne Hackborne6b68032011-10-13 16:26:02 -0700286 friend class AaptAssets;
287
288 status_t addDir(const String8& name, const sp<AaptDir>& dir);
289 sp<AaptDir> makeDir(const String8& name);
290 status_t addLeafFile(const String8& leafName,
Adam Lesinski09384302014-01-22 16:07:42 -0800291 const sp<AaptFile>& file,
292 const bool overwrite=false);
Dianne Hackborne6b68032011-10-13 16:26:02 -0700293 virtual ssize_t slurpFullTree(Bundle* bundle,
294 const String8& srcDir,
295 const AaptGroupEntry& kind,
296 const String8& resType,
Adam Lesinski09384302014-01-22 16:07:42 -0800297 sp<FilePathStore>& fullResPaths,
298 const bool overwrite=false);
Dianne Hackborne6b68032011-10-13 16:26:02 -0700299
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800300 String8 mLeaf;
301 String8 mPath;
302
303 DefaultKeyedVector<String8, sp<AaptGroup> > mFiles;
304 DefaultKeyedVector<String8, sp<AaptDir> > mDirs;
305};
306
307/**
308 * All information we know about a particular symbol.
309 */
310class AaptSymbolEntry
311{
312public:
313 AaptSymbolEntry()
Dianne Hackborn1644c6d72012-02-06 15:33:21 -0800314 : isPublic(false), isJavaSymbol(false), typeCode(TYPE_UNKNOWN)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800315 {
316 }
317 AaptSymbolEntry(const String8& _name)
Dianne Hackborn1644c6d72012-02-06 15:33:21 -0800318 : name(_name), isPublic(false), isJavaSymbol(false), typeCode(TYPE_UNKNOWN)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800319 {
320 }
321 AaptSymbolEntry(const AaptSymbolEntry& o)
322 : name(o.name), sourcePos(o.sourcePos), isPublic(o.isPublic)
Dianne Hackborn1644c6d72012-02-06 15:33:21 -0800323 , isJavaSymbol(o.isJavaSymbol), comment(o.comment), typeComment(o.typeComment)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800324 , typeCode(o.typeCode), int32Val(o.int32Val), stringVal(o.stringVal)
325 {
326 }
327 AaptSymbolEntry operator=(const AaptSymbolEntry& o)
328 {
329 sourcePos = o.sourcePos;
330 isPublic = o.isPublic;
Dianne Hackborn1644c6d72012-02-06 15:33:21 -0800331 isJavaSymbol = o.isJavaSymbol;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800332 comment = o.comment;
333 typeComment = o.typeComment;
334 typeCode = o.typeCode;
335 int32Val = o.int32Val;
336 stringVal = o.stringVal;
337 return *this;
338 }
339
340 const String8 name;
341
342 SourcePos sourcePos;
343 bool isPublic;
Dianne Hackborn1644c6d72012-02-06 15:33:21 -0800344 bool isJavaSymbol;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800345
346 String16 comment;
347 String16 typeComment;
348
349 enum {
350 TYPE_UNKNOWN = 0,
351 TYPE_INT32,
352 TYPE_STRING
353 };
354
355 int typeCode;
356
357 // Value. May be one of these.
358 int32_t int32Val;
359 String8 stringVal;
360};
361
362/**
363 * A group of related symbols (such as indices into a string block)
364 * that have been generated from the assets.
365 */
366class AaptSymbols : public RefBase
367{
368public:
369 AaptSymbols() { }
370 virtual ~AaptSymbols() { }
371
372 status_t addSymbol(const String8& name, int32_t value, const SourcePos& pos) {
373 if (!check_valid_symbol_name(name, pos, "symbol")) {
374 return BAD_VALUE;
375 }
376 AaptSymbolEntry& sym = edit_symbol(name, &pos);
377 sym.typeCode = AaptSymbolEntry::TYPE_INT32;
378 sym.int32Val = value;
379 return NO_ERROR;
380 }
381
382 status_t addStringSymbol(const String8& name, const String8& value,
383 const SourcePos& pos) {
384 if (!check_valid_symbol_name(name, pos, "symbol")) {
385 return BAD_VALUE;
386 }
387 AaptSymbolEntry& sym = edit_symbol(name, &pos);
388 sym.typeCode = AaptSymbolEntry::TYPE_STRING;
389 sym.stringVal = value;
390 return NO_ERROR;
391 }
392
393 status_t makeSymbolPublic(const String8& name, const SourcePos& pos) {
394 if (!check_valid_symbol_name(name, pos, "symbol")) {
395 return BAD_VALUE;
396 }
397 AaptSymbolEntry& sym = edit_symbol(name, &pos);
398 sym.isPublic = true;
399 return NO_ERROR;
400 }
401
Dianne Hackborn1644c6d72012-02-06 15:33:21 -0800402 status_t makeSymbolJavaSymbol(const String8& name, const SourcePos& pos) {
403 if (!check_valid_symbol_name(name, pos, "symbol")) {
404 return BAD_VALUE;
405 }
406 AaptSymbolEntry& sym = edit_symbol(name, &pos);
407 sym.isJavaSymbol = true;
408 return NO_ERROR;
409 }
410
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800411 void appendComment(const String8& name, const String16& comment, const SourcePos& pos) {
412 if (comment.size() <= 0) {
413 return;
414 }
415 AaptSymbolEntry& sym = edit_symbol(name, &pos);
416 if (sym.comment.size() == 0) {
417 sym.comment = comment;
418 } else {
419 sym.comment.append(String16("\n"));
420 sym.comment.append(comment);
421 }
422 }
423
424 void appendTypeComment(const String8& name, const String16& comment) {
425 if (comment.size() <= 0) {
426 return;
427 }
428 AaptSymbolEntry& sym = edit_symbol(name, NULL);
429 if (sym.typeComment.size() == 0) {
430 sym.typeComment = comment;
431 } else {
432 sym.typeComment.append(String16("\n"));
433 sym.typeComment.append(comment);
434 }
435 }
436
437 sp<AaptSymbols> addNestedSymbol(const String8& name, const SourcePos& pos) {
438 if (!check_valid_symbol_name(name, pos, "nested symbol")) {
439 return NULL;
440 }
441
442 sp<AaptSymbols> sym = mNestedSymbols.valueFor(name);
443 if (sym == NULL) {
444 sym = new AaptSymbols();
445 mNestedSymbols.add(name, sym);
446 }
447
448 return sym;
449 }
450
Dianne Hackborn1644c6d72012-02-06 15:33:21 -0800451 status_t applyJavaSymbols(const sp<AaptSymbols>& javaSymbols);
452
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800453 const KeyedVector<String8, AaptSymbolEntry>& getSymbols() const
454 { return mSymbols; }
455 const DefaultKeyedVector<String8, sp<AaptSymbols> >& getNestedSymbols() const
456 { return mNestedSymbols; }
457
458 const String16& getComment(const String8& name) const
459 { return get_symbol(name).comment; }
460 const String16& getTypeComment(const String8& name) const
461 { return get_symbol(name).typeComment; }
462
463private:
464 bool check_valid_symbol_name(const String8& symbol, const SourcePos& pos, const char* label) {
465 if (valid_symbol_name(symbol)) {
466 return true;
467 }
468 pos.error("invalid %s: '%s'\n", label, symbol.string());
469 return false;
470 }
471 AaptSymbolEntry& edit_symbol(const String8& symbol, const SourcePos* pos) {
472 ssize_t i = mSymbols.indexOfKey(symbol);
473 if (i < 0) {
474 i = mSymbols.add(symbol, AaptSymbolEntry(symbol));
475 }
476 AaptSymbolEntry& sym = mSymbols.editValueAt(i);
477 if (pos != NULL && sym.sourcePos.line < 0) {
478 sym.sourcePos = *pos;
479 }
480 return sym;
481 }
482 const AaptSymbolEntry& get_symbol(const String8& symbol) const {
483 ssize_t i = mSymbols.indexOfKey(symbol);
484 if (i >= 0) {
485 return mSymbols.valueAt(i);
486 }
487 return mDefSymbol;
488 }
489
490 KeyedVector<String8, AaptSymbolEntry> mSymbols;
491 DefaultKeyedVector<String8, sp<AaptSymbols> > mNestedSymbols;
492 AaptSymbolEntry mDefSymbol;
493};
494
Marco Nelissen6a1fade2009-04-20 16:16:01 -0700495class ResourceTypeSet : public RefBase,
496 public KeyedVector<String8,sp<AaptGroup> >
497{
498public:
499 ResourceTypeSet();
500};
501
Josiah Gaskin9bf34ca2011-06-14 13:57:09 -0700502// Storage for lists of fully qualified paths for
503// resources encountered during slurping.
504class FilePathStore : public RefBase,
505 public Vector<String8>
506{
507public:
508 FilePathStore();
509};
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800510
511/**
512 * Asset hierarchy being operated on.
513 */
514class AaptAssets : public AaptDir
515{
516public:
Dianne Hackborne6b68032011-10-13 16:26:02 -0700517 AaptAssets();
Marco Nelissen6a1fade2009-04-20 16:16:01 -0700518 virtual ~AaptAssets() { delete mRes; }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800519
520 const String8& getPackage() const { return mPackage; }
Dianne Hackborn1644c6d72012-02-06 15:33:21 -0800521 void setPackage(const String8& package) {
522 mPackage = package;
523 mSymbolsPrivatePackage = package;
524 mHavePrivateSymbols = false;
525 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800526
Dianne Hackborne6b68032011-10-13 16:26:02 -0700527 const SortedVector<AaptGroupEntry>& getGroupEntries() const;
528
529 virtual status_t addFile(const String8& name, const sp<AaptGroup>& file);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800530
531 sp<AaptFile> addFile(const String8& filePath,
532 const AaptGroupEntry& entry,
533 const String8& srcDir,
534 sp<AaptGroup>* outGroup,
535 const String8& resType);
536
537 void addResource(const String8& leafName,
538 const String8& path,
539 const sp<AaptFile>& file,
540 const String8& resType);
541
Dianne Hackborn64551b22009-08-15 00:00:33 -0700542 void addGroupEntry(const AaptGroupEntry& entry) { mGroupEntries.add(entry); }
543
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800544 ssize_t slurpFromArgs(Bundle* bundle);
545
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800546 sp<AaptSymbols> getSymbolsFor(const String8& name);
547
Dianne Hackborn1644c6d72012-02-06 15:33:21 -0800548 sp<AaptSymbols> getJavaSymbolsFor(const String8& name);
549
550 status_t applyJavaSymbols();
551
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800552 const DefaultKeyedVector<String8, sp<AaptSymbols> >& getSymbols() const { return mSymbols; }
553
554 String8 getSymbolsPrivatePackage() const { return mSymbolsPrivatePackage; }
Dianne Hackborn1644c6d72012-02-06 15:33:21 -0800555 void setSymbolsPrivatePackage(const String8& pkg) {
556 mSymbolsPrivatePackage = pkg;
557 mHavePrivateSymbols = mSymbolsPrivatePackage != mPackage;
558 }
559
560 bool havePrivateSymbols() const { return mHavePrivateSymbols; }
561
562 bool isJavaSymbol(const AaptSymbolEntry& sym, bool includePrivate) const;
563
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800564 status_t buildIncludedResources(Bundle* bundle);
565 status_t addIncludedResources(const sp<AaptFile>& file);
566 const ResTable& getIncludedResources() const;
Adam Lesinskiad2d07d2014-08-27 16:21:08 -0700567 AssetManager& getAssetManager();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800568
Dianne Hackborne6b68032011-10-13 16:26:02 -0700569 void print(const String8& prefix) const;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800570
Dianne Hackborne6b68032011-10-13 16:26:02 -0700571 inline const Vector<sp<AaptDir> >& resDirs() const { return mResDirs; }
572 sp<AaptDir> resDir(const String8& name) const;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800573
574 inline sp<AaptAssets> getOverlay() { return mOverlay; }
575 inline void setOverlay(sp<AaptAssets>& overlay) { mOverlay = overlay; }
576
577 inline KeyedVector<String8, sp<ResourceTypeSet> >* getResources() { return mRes; }
578 inline void
Marco Nelissen6a1fade2009-04-20 16:16:01 -0700579 setResources(KeyedVector<String8, sp<ResourceTypeSet> >* res) { delete mRes; mRes = res; }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800580
Josiah Gaskin9bf34ca2011-06-14 13:57:09 -0700581 inline sp<FilePathStore>& getFullResPaths() { return mFullResPaths; }
582 inline void
583 setFullResPaths(sp<FilePathStore>& res) { mFullResPaths = res; }
584
Josiah Gaskin03589cc2011-06-27 16:26:02 -0700585 inline sp<FilePathStore>& getFullAssetPaths() { return mFullAssetPaths; }
586 inline void
587 setFullAssetPaths(sp<FilePathStore>& res) { mFullAssetPaths = res; }
588
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800589private:
Dianne Hackborne6b68032011-10-13 16:26:02 -0700590 virtual ssize_t slurpFullTree(Bundle* bundle,
591 const String8& srcDir,
592 const AaptGroupEntry& kind,
593 const String8& resType,
Adam Lesinski40e8eef2014-09-16 14:43:29 -0700594 sp<FilePathStore>& fullResPaths,
595 const bool overwrite=false);
Dianne Hackborne6b68032011-10-13 16:26:02 -0700596
597 ssize_t slurpResourceTree(Bundle* bundle, const String8& srcDir);
598 ssize_t slurpResourceZip(Bundle* bundle, const char* filename);
599
600 status_t filter(Bundle* bundle);
601
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800602 String8 mPackage;
603 SortedVector<AaptGroupEntry> mGroupEntries;
604 DefaultKeyedVector<String8, sp<AaptSymbols> > mSymbols;
Dianne Hackborn1644c6d72012-02-06 15:33:21 -0800605 DefaultKeyedVector<String8, sp<AaptSymbols> > mJavaSymbols;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800606 String8 mSymbolsPrivatePackage;
Dianne Hackborn1644c6d72012-02-06 15:33:21 -0800607 bool mHavePrivateSymbols;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800608
Dianne Hackborne6b68032011-10-13 16:26:02 -0700609 Vector<sp<AaptDir> > mResDirs;
610
611 bool mChanged;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800612
613 bool mHaveIncludedAssets;
614 AssetManager mIncludedAssets;
615
616 sp<AaptAssets> mOverlay;
617 KeyedVector<String8, sp<ResourceTypeSet> >* mRes;
Josiah Gaskin9bf34ca2011-06-14 13:57:09 -0700618
619 sp<FilePathStore> mFullResPaths;
Josiah Gaskin03589cc2011-06-27 16:26:02 -0700620 sp<FilePathStore> mFullAssetPaths;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800621};
622
623#endif // __AAPT_ASSETS_H
624