Enforce public resource restriction on bag parents.
Need to put some more styles in the SDK to avoid breaking apps.
Also, welcome Android 3.2.
Change-Id: Ia31d07c9b1b91ad868d8630437fdc1b5ae24f37d
diff --git a/include/utils/ResourceTypes.h b/include/utils/ResourceTypes.h
index 8a92cd6..612ff93 100644
--- a/include/utils/ResourceTypes.h
+++ b/include/utils/ResourceTypes.h
@@ -1988,7 +1988,8 @@
String16* outName,
const String16* defType = NULL,
const String16* defPackage = NULL,
- const char** outErrorMsg = NULL);
+ const char** outErrorMsg = NULL,
+ bool* outPublicOnly = NULL);
static bool stringToInt(const char16_t* s, size_t len, Res_value* outValue);
static bool stringToFloat(const char16_t* s, size_t len, Res_value* outValue);
diff --git a/libs/utils/ResourceTypes.cpp b/libs/utils/ResourceTypes.cpp
index 4655a7e..6cf01c8 100644
--- a/libs/utils/ResourceTypes.cpp
+++ b/libs/utils/ResourceTypes.cpp
@@ -2663,6 +2663,9 @@
goto nope;
}
}
+ if (outTypeSpecFlags) {
+ *outTypeSpecFlags = ResTable_typeSpec::SPEC_PUBLIC;
+ }
return m->id;
nope:
;
@@ -2677,6 +2680,9 @@
index);
return 0;
}
+ if (outTypeSpecFlags) {
+ *outTypeSpecFlags = ResTable_typeSpec::SPEC_PUBLIC;
+ }
return Res_MAKEARRAY(index);
}
}
@@ -2687,6 +2693,8 @@
return 0;
}
+ bool fakePublic = false;
+
// Figure out the package and type we are looking in...
const char16_t* packageEnd = NULL;
@@ -2698,7 +2706,13 @@
else if (*p == '/') typeEnd = p;
p++;
}
- if (*name == '@') name++;
+ if (*name == '@') {
+ name++;
+ if (*name == '*') {
+ fakePublic = true;
+ name++;
+ }
+ }
if (name >= nameEnd) {
return 0;
}
@@ -2803,6 +2817,9 @@
if (dtohl(entry->key.index) == (size_t)ei) {
if (outTypeSpecFlags) {
*outTypeSpecFlags = typeConfigs->typeSpecFlags[i];
+ if (fakePublic) {
+ *outTypeSpecFlags |= ResTable_typeSpec::SPEC_PUBLIC;
+ }
}
return Res_MAKEID(group->id-1, ti, i);
}
@@ -2819,7 +2836,8 @@
String16* outName,
const String16* defType,
const String16* defPackage,
- const char** outErrorMsg)
+ const char** outErrorMsg,
+ bool* outPublicOnly)
{
const char16_t* packageEnd = NULL;
const char16_t* typeEnd = NULL;
@@ -2836,6 +2854,16 @@
p = refStr;
if (*p == '@') p++;
+ if (outPublicOnly != NULL) {
+ *outPublicOnly = true;
+ }
+ if (*p == '*') {
+ p++;
+ if (outPublicOnly != NULL) {
+ *outPublicOnly = false;
+ }
+ }
+
if (packageEnd) {
*outPackage = String16(p, packageEnd-p);
p = packageEnd+1;