From: Android (Google) Code Review Date: Mon, 29 Jun 2009 23:37:17 +0000 (-0700) Subject: am 72eb0aca: Merge change 5483 into donut X-Git-Url: https://git.saurik.com/android/aapt.git/commitdiff_plain/227d278071f3d156032fdee8baf322f5a4e0811e?ds=inline;hp=-c am 72eb0aca: Merge change 5483 into donut Merge commit '72eb0acad5cffc57ce5006f6deab29ee259e461e' * commit '72eb0acad5cffc57ce5006f6deab29ee259e461e': Expand support for different screen sizes. --- 227d278071f3d156032fdee8baf322f5a4e0811e diff --combined AaptAssets.h index 3f37069,3b96412..e8c7395 --- a/AaptAssets.h +++ b/AaptAssets.h @@@ -15,7 -15,7 +15,7 @@@ #include #include #include -#include +#include "ZipFile.h" #include "Bundle.h" #include "SourcePos.h" @@@ -37,6 -37,7 +37,7 @@@ enum AXIS_KEYBOARD, AXIS_NAVIGATION, AXIS_SCREENSIZE, + AXIS_SCREENLAYOUT, AXIS_VERSION }; @@@ -62,6 -63,7 +63,7 @@@ public String8 keyboard; String8 navigation; String8 screenSize; + String8 screenLayout; String8 version; bool initFromDirName(const char* dir, String8* resType); @@@ -78,6 -80,7 +80,7 @@@ static bool getKeyboardName(const char* name, ResTable_config* out = NULL); static bool getNavigationName(const char* name, ResTable_config* out = NULL); static bool getScreenSizeName(const char* name, ResTable_config* out = NULL); + static bool getScreenLayoutName(const char* name, ResTable_config* out = NULL); static bool getVersionName(const char* name, ResTable_config* out = NULL); int compare(const AaptGroupEntry& o) const; @@@ -125,9 -128,7 +128,9 @@@ public { //printf("new AaptFile created %s\n", (const char*)sourceFile); } - virtual ~AaptFile() { } + virtual ~AaptFile() { + free(mData); + } const String8& getPath() const { return mPath; } const AaptGroupEntry& getGroupEntry() const { return mGroupEntry; } @@@ -443,13 -444,7 +446,13 @@@ private AaptSymbolEntry mDefSymbol; }; -class ResourceTypeSet; +class ResourceTypeSet : public RefBase, + public KeyedVector > +{ +public: + ResourceTypeSet(); +}; + /** * Asset hierarchy being operated on. @@@ -457,8 -452,8 +460,8 @@@ class AaptAssets : public AaptDir { public: - AaptAssets() : AaptDir(String8(), String8()), mHaveIncludedAssets(false) { } - virtual ~AaptAssets() { } + AaptAssets() : AaptDir(String8(), String8()), mHaveIncludedAssets(false), mRes(NULL) { } + virtual ~AaptAssets() { delete mRes; } const String8& getPackage() const { return mPackage; } void setPackage(const String8& package) { mPackage = package; mSymbolsPrivatePackage = package; } @@@ -506,7 -501,7 +509,7 @@@ inline KeyedVector >* getResources() { return mRes; } inline void - setResources(KeyedVector >* res) { mRes = res; } + setResources(KeyedVector >* res) { delete mRes; mRes = res; } private: String8 mPackage; diff --combined Command.cpp index dcda379,e04491d..c0ae592 --- a/Command.cpp +++ b/Command.cpp @@@ -8,10 -8,8 +8,10 @@@ #include "ResourceTable.h" #include "XMLNode.h" -#include -#include +#include +#include +#include +#include #include #include @@@ -331,6 -329,9 +331,9 @@@ enum TARGET_SDK_VERSION_ATTR = 0x01010270, TEST_ONLY_ATTR = 0x01010272, DENSITY_ATTR = 0x0101026c, + SMALL_SCREEN_ATTR = 0x01010284, + NORMAL_SCREEN_ATTR = 0x01010285, + LARGE_SCREEN_ATTR = 0x01010286, }; const char *getComponentName(String8 &pkgName, String8 &componentName) { @@@ -501,6 -502,10 +504,10 @@@ int doDump(Bundle* bundle bool isLauncherActivity = false; bool withinApplication = false; bool withinReceiver = false; + int targetSdk = 0; + int smallScreen = 1; + int normalScreen = 1; + int largeScreen = 1; String8 pkg; String8 activityName; String8 activityLabel; @@@ -574,8 -579,10 +581,10 @@@ error.string()); goto bail; } + if (name == "Donut") targetSdk = 4; printf("sdkVersion:'%s'\n", name.string()); } else if (code != -1) { + targetSdk = code; printf("sdkVersion:'%d'\n", code); } code = getIntegerAttribute(tree, TARGET_SDK_VERSION_ATTR, &error); @@@ -587,8 -594,12 +596,12 @@@ error.string()); goto bail; } + if (name == "Donut" && targetSdk < 4) targetSdk = 4; printf("targetSdkVersion:'%s'\n", name.string()); } else if (code != -1) { + if (targetSdk < code) { + targetSdk = code; + } printf("targetSdkVersion:'%d'\n", code); } } else if (tag == "uses-configuration") { @@@ -627,6 -638,13 +640,13 @@@ goto bail; } printf("supports-density:'%d'\n", dens); + } else if (tag == "supports-screens") { + smallScreen = getIntegerAttribute(tree, + SMALL_SCREEN_ATTR, NULL, 1); + normalScreen = getIntegerAttribute(tree, + NORMAL_SCREEN_ATTR, NULL, 1); + largeScreen = getIntegerAttribute(tree, + LARGE_SCREEN_ATTR, NULL, 1); } } else if (depth == 3 && withinApplication) { withinActivity = false; @@@ -735,6 -753,25 +755,25 @@@ } } + // Determine default values for any unspecified screen sizes, + // based on the target SDK of the package. As of 4 (donut) + // the screen size support was introduced, so all default to + // enabled. + if (smallScreen > 0) { + smallScreen = targetSdk >= 4 ? -1 : 0; + } + if (normalScreen > 0) { + normalScreen = -1; + } + if (largeScreen > 0) { + largeScreen = targetSdk >= 4 ? -1 : 0; + } + printf("supports-screens:"); + if (smallScreen != 0) printf(" 'small'"); + if (normalScreen != 0) printf(" 'normal'"); + if (largeScreen != 0) printf(" 'large'"); + printf("\n"); + printf("locales:"); Vector locales; res.getLocales(&locales);