From 426431adcc220b6adfbe1d9530247f897e60fa36 Mon Sep 17 00:00:00 2001
From: Dianne Hackborn
Date: Thu, 9 Jun 2011 11:29:08 -0700
Subject: 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
---
api/current.xml | 321 +++++++++++++++++++++++++++++++-
core/java/android/os/Build.java | 4 +-
core/res/res/values/public.xml | 29 +++
include/utils/ResourceTypes.h | 3 +-
libs/utils/ResourceTypes.cpp | 32 +++-
packages/SystemUI/res/values/styles.xml | 8 +-
tools/aapt/ResourceTable.cpp | 5 +-
tools/aapt/ResourceTable.h | 4 +-
8 files changed, 392 insertions(+), 14 deletions(-)
diff --git a/api/current.xml b/api/current.xml
index 1f5aaf3..6581042 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -15208,6 +15208,325 @@
visibility="public"
>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Update to Honeycomb MR1 to support 7 inch tablets, improve
* screen compatibility mode, etc.
@@ -244,7 +244,7 @@ public class Build {
* large as the current screen will provide the user with a UI to
* switch them in to screen size compatibility mode.
*/
- public static final int HONEYCOMB_MR2 = CUR_DEVELOPMENT;
+ public static final int HONEYCOMB_MR2 = 13;
}
/** The type of build, like "user" or "eng". */
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index db5f39f..dfa33a6 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -1670,5 +1670,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/include/utils/ResourceTypes.h b/include/utils/ResourceTypes.h
index d1d9844..0603ed5 100644
--- a/include/utils/ResourceTypes.h
+++ b/include/utils/ResourceTypes.h
@@ -1988,7 +1988,8 @@ public:
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 a64918d..ecb8c0c 100644
--- a/libs/utils/ResourceTypes.cpp
+++ b/libs/utils/ResourceTypes.cpp
@@ -2499,6 +2499,9 @@ uint32_t ResTable::identifierForName(const char16_t* name, size_t nameLen,
goto nope;
}
}
+ if (outTypeSpecFlags) {
+ *outTypeSpecFlags = ResTable_typeSpec::SPEC_PUBLIC;
+ }
return m->id;
nope:
;
@@ -2513,6 +2516,9 @@ nope:
index);
return 0;
}
+ if (outTypeSpecFlags) {
+ *outTypeSpecFlags = ResTable_typeSpec::SPEC_PUBLIC;
+ }
return Res_MAKEARRAY(index);
}
}
@@ -2523,6 +2529,8 @@ nope:
return 0;
}
+ bool fakePublic = false;
+
// Figure out the package and type we are looking in...
const char16_t* packageEnd = NULL;
@@ -2534,7 +2542,13 @@ nope:
else if (*p == '/') typeEnd = p;
p++;
}
- if (*name == '@') name++;
+ if (*name == '@') {
+ name++;
+ if (*name == '*') {
+ fakePublic = true;
+ name++;
+ }
+ }
if (name >= nameEnd) {
return 0;
}
@@ -2639,6 +2653,9 @@ nope:
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);
}
@@ -2655,7 +2672,8 @@ bool ResTable::expandResourceRef(const uint16_t* refStr, size_t refLen,
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;
@@ -2672,6 +2690,16 @@ bool ResTable::expandResourceRef(const uint16_t* refStr, size_t refLen,
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;
diff --git a/packages/SystemUI/res/values/styles.xml b/packages/SystemUI/res/values/styles.xml
index 86ffb4d..91a8855 100644
--- a/packages/SystemUI/res/values/styles.xml
+++ b/packages/SystemUI/res/values/styles.xml
@@ -16,25 +16,25 @@
-