blob: 0c2576a954b1ca8de0b9bd6378ef718c04e1e8d4 [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:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800107 bool initFromDirName(const char* dir, String8* resType);
108
Adam Lesinskifab50872014-04-16 14:40:42 -0700109 inline const ConfigDescription& toParams() const { return mParams; }
Dianne Hackborne6b68032011-10-13 16:26:02 -0700110
Adam Lesinskifab50872014-04-16 14:40:42 -0700111 inline int compare(const AaptGroupEntry& o) const { return mParams.compareLogical(o.mParams); }
Narayan Kamath91447d82014-01-21 15:32:36 +0000112 inline bool operator<(const AaptGroupEntry& o) const { return compare(o) < 0; }
113 inline bool operator<=(const AaptGroupEntry& o) const { return compare(o) <= 0; }
114 inline bool operator==(const AaptGroupEntry& o) const { return compare(o) == 0; }
115 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
Adam Lesinskifab50872014-04-16 14:40:42 -0700119 String8 toString() const { return mParams.toString(); }
Narayan Kamath91447d82014-01-21 15:32:36 +0000120 String8 toDirName(const String8& resType) const;
121
Adam Lesinskifab50872014-04-16 14:40:42 -0700122 const String8 getVersionString() const { return AaptConfig::getVersion(mParams); }
Narayan Kamath91447d82014-01-21 15:32:36 +0000123
124private:
Adam Lesinskifab50872014-04-16 14:40:42 -0700125 ConfigDescription mParams;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800126};
127
128inline int compare_type(const AaptGroupEntry& lhs, const AaptGroupEntry& rhs)
129{
130 return lhs.compare(rhs);
131}
132
133inline int strictly_order_type(const AaptGroupEntry& lhs, const AaptGroupEntry& rhs)
134{
135 return compare_type(lhs, rhs) < 0;
136}
137
138class AaptGroup;
Josiah Gaskin9bf34ca2011-06-14 13:57:09 -0700139class FilePathStore;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800140
141/**
142 * A single asset file we know about.
143 */
144class AaptFile : public RefBase
145{
146public:
147 AaptFile(const String8& sourceFile, const AaptGroupEntry& groupEntry,
148 const String8& resType)
149 : mGroupEntry(groupEntry)
150 , mResourceType(resType)
151 , mSourceFile(sourceFile)
152 , mData(NULL)
153 , mDataSize(0)
154 , mBufferSize(0)
155 , mCompression(ZipEntry::kCompressStored)
156 {
157 //printf("new AaptFile created %s\n", (const char*)sourceFile);
158 }
Marco Nelissen6a1fade2009-04-20 16:16:01 -0700159 virtual ~AaptFile() {
160 free(mData);
161 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800162
163 const String8& getPath() const { return mPath; }
164 const AaptGroupEntry& getGroupEntry() const { return mGroupEntry; }
165
166 // Data API. If there is data attached to the file,
167 // getSourceFile() is not used.
168 bool hasData() const { return mData != NULL; }
169 const void* getData() const { return mData; }
170 size_t getSize() const { return mDataSize; }
171 void* editData(size_t size);
172 void* editData(size_t* outSize = NULL);
Adam Lesinskide898ff2014-01-29 18:20:45 -0800173 void* editDataInRange(size_t offset, size_t size);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800174 void* padData(size_t wordSize);
175 status_t writeData(const void* data, size_t size);
176 void clearData();
177
178 const String8& getResourceType() const { return mResourceType; }
179
180 // File API. If the file does not hold raw data, this is
181 // a full path to a file on the filesystem that holds its data.
182 const String8& getSourceFile() const { return mSourceFile; }
183
184 String8 getPrintableSource() const;
185
186 // Desired compression method, as per utils/ZipEntry.h. For example,
187 // no compression is ZipEntry::kCompressStored.
188 int getCompressionMethod() const { return mCompression; }
189 void setCompressionMethod(int c) { mCompression = c; }
190private:
191 friend class AaptGroup;
192
193 String8 mPath;
194 AaptGroupEntry mGroupEntry;
195 String8 mResourceType;
196 String8 mSourceFile;
197 void* mData;
198 size_t mDataSize;
199 size_t mBufferSize;
200 int mCompression;
201};
202
203/**
204 * A group of related files (the same file, with different
205 * vendor/locale variations).
206 */
207class AaptGroup : public RefBase
208{
209public:
210 AaptGroup(const String8& leaf, const String8& path)
211 : mLeaf(leaf), mPath(path) { }
212 virtual ~AaptGroup() { }
213
214 const String8& getLeaf() const { return mLeaf; }
215
216 // Returns the relative path after the AaptGroupEntry dirs.
217 const String8& getPath() const { return mPath; }
218
219 const DefaultKeyedVector<AaptGroupEntry, sp<AaptFile> >& getFiles() const
220 { return mFiles; }
221
Adam Lesinski09384302014-01-22 16:07:42 -0800222 status_t addFile(const sp<AaptFile>& file, const bool overwriteDuplicate=false);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800223 void removeFile(size_t index);
224
Dianne Hackborne6b68032011-10-13 16:26:02 -0700225 void print(const String8& prefix) const;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800226
227 String8 getPrintableSource() const;
228
229private:
230 String8 mLeaf;
231 String8 mPath;
232
233 DefaultKeyedVector<AaptGroupEntry, sp<AaptFile> > mFiles;
234};
235
236/**
Dianne Hackborne6b68032011-10-13 16:26:02 -0700237 * A single directory of assets, which can contain files and other
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800238 * sub-directories.
239 */
240class AaptDir : public RefBase
241{
242public:
243 AaptDir(const String8& leaf, const String8& path)
244 : mLeaf(leaf), mPath(path) { }
245 virtual ~AaptDir() { }
246
247 const String8& getLeaf() const { return mLeaf; }
248
249 const String8& getPath() const { return mPath; }
250
251 const DefaultKeyedVector<String8, sp<AaptGroup> >& getFiles() const { return mFiles; }
252 const DefaultKeyedVector<String8, sp<AaptDir> >& getDirs() const { return mDirs; }
253
Dianne Hackborne6b68032011-10-13 16:26:02 -0700254 virtual status_t addFile(const String8& name, const sp<AaptGroup>& file);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800255
256 void removeFile(const String8& name);
257 void removeDir(const String8& name);
258
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800259 /*
260 * Perform some sanity checks on the names of files and directories here.
261 * In particular:
262 * - Check for illegal chars in filenames.
263 * - Check filename length.
264 * - Check for presence of ".gz" and non-".gz" copies of same file.
265 * - Check for multiple files whose names match in a case-insensitive
266 * fashion (problematic for some systems).
267 *
268 * Comparing names against all other names is O(n^2). We could speed
269 * it up some by sorting the entries and being smarter about what we
270 * compare against, but I'm not expecting to have enough files in a
271 * single directory to make a noticeable difference in speed.
272 *
273 * Note that sorting here is not enough to guarantee that the package
274 * contents are sorted -- subsequent updates can rearrange things.
275 */
276 status_t validate() const;
277
Dianne Hackborne6b68032011-10-13 16:26:02 -0700278 void print(const String8& prefix) const;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800279
280 String8 getPrintableSource() const;
281
282private:
Dianne Hackborne6b68032011-10-13 16:26:02 -0700283 friend class AaptAssets;
284
285 status_t addDir(const String8& name, const sp<AaptDir>& dir);
286 sp<AaptDir> makeDir(const String8& name);
287 status_t addLeafFile(const String8& leafName,
Adam Lesinski09384302014-01-22 16:07:42 -0800288 const sp<AaptFile>& file,
289 const bool overwrite=false);
Dianne Hackborne6b68032011-10-13 16:26:02 -0700290 virtual ssize_t slurpFullTree(Bundle* bundle,
291 const String8& srcDir,
292 const AaptGroupEntry& kind,
293 const String8& resType,
Adam Lesinski09384302014-01-22 16:07:42 -0800294 sp<FilePathStore>& fullResPaths,
295 const bool overwrite=false);
Dianne Hackborne6b68032011-10-13 16:26:02 -0700296
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800297 String8 mLeaf;
298 String8 mPath;
299
300 DefaultKeyedVector<String8, sp<AaptGroup> > mFiles;
301 DefaultKeyedVector<String8, sp<AaptDir> > mDirs;
302};
303
304/**
305 * All information we know about a particular symbol.
306 */
307class AaptSymbolEntry
308{
309public:
310 AaptSymbolEntry()
Dianne Hackborn1644c6d72012-02-06 15:33:21 -0800311 : isPublic(false), isJavaSymbol(false), typeCode(TYPE_UNKNOWN)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800312 {
313 }
314 AaptSymbolEntry(const String8& _name)
Dianne Hackborn1644c6d72012-02-06 15:33:21 -0800315 : name(_name), isPublic(false), isJavaSymbol(false), typeCode(TYPE_UNKNOWN)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800316 {
317 }
318 AaptSymbolEntry(const AaptSymbolEntry& o)
319 : name(o.name), sourcePos(o.sourcePos), isPublic(o.isPublic)
Dianne Hackborn1644c6d72012-02-06 15:33:21 -0800320 , isJavaSymbol(o.isJavaSymbol), comment(o.comment), typeComment(o.typeComment)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800321 , typeCode(o.typeCode), int32Val(o.int32Val), stringVal(o.stringVal)
322 {
323 }
324 AaptSymbolEntry operator=(const AaptSymbolEntry& o)
325 {
326 sourcePos = o.sourcePos;
327 isPublic = o.isPublic;
Dianne Hackborn1644c6d72012-02-06 15:33:21 -0800328 isJavaSymbol = o.isJavaSymbol;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800329 comment = o.comment;
330 typeComment = o.typeComment;
331 typeCode = o.typeCode;
332 int32Val = o.int32Val;
333 stringVal = o.stringVal;
334 return *this;
335 }
336
337 const String8 name;
338
339 SourcePos sourcePos;
340 bool isPublic;
Dianne Hackborn1644c6d72012-02-06 15:33:21 -0800341 bool isJavaSymbol;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800342
343 String16 comment;
344 String16 typeComment;
345
346 enum {
347 TYPE_UNKNOWN = 0,
348 TYPE_INT32,
349 TYPE_STRING
350 };
351
352 int typeCode;
353
354 // Value. May be one of these.
355 int32_t int32Val;
356 String8 stringVal;
357};
358
359/**
360 * A group of related symbols (such as indices into a string block)
361 * that have been generated from the assets.
362 */
363class AaptSymbols : public RefBase
364{
365public:
366 AaptSymbols() { }
367 virtual ~AaptSymbols() { }
368
369 status_t addSymbol(const String8& name, int32_t value, const SourcePos& pos) {
370 if (!check_valid_symbol_name(name, pos, "symbol")) {
371 return BAD_VALUE;
372 }
373 AaptSymbolEntry& sym = edit_symbol(name, &pos);
374 sym.typeCode = AaptSymbolEntry::TYPE_INT32;
375 sym.int32Val = value;
376 return NO_ERROR;
377 }
378
379 status_t addStringSymbol(const String8& name, const String8& value,
380 const SourcePos& pos) {
381 if (!check_valid_symbol_name(name, pos, "symbol")) {
382 return BAD_VALUE;
383 }
384 AaptSymbolEntry& sym = edit_symbol(name, &pos);
385 sym.typeCode = AaptSymbolEntry::TYPE_STRING;
386 sym.stringVal = value;
387 return NO_ERROR;
388 }
389
390 status_t makeSymbolPublic(const String8& name, const SourcePos& pos) {
391 if (!check_valid_symbol_name(name, pos, "symbol")) {
392 return BAD_VALUE;
393 }
394 AaptSymbolEntry& sym = edit_symbol(name, &pos);
395 sym.isPublic = true;
396 return NO_ERROR;
397 }
398
Dianne Hackborn1644c6d72012-02-06 15:33:21 -0800399 status_t makeSymbolJavaSymbol(const String8& name, const SourcePos& pos) {
400 if (!check_valid_symbol_name(name, pos, "symbol")) {
401 return BAD_VALUE;
402 }
403 AaptSymbolEntry& sym = edit_symbol(name, &pos);
404 sym.isJavaSymbol = true;
405 return NO_ERROR;
406 }
407
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800408 void appendComment(const String8& name, const String16& comment, const SourcePos& pos) {
409 if (comment.size() <= 0) {
410 return;
411 }
412 AaptSymbolEntry& sym = edit_symbol(name, &pos);
413 if (sym.comment.size() == 0) {
414 sym.comment = comment;
415 } else {
416 sym.comment.append(String16("\n"));
417 sym.comment.append(comment);
418 }
419 }
420
421 void appendTypeComment(const String8& name, const String16& comment) {
422 if (comment.size() <= 0) {
423 return;
424 }
425 AaptSymbolEntry& sym = edit_symbol(name, NULL);
426 if (sym.typeComment.size() == 0) {
427 sym.typeComment = comment;
428 } else {
429 sym.typeComment.append(String16("\n"));
430 sym.typeComment.append(comment);
431 }
432 }
433
434 sp<AaptSymbols> addNestedSymbol(const String8& name, const SourcePos& pos) {
435 if (!check_valid_symbol_name(name, pos, "nested symbol")) {
436 return NULL;
437 }
438
439 sp<AaptSymbols> sym = mNestedSymbols.valueFor(name);
440 if (sym == NULL) {
441 sym = new AaptSymbols();
442 mNestedSymbols.add(name, sym);
443 }
444
445 return sym;
446 }
447
Dianne Hackborn1644c6d72012-02-06 15:33:21 -0800448 status_t applyJavaSymbols(const sp<AaptSymbols>& javaSymbols);
449
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800450 const KeyedVector<String8, AaptSymbolEntry>& getSymbols() const
451 { return mSymbols; }
452 const DefaultKeyedVector<String8, sp<AaptSymbols> >& getNestedSymbols() const
453 { return mNestedSymbols; }
454
455 const String16& getComment(const String8& name) const
456 { return get_symbol(name).comment; }
457 const String16& getTypeComment(const String8& name) const
458 { return get_symbol(name).typeComment; }
459
460private:
461 bool check_valid_symbol_name(const String8& symbol, const SourcePos& pos, const char* label) {
462 if (valid_symbol_name(symbol)) {
463 return true;
464 }
465 pos.error("invalid %s: '%s'\n", label, symbol.string());
466 return false;
467 }
468 AaptSymbolEntry& edit_symbol(const String8& symbol, const SourcePos* pos) {
469 ssize_t i = mSymbols.indexOfKey(symbol);
470 if (i < 0) {
471 i = mSymbols.add(symbol, AaptSymbolEntry(symbol));
472 }
473 AaptSymbolEntry& sym = mSymbols.editValueAt(i);
474 if (pos != NULL && sym.sourcePos.line < 0) {
475 sym.sourcePos = *pos;
476 }
477 return sym;
478 }
479 const AaptSymbolEntry& get_symbol(const String8& symbol) const {
480 ssize_t i = mSymbols.indexOfKey(symbol);
481 if (i >= 0) {
482 return mSymbols.valueAt(i);
483 }
484 return mDefSymbol;
485 }
486
487 KeyedVector<String8, AaptSymbolEntry> mSymbols;
488 DefaultKeyedVector<String8, sp<AaptSymbols> > mNestedSymbols;
489 AaptSymbolEntry mDefSymbol;
490};
491
Marco Nelissen6a1fade2009-04-20 16:16:01 -0700492class ResourceTypeSet : public RefBase,
493 public KeyedVector<String8,sp<AaptGroup> >
494{
495public:
496 ResourceTypeSet();
497};
498
Josiah Gaskin9bf34ca2011-06-14 13:57:09 -0700499// Storage for lists of fully qualified paths for
500// resources encountered during slurping.
501class FilePathStore : public RefBase,
502 public Vector<String8>
503{
504public:
505 FilePathStore();
506};
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800507
508/**
509 * Asset hierarchy being operated on.
510 */
511class AaptAssets : public AaptDir
512{
513public:
Dianne Hackborne6b68032011-10-13 16:26:02 -0700514 AaptAssets();
Marco Nelissen6a1fade2009-04-20 16:16:01 -0700515 virtual ~AaptAssets() { delete mRes; }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800516
517 const String8& getPackage() const { return mPackage; }
Dianne Hackborn1644c6d72012-02-06 15:33:21 -0800518 void setPackage(const String8& package) {
519 mPackage = package;
520 mSymbolsPrivatePackage = package;
521 mHavePrivateSymbols = false;
522 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800523
Dianne Hackborne6b68032011-10-13 16:26:02 -0700524 const SortedVector<AaptGroupEntry>& getGroupEntries() const;
525
526 virtual status_t addFile(const String8& name, const sp<AaptGroup>& file);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800527
528 sp<AaptFile> addFile(const String8& filePath,
529 const AaptGroupEntry& entry,
530 const String8& srcDir,
531 sp<AaptGroup>* outGroup,
532 const String8& resType);
533
534 void addResource(const String8& leafName,
535 const String8& path,
536 const sp<AaptFile>& file,
537 const String8& resType);
538
Dianne Hackborn64551b22009-08-15 00:00:33 -0700539 void addGroupEntry(const AaptGroupEntry& entry) { mGroupEntries.add(entry); }
540
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800541 ssize_t slurpFromArgs(Bundle* bundle);
542
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800543 sp<AaptSymbols> getSymbolsFor(const String8& name);
544
Dianne Hackborn1644c6d72012-02-06 15:33:21 -0800545 sp<AaptSymbols> getJavaSymbolsFor(const String8& name);
546
547 status_t applyJavaSymbols();
548
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800549 const DefaultKeyedVector<String8, sp<AaptSymbols> >& getSymbols() const { return mSymbols; }
550
551 String8 getSymbolsPrivatePackage() const { return mSymbolsPrivatePackage; }
Dianne Hackborn1644c6d72012-02-06 15:33:21 -0800552 void setSymbolsPrivatePackage(const String8& pkg) {
553 mSymbolsPrivatePackage = pkg;
554 mHavePrivateSymbols = mSymbolsPrivatePackage != mPackage;
555 }
556
557 bool havePrivateSymbols() const { return mHavePrivateSymbols; }
558
559 bool isJavaSymbol(const AaptSymbolEntry& sym, bool includePrivate) const;
560
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800561 status_t buildIncludedResources(Bundle* bundle);
562 status_t addIncludedResources(const sp<AaptFile>& file);
563 const ResTable& getIncludedResources() const;
564
Dianne Hackborne6b68032011-10-13 16:26:02 -0700565 void print(const String8& prefix) const;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800566
Dianne Hackborne6b68032011-10-13 16:26:02 -0700567 inline const Vector<sp<AaptDir> >& resDirs() const { return mResDirs; }
568 sp<AaptDir> resDir(const String8& name) const;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800569
570 inline sp<AaptAssets> getOverlay() { return mOverlay; }
571 inline void setOverlay(sp<AaptAssets>& overlay) { mOverlay = overlay; }
572
573 inline KeyedVector<String8, sp<ResourceTypeSet> >* getResources() { return mRes; }
574 inline void
Marco Nelissen6a1fade2009-04-20 16:16:01 -0700575 setResources(KeyedVector<String8, sp<ResourceTypeSet> >* res) { delete mRes; mRes = res; }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800576
Josiah Gaskin9bf34ca2011-06-14 13:57:09 -0700577 inline sp<FilePathStore>& getFullResPaths() { return mFullResPaths; }
578 inline void
579 setFullResPaths(sp<FilePathStore>& res) { mFullResPaths = res; }
580
Josiah Gaskin03589cc2011-06-27 16:26:02 -0700581 inline sp<FilePathStore>& getFullAssetPaths() { return mFullAssetPaths; }
582 inline void
583 setFullAssetPaths(sp<FilePathStore>& res) { mFullAssetPaths = res; }
584
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800585private:
Dianne Hackborne6b68032011-10-13 16:26:02 -0700586 virtual ssize_t slurpFullTree(Bundle* bundle,
587 const String8& srcDir,
588 const AaptGroupEntry& kind,
589 const String8& resType,
590 sp<FilePathStore>& fullResPaths);
591
592 ssize_t slurpResourceTree(Bundle* bundle, const String8& srcDir);
593 ssize_t slurpResourceZip(Bundle* bundle, const char* filename);
594
595 status_t filter(Bundle* bundle);
596
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800597 String8 mPackage;
598 SortedVector<AaptGroupEntry> mGroupEntries;
599 DefaultKeyedVector<String8, sp<AaptSymbols> > mSymbols;
Dianne Hackborn1644c6d72012-02-06 15:33:21 -0800600 DefaultKeyedVector<String8, sp<AaptSymbols> > mJavaSymbols;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800601 String8 mSymbolsPrivatePackage;
Dianne Hackborn1644c6d72012-02-06 15:33:21 -0800602 bool mHavePrivateSymbols;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800603
Dianne Hackborne6b68032011-10-13 16:26:02 -0700604 Vector<sp<AaptDir> > mResDirs;
605
606 bool mChanged;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800607
608 bool mHaveIncludedAssets;
609 AssetManager mIncludedAssets;
610
611 sp<AaptAssets> mOverlay;
612 KeyedVector<String8, sp<ResourceTypeSet> >* mRes;
Josiah Gaskin9bf34ca2011-06-14 13:57:09 -0700613
614 sp<FilePathStore> mFullResPaths;
Josiah Gaskin03589cc2011-06-27 16:26:02 -0700615 sp<FilePathStore> mFullAssetPaths;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800616};
617
618#endif // __AAPT_ASSETS_H
619