From 76d8aa0abcde982698fbad8fd82af9cfb769baf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ryszard=20Wi=C5=9Bniewski?= Date: Tue, 3 May 2011 03:51:51 +0200 Subject: [PATCH] AXmlResourceParser::getAttributeValue(): do not use raw value for references and styles. --- .../res/decoder/AXmlResourceParser.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/apktool-lib/src/main/java/brut/androlib/res/decoder/AXmlResourceParser.java b/apktool-lib/src/main/java/brut/androlib/res/decoder/AXmlResourceParser.java index 62f23896..9ada6407 100644 --- a/apktool-lib/src/main/java/brut/androlib/res/decoder/AXmlResourceParser.java +++ b/apktool-lib/src/main/java/brut/androlib/res/decoder/AXmlResourceParser.java @@ -306,15 +306,15 @@ public class AXmlResourceParser implements XmlResourceParser { public String getAttributeValue(int index) { int offset = getAttributeOffset(index); - int valueString = m_attributes[offset + ATTRIBUTE_IX_VALUE_STRING]; - if (valueString != -1) { - return AndrolibResources.escapeTextForResXml( - m_strings.getString(valueString)); - } int valueType = m_attributes[offset + ATTRIBUTE_IX_VALUE_TYPE]; int valueData = m_attributes[offset + ATTRIBUTE_IX_VALUE_DATA]; + int valueString = m_attributes[offset + ATTRIBUTE_IX_VALUE_STRING]; - if (mAttrDecoder != null) { + if (mAttrDecoder != null && ( + valueString == -1 + || valueType == TypedValue.TYPE_REFERENCE + || valueType == TypedValue.TYPE_ATTRIBUTE + )) { try { return mAttrDecoder.decode(valueType, valueData, getAttributeNameResource(index)); @@ -329,6 +329,11 @@ public class AXmlResourceParser implements XmlResourceParser { } } + if (valueString != -1) { + return AndrolibResources.escapeTextForResXml( + m_strings.getString(valueString)); + } + return TypedValue.coerceToString(valueType, valueData); }