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; }
/* 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
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",
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;
}
return UNKNOWN_ERROR;
}
- status_t err = parsePackage(assets, androidManifestFile);
+ status_t err = parsePackage(bundle, assets, androidManifestFile);
if (err != NO_ERROR) {
return err;
}