From 2b01c9f24cb80551eb7ba65ca63d3ac92a68dec7 Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Thu, 9 Jun 2011 11:29:08 -0700 Subject: [PATCH] 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 --- ResourceTable.cpp | 5 +++-- ResourceTable.h | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ResourceTable.cpp b/ResourceTable.cpp index 68c3892..d98b285 100644 --- a/ResourceTable.cpp +++ b/ResourceTable.cpp @@ -1963,10 +1963,11 @@ uint32_t ResourceTable::getResId(const String16& ref, bool onlyPublic) const { String16 package, type, name; + bool refOnlyPublic = true; if (!ResTable::expandResourceRef( ref.string(), ref.size(), &package, &type, &name, defType, defPackage ? defPackage:&mAssetsPackage, - outErrorMsg)) { + outErrorMsg, &refOnlyPublic)) { NOISY(printf("Expanding resource: ref=%s\n", String8(ref).string())); NOISY(printf("Expanding resource: defType=%s\n", @@ -1979,7 +1980,7 @@ uint32_t ResourceTable::getResId(const String16& ref, String8(name).string())); return 0; } - uint32_t res = getResId(package, type, name, onlyPublic); + uint32_t res = getResId(package, type, name, onlyPublic && refOnlyPublic); NOISY(printf("Expanded resource: p=%s, t=%s, n=%s, res=%d\n", String8(package).string(), String8(type).string(), String8(name).string(), res)); diff --git a/ResourceTable.h b/ResourceTable.h index bbb8140..734c541 100644 --- a/ResourceTable.h +++ b/ResourceTable.h @@ -162,13 +162,13 @@ public: uint32_t getResId(const String16& package, const String16& type, const String16& name, - bool onlyPublic = false) const; + bool onlyPublic = true) const; uint32_t getResId(const String16& ref, const String16* defType = NULL, const String16* defPackage = NULL, const char** outErrorMsg = NULL, - bool onlyPublic = false) const; + bool onlyPublic = true) const; static bool isValidResourceName(const String16& s); -- 2.45.2