From ce7c99c6617bd8a577126386a37060d356b5d1d4 Mon Sep 17 00:00:00 2001 From: Aurimas Liutikas Date: Tue, 18 Dec 2018 16:20:49 -0800 Subject: Add source style for each TypedValue. This API will be used by Android Studio layout inspector to query where a given resource attribute originated from to allow developers to have an easier way to find what needs to be changed to affect a given resource attribute. Test: CTS added in the topic Bug: 111439551 Change-Id: Ifbb52b39912ed0444030a86164290a1cd4155250 --- libs/androidfw/AttributeResolution.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'libs/androidfw/AttributeResolution.cpp') diff --git a/libs/androidfw/AttributeResolution.cpp b/libs/androidfw/AttributeResolution.cpp index 3dc1f2cd56c5..18d74efdbacf 100644 --- a/libs/androidfw/AttributeResolution.cpp +++ b/libs/androidfw/AttributeResolution.cpp @@ -286,6 +286,7 @@ void ApplyStyle(Theme* theme, ResXMLParser* xml_parser, uint32_t def_style_attr, value.dataType = Res_value::TYPE_NULL; value.data = Res_value::DATA_NULL_UNDEFINED; config.density = 0; + uint32_t source_style_resid = 0; // Try to find a value for this attribute... we prioritize values // coming from, first XML attributes, then XML style, then default @@ -309,6 +310,7 @@ void ApplyStyle(Theme* theme, ResXMLParser* xml_parser, uint32_t def_style_attr, cookie = entry->cookie; type_set_flags = style_flags; value = entry->value; + source_style_resid = entry->style; if (kDebugStyles) { ALOGI("-> From style: type=0x%x, data=0x%08x, style=0x%08x", value.dataType, value.data, entry->style); @@ -325,8 +327,10 @@ void ApplyStyle(Theme* theme, ResXMLParser* xml_parser, uint32_t def_style_attr, type_set_flags = def_style_flags; value = entry->value; if (kDebugStyles) { - ALOGI("-> From def style: type=0x%x, data=0x%08x", value.dataType, value.data); + ALOGI("-> From def style: type=0x%x, data=0x%08x, style=0x%08x", value.dataType, value.data, + entry->style); } + source_style_resid = entry->style; } } @@ -382,6 +386,7 @@ void ApplyStyle(Theme* theme, ResXMLParser* xml_parser, uint32_t def_style_attr, out_values[STYLE_RESOURCE_ID] = resid; out_values[STYLE_CHANGING_CONFIGURATIONS] = type_set_flags; out_values[STYLE_DENSITY] = config.density; + out_values[SYTLE_SOURCE_STYLE] = source_style_resid; if (value.dataType != Res_value::TYPE_NULL || value.data == Res_value::DATA_NULL_EMPTY) { indices_idx++; -- cgit v1.2.3