@@ -24,6 +24,8 @@ using namespace android;
2424
2525bool valid_symbol_name (const String8& str);
2626
27+ class AaptAssets ;
28+
2729enum {
2830 AXIS_NONE = 0 ,
2931 AXIS_MCC = 1 ,
@@ -45,7 +47,10 @@ enum {
4547 AXIS_SMALLESTSCREENWIDTHDP,
4648 AXIS_SCREENWIDTHDP,
4749 AXIS_SCREENHEIGHTDP,
48- AXIS_VERSION
50+ AXIS_VERSION,
51+
52+ AXIS_START = AXIS_MCC,
53+ AXIS_END = AXIS_VERSION,
4954};
5055
5156enum {
5661 SDK_MR1 = 7 ,
5762 SDK_FROYO = 8 ,
5863 SDK_HONEYCOMB_MR2 = 13 ,
64+ SDK_ICE_CREAM_SANDWICH = 14 ,
5965};
6066
6167/* *
@@ -65,35 +71,19 @@ enum {
6571struct AaptGroupEntry
6672{
6773public:
68- AaptGroupEntry () { }
74+ AaptGroupEntry () : mParamsChanged ( true ) { }
6975 AaptGroupEntry (const String8& _locale, const String8& _vendor)
70- : locale(_locale), vendor(_vendor) { }
71-
72- String8 mcc;
73- String8 mnc;
74- String8 locale;
75- String8 vendor;
76- String8 smallestScreenWidthDp;
77- String8 screenWidthDp;
78- String8 screenHeightDp;
79- String8 screenLayoutSize;
80- String8 screenLayoutLong;
81- String8 orientation;
82- String8 uiModeType;
83- String8 uiModeNight;
84- String8 density;
85- String8 touchscreen;
86- String8 keysHidden;
87- String8 keyboard;
88- String8 navHidden;
89- String8 navigation;
90- String8 screenSize;
91- String8 version;
76+ : locale(_locale), vendor(_vendor), mParamsChanged (true ) { }
9277
9378 bool initFromDirName (const char * dir, String8* resType);
9479
9580 static status_t parseNamePart (const String8& part, int * axis, uint32_t * value);
96-
81+
82+ static uint32_t getConfigValueForAxis (const ResTable_config& config, int axis);
83+
84+ static bool configSameExcept (const ResTable_config& config,
85+ const ResTable_config& otherConfig, int axis);
86+
9787 static bool getMccName (const char * name, ResTable_config* out = NULL );
9888 static bool getMncName (const char * name, ResTable_config* out = NULL );
9989 static bool getLocaleName (const char * name, ResTable_config* out = NULL );
@@ -116,7 +106,7 @@ struct AaptGroupEntry
116106
117107 int compare (const AaptGroupEntry& o) const ;
118108
119- ResTable_config toParams () const ;
109+ const ResTable_config& toParams () const ;
120110
121111 inline bool operator <(const AaptGroupEntry& o) const { return compare (o) < 0 ; }
122112 inline bool operator <=(const AaptGroupEntry& o) const { return compare (o) <= 0 ; }
@@ -127,6 +117,33 @@ struct AaptGroupEntry
127117
128118 String8 toString () const ;
129119 String8 toDirName (const String8& resType) const ;
120+
121+ const String8& getVersionString () const { return version; }
122+
123+ private:
124+ String8 mcc;
125+ String8 mnc;
126+ String8 locale;
127+ String8 vendor;
128+ String8 smallestScreenWidthDp;
129+ String8 screenWidthDp;
130+ String8 screenHeightDp;
131+ String8 screenLayoutSize;
132+ String8 screenLayoutLong;
133+ String8 orientation;
134+ String8 uiModeType;
135+ String8 uiModeNight;
136+ String8 density;
137+ String8 touchscreen;
138+ String8 keysHidden;
139+ String8 keyboard;
140+ String8 navHidden;
141+ String8 navigation;
142+ String8 screenSize;
143+ String8 version;
144+
145+ mutable bool mParamsChanged ;
146+ mutable ResTable_config mParams ;
130147};
131148
132149inline int compare_type (const AaptGroupEntry& lhs, const AaptGroupEntry& rhs)
@@ -225,7 +242,7 @@ class AaptGroup : public RefBase
225242 status_t addFile (const sp<AaptFile>& file);
226243 void removeFile (size_t index);
227244
228- void print () const ;
245+ void print (const String8& prefix ) const ;
229246
230247 String8 getPrintableSource () const ;
231248
@@ -237,7 +254,7 @@ class AaptGroup : public RefBase
237254};
238255
239256/* *
240- * A single directory of assets, which can contain for files and other
257+ * A single directory of assets, which can contain files and other
241258 * sub-directories.
242259 */
243260class AaptDir : public RefBase
@@ -254,25 +271,11 @@ class AaptDir : public RefBase
254271 const DefaultKeyedVector<String8, sp<AaptGroup> >& getFiles () const { return mFiles ; }
255272 const DefaultKeyedVector<String8, sp<AaptDir> >& getDirs () const { return mDirs ; }
256273
257- status_t addFile (const String8& name, const sp<AaptGroup>& file);
258- status_t addDir (const String8& name, const sp<AaptDir>& dir);
259-
260- sp<AaptDir> makeDir (const String8& name);
274+ virtual status_t addFile (const String8& name, const sp<AaptGroup>& file);
261275
262276 void removeFile (const String8& name);
263277 void removeDir (const String8& name);
264278
265- status_t renameFile (const sp<AaptFile>& file, const String8& newName);
266-
267- status_t addLeafFile (const String8& leafName,
268- const sp<AaptFile>& file);
269-
270- virtual ssize_t slurpFullTree (Bundle* bundle,
271- const String8& srcDir,
272- const AaptGroupEntry& kind,
273- const String8& resType,
274- sp<FilePathStore>& fullResPaths);
275-
276279 /*
277280 * Perform some sanity checks on the names of files and directories here.
278281 * In particular:
@@ -292,11 +295,23 @@ class AaptDir : public RefBase
292295 */
293296 status_t validate () const ;
294297
295- void print () const ;
298+ void print (const String8& prefix ) const ;
296299
297300 String8 getPrintableSource () const ;
298301
299302private:
303+ friend class AaptAssets ;
304+
305+ status_t addDir (const String8& name, const sp<AaptDir>& dir);
306+ sp<AaptDir> makeDir (const String8& name);
307+ status_t addLeafFile (const String8& leafName,
308+ const sp<AaptFile>& file);
309+ virtual ssize_t slurpFullTree (Bundle* bundle,
310+ const String8& srcDir,
311+ const AaptGroupEntry& kind,
312+ const String8& resType,
313+ sp<FilePathStore>& fullResPaths);
314+
300315 String8 mLeaf ;
301316 String8 mPath ;
302317
@@ -501,13 +516,15 @@ class FilePathStore : public RefBase,
501516class AaptAssets : public AaptDir
502517{
503518public:
504- AaptAssets () : AaptDir(String8(), String8()), mHaveIncludedAssets ( false ), mRes ( NULL ) { }
519+ AaptAssets ();
505520 virtual ~AaptAssets () { delete mRes ; }
506521
507522 const String8& getPackage () const { return mPackage ; }
508523 void setPackage (const String8& package) { mPackage = package; mSymbolsPrivatePackage = package; }
509524
510- const SortedVector<AaptGroupEntry>& getGroupEntries () const { return mGroupEntries ; }
525+ const SortedVector<AaptGroupEntry>& getGroupEntries () const ;
526+
527+ virtual status_t addFile (const String8& name, const sp<AaptGroup>& file);
511528
512529 sp<AaptFile> addFile (const String8& filePath,
513530 const AaptGroupEntry& entry,
@@ -524,15 +541,6 @@ class AaptAssets : public AaptDir
524541
525542 ssize_t slurpFromArgs (Bundle* bundle);
526543
527- virtual ssize_t slurpFullTree (Bundle* bundle,
528- const String8& srcDir,
529- const AaptGroupEntry& kind,
530- const String8& resType,
531- sp<FilePathStore>& fullResPaths);
532-
533- ssize_t slurpResourceTree (Bundle* bundle, const String8& srcDir);
534- ssize_t slurpResourceZip (Bundle* bundle, const char * filename);
535-
536544 sp<AaptSymbols> getSymbolsFor (const String8& name);
537545
538546 const DefaultKeyedVector<String8, sp<AaptSymbols> >& getSymbols () const { return mSymbols ; }
@@ -544,10 +552,10 @@ class AaptAssets : public AaptDir
544552 status_t addIncludedResources (const sp<AaptFile>& file);
545553 const ResTable& getIncludedResources () const ;
546554
547- void print () const ;
555+ void print (const String8& prefix ) const ;
548556
549- inline const Vector<sp<AaptDir> >& resDirs () { return mDirs ; }
550- sp<AaptDir> resDir (const String8& name);
557+ inline const Vector<sp<AaptDir> >& resDirs () const { return mResDirs ; }
558+ sp<AaptDir> resDir (const String8& name) const ;
551559
552560 inline sp<AaptAssets> getOverlay () { return mOverlay ; }
553561 inline void setOverlay (sp<AaptAssets>& overlay) { mOverlay = overlay; }
@@ -565,12 +573,25 @@ class AaptAssets : public AaptDir
565573 setFullAssetPaths (sp<FilePathStore>& res) { mFullAssetPaths = res; }
566574
567575private:
576+ virtual ssize_t slurpFullTree (Bundle* bundle,
577+ const String8& srcDir,
578+ const AaptGroupEntry& kind,
579+ const String8& resType,
580+ sp<FilePathStore>& fullResPaths);
581+
582+ ssize_t slurpResourceTree (Bundle* bundle, const String8& srcDir);
583+ ssize_t slurpResourceZip (Bundle* bundle, const char * filename);
584+
585+ status_t filter (Bundle* bundle);
586+
568587 String8 mPackage ;
569588 SortedVector<AaptGroupEntry> mGroupEntries ;
570589 DefaultKeyedVector<String8, sp<AaptSymbols> > mSymbols ;
571590 String8 mSymbolsPrivatePackage ;
572591
573- Vector<sp<AaptDir> > mDirs ;
592+ Vector<sp<AaptDir> > mResDirs ;
593+
594+ bool mChanged ;
574595
575596 bool mHaveIncludedAssets ;
576597 AssetManager mIncludedAssets ;
0 commit comments