Permalink
Browse files

Improve forcedPackageId. Now aapt can build apk with any id.

  • Loading branch information...
1 parent 7cc18d9 commit 7954c72f55e6a2ffe8f3654498219bd7802d1171 @peter23 peter23 committed Jan 14, 2017
@@ -1810,7 +1810,7 @@ class ResTable
// resolve resources that do not exist in this ResTable. If 'attrType' is
// supplied, the value will be type checked for this format if 'attrID'
// is not supplied or found.
- bool stringToValue(Res_value* outValue, String16* outString,
+ bool stringToValue(const ssize_t FORCED_PACKAGE_ID, Res_value* outValue, String16* outString,
const char16_t* s, size_t len,
bool preserveSpaces, bool coerceType,
uint32_t attrID = 0,
@@ -5035,7 +5035,7 @@ bool ResTable::stringToFloat(const char16_t* s, size_t len, Res_value* outValue)
return false;
}
-bool ResTable::stringToValue(Res_value* outValue, String16* outString,
+bool ResTable::stringToValue(const ssize_t FORCED_PACKAGE_ID, Res_value* outValue, String16* outString,
const char16_t* s, size_t len,
bool preserveSpaces, bool coerceType,
uint32_t attrID,
@@ -5189,7 +5189,7 @@ bool ResTable::stringToValue(Res_value* outValue, String16* outString,
}
uint32_t packageId = Res_GETPACKAGE(rid) + 1;
- if (packageId != APP_PACKAGE_ID && packageId != SYS_PACKAGE_ID) {
+ if (packageId != APP_PACKAGE_ID && packageId != SYS_PACKAGE_ID && packageId != (uint32_t)FORCED_PACKAGE_ID) {
outValue->dataType = Res_value::TYPE_DYNAMIC_REFERENCE;
}
outValue->data = rid;
@@ -5210,7 +5210,7 @@ bool ResTable::stringToValue(Res_value* outValue, String16* outString,
outValue->data = rid;
outValue->dataType = Res_value::TYPE_DYNAMIC_REFERENCE;
return true;
- } else if (packageId == APP_PACKAGE_ID || packageId == SYS_PACKAGE_ID) {
+ } else if (packageId == APP_PACKAGE_ID || packageId == SYS_PACKAGE_ID || packageId == (uint32_t)FORCED_PACKAGE_ID) {
// We accept packageId's generated as 0x01 in order to support
// building the android system resources
outValue->data = rid;
@@ -5356,7 +5356,7 @@ bool ResTable::stringToValue(Res_value* outValue, String16* outString,
}
uint32_t packageId = Res_GETPACKAGE(rid) + 1;
- if (packageId != APP_PACKAGE_ID && packageId != SYS_PACKAGE_ID) {
+ if (packageId != APP_PACKAGE_ID && packageId != SYS_PACKAGE_ID && packageId != (uint32_t)FORCED_PACKAGE_ID) {
outValue->dataType = Res_value::TYPE_DYNAMIC_ATTRIBUTE;
}
outValue->data = rid;
@@ -5371,7 +5371,7 @@ bool ResTable::stringToValue(Res_value* outValue, String16* outString,
outValue->data = rid;
outValue->dataType = Res_value::TYPE_DYNAMIC_ATTRIBUTE;
return true;
- } else if (packageId == APP_PACKAGE_ID || packageId == SYS_PACKAGE_ID) {
+ } else if (packageId == APP_PACKAGE_ID || packageId == SYS_PACKAGE_ID || packageId == (uint32_t)FORCED_PACKAGE_ID) {
// We accept packageId's generated as 0x01 in order to support
// building the android system resources
outValue->data = rid;
@@ -101,7 +101,7 @@ status_t compileXmlFile(const Bundle* bundle,
}
if ((options&XML_COMPILE_PARSE_VALUES) != 0) {
- status_t err = root->parseValues(assets, table);
+ status_t err = root->parseValues(bundle, assets, table);
if (err != NO_ERROR) {
hasErrors = true;
}
@@ -2308,7 +2308,7 @@ bool ResourceTable::stringToValue(Res_value* outValue, StringPool* pool,
if (style == NULL || style->size() == 0) {
// Text is not styled so it can be any type... let's figure it out.
res = mAssets->getIncludedResources()
- .stringToValue(outValue, &finalStr, str.string(), str.size(), preserveSpaces,
+ .stringToValue(mBundle->getForcedPackageId(), outValue, &finalStr, str.string(), str.size(), preserveSpaces,
coerceType, attrID, NULL, &mAssetsPackage, this,
accessorCookie, attrType);
} else {
@@ -974,7 +974,7 @@ void XMLNode::removeWhitespace(bool stripAll, const char** cDataTags)
}
}
-status_t XMLNode::parseValues(const sp<AaptAssets>& assets,
+status_t XMLNode::parseValues(const Bundle* bundle, const sp<AaptAssets>& assets,
ResourceTable* table)
{
bool hasErrors = false;
@@ -988,7 +988,7 @@ status_t XMLNode::parseValues(const sp<AaptAssets>& assets,
String8(e.string));
table->setCurrentXmlPos(SourcePos(mFilename, getStartLineNumber()));
if (!assets->getIncludedResources()
- .stringToValue(&e.value, &e.string,
+ .stringToValue(bundle->getForcedPackageId(), &e.value, &e.string,
e.string.string(), e.string.size(), true, true,
e.nameResId, NULL, &defPackage, table, &ac)) {
hasErrors = true;
@@ -1002,7 +1002,7 @@ status_t XMLNode::parseValues(const sp<AaptAssets>& assets,
}
const size_t N = mChildren.size();
for (size_t i=0; i<N; i++) {
- status_t err = mChildren.itemAt(i)->parseValues(assets, table);
+ status_t err = mChildren.itemAt(i)->parseValues(bundle, assets, table);
if (err != NO_ERROR) {
hasErrors = true;
}
@@ -135,7 +135,7 @@ class XMLNode : public RefBase
void setUTF8(bool val) { mUTF8 = val; }
- status_t parseValues(const sp<AaptAssets>& assets, ResourceTable* table);
+ status_t parseValues(const Bundle* bundle, const sp<AaptAssets>& assets, ResourceTable* table);
status_t assignResourceIds(const sp<AaptAssets>& assets,
const ResourceTable* table = NULL);

0 comments on commit 7954c72

Please sign in to comment.