From c915fbfbc76eff4b31fbfa06bf45734fb73c104d Mon Sep 17 00:00:00 2001 From: d34d Date: Mon, 18 Jan 2016 19:52:10 -0800 Subject: Themes: Reference app resource when compiling theme [2/2] This allows us to pass in the path to the target apk as an additional included resource apk, allowing theme designers to reference styles and attributes from the original package without needing to duplicate them. Duplicating attributes never worked quite well, and causes all sorts of issues, including crashing apps. Instead of a theme declaring attributes, that are app specific, it can simply reference the originals. This way things like colors that are style specific get included correctly. Here's an example of stat_sys_wifi_signal_4_fully.xml using this feature. By using ?com.android.systemui:attr/ we are able to reference attributes defined in SystemUI directly in our themed resource. Change-Id: Icc794da9af2cd48099d42f9d7fbadaad8612b5db TICKET: CYNGNOS-1645 --- libs/androidfw/ResourceTypes.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'libs') diff --git a/libs/androidfw/ResourceTypes.cpp b/libs/androidfw/ResourceTypes.cpp index 818e1c5..5fe0d66 100644 --- a/libs/androidfw/ResourceTypes.cpp +++ b/libs/androidfw/ResourceTypes.cpp @@ -5290,6 +5290,13 @@ bool ResTable::stringToValue(Res_value* outValue, String16* outString, identifierForName(name.string(), name.size(), type.string(), type.size(), package.string(), package.size(), &specFlags); +// HACK +// This allows themes to reference attributes that are app specific and +// normally private. Only applies to aapt running on device not host +// build systems. +#ifdef HAVE_ANDROID_OS + enforcePrivate = false; +#endif if (rid != 0) { if (enforcePrivate) { if ((specFlags&ResTable_typeSpec::SPEC_PUBLIC) == 0) { -- cgit v1.1