diff options
author | Kenny Root <kroot@google.com> | 2009-12-11 01:40:19 -0800 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2009-12-11 01:40:19 -0800 |
commit | 49c6eacba14d495ed69eb436396dd216dba8b6c4 (patch) | |
tree | b860e2cdba397529a21d86eda544d319f559fcae /tools | |
parent | f381c242cc3a7420e77cc264b92d64c9fcbe00a8 (diff) | |
parent | cdbf5746fcbee26bed74090e22aff761d1b4da3b (diff) | |
download | frameworks_base-49c6eacba14d495ed69eb436396dd216dba8b6c4.zip frameworks_base-49c6eacba14d495ed69eb436396dd216dba8b6c4.tar.gz frameworks_base-49c6eacba14d495ed69eb436396dd216dba8b6c4.tar.bz2 |
am cdbf5746: am b5ef7ee1: Default to UTF8 resources when packaging with aapt
Merge commit 'cdbf5746fcbee26bed74090e22aff761d1b4da3b'
* commit 'cdbf5746fcbee26bed74090e22aff761d1b4da3b':
Default to UTF8 resources when packaging with aapt
Diffstat (limited to 'tools')
-rw-r--r-- | tools/aapt/Bundle.h | 19 | ||||
-rw-r--r-- | tools/aapt/Resource.cpp | 21 |
2 files changed, 37 insertions, 3 deletions
diff --git a/tools/aapt/Bundle.h b/tools/aapt/Bundle.h index 4737f84..a2c6a12 100644 --- a/tools/aapt/Bundle.h +++ b/tools/aapt/Bundle.h @@ -114,7 +114,10 @@ public: void addNoCompressExtension(const char* ext) { mNoCompressExtensions.add(ext); } const char* getMinSdkVersion() const { return mMinSdkVersion; } - void setMinSdkVersion(const char* val) { mMinSdkVersion = val; } + void setMinSdkVersion(const char* val) { + mMinSdkVersion = val; + setUTF8(isUTF8Available()); + } const char* getTargetSdkVersion() const { return mTargetSdkVersion; } void setTargetSdkVersion(const char* val) { mTargetSdkVersion = val; } const char* getMaxSdkVersion() const { return mMaxSdkVersion; } @@ -197,6 +200,20 @@ private: /* misc stuff */ int mPackageCount; #endif + + /* UTF-8 is only available on APIs 7 or above or + * SDK levels that have code names. + */ + bool isUTF8Available() { + char *end; + int minSdkNum = (int)strtol(mMinSdkVersion, &end, 0); + if (*end == '\0') { + if (minSdkNum < 7) { + return false; + } + } + return true; + } }; #endif // __BUNDLE_H diff --git a/tools/aapt/Resource.cpp b/tools/aapt/Resource.cpp index d04a873..de6ff14 100644 --- a/tools/aapt/Resource.cpp +++ b/tools/aapt/Resource.cpp @@ -171,7 +171,8 @@ static sp<AaptFile> getResourceFile(const sp<AaptAssets>& assets, bool makeIfNec NULL, String8()); } -static status_t parsePackage(const sp<AaptAssets>& assets, const sp<AaptGroup>& grp) +static status_t parsePackage(Bundle* bundle, const sp<AaptAssets>& assets, + const sp<AaptGroup>& grp) { if (grp->getFiles().size() != 1) { fprintf(stderr, "warning: Multiple AndroidManifest.xml files found, using %s\n", @@ -215,6 +216,22 @@ static status_t parsePackage(const sp<AaptAssets>& assets, const sp<AaptGroup>& assets->setPackage(String8(block.getAttributeStringValue(nameIndex, &len))); + String16 uses_sdk16("uses-sdk"); + while ((code=block.next()) != ResXMLTree::END_DOCUMENT + && code != ResXMLTree::BAD_DOCUMENT) { + if (code == ResXMLTree::START_TAG) { + if (strcmp16(block.getElementName(&len), uses_sdk16.string()) == 0) { + ssize_t minSdkIndex = block.indexOfAttribute("android", + "minSdkVersion"); + if (minSdkIndex >= 0) { + String8 minSdkString = String8( + block.getAttributeStringValue(minSdkIndex, &len)); + bundle->setMinSdkVersion(minSdkString.string()); + } + } + } + } + return NO_ERROR; } @@ -597,7 +614,7 @@ status_t buildResources(Bundle* bundle, const sp<AaptAssets>& assets) return UNKNOWN_ERROR; } - status_t err = parsePackage(assets, androidManifestFile); + status_t err = parsePackage(bundle, assets, androidManifestFile); if (err != NO_ERROR) { return err; } |