Catch attr lookup on internal attributes

Internal attributes will fail the AttrDecoder. Catch the errors
and simply return the undecoded value which will be correct. Fixes #913
This commit is contained in:
Connor Tumbleson 2015-05-10 07:36:44 -05:00
parent 48285bde03
commit 9cb3df85d8

View File

@ -17,6 +17,7 @@
package brut.androlib.res.decoder; package brut.androlib.res.decoder;
import brut.androlib.AndrolibException; import brut.androlib.AndrolibException;
import brut.androlib.err.UndefinedResObject;
import brut.androlib.res.data.ResPackage; import brut.androlib.res.data.ResPackage;
import brut.androlib.res.data.ResResSpec; import brut.androlib.res.data.ResResSpec;
import brut.androlib.res.data.value.ResAttr; import brut.androlib.res.data.value.ResAttr;
@ -32,10 +33,15 @@ public class ResAttrDecoder {
type, value, rawValue); type, value, rawValue);
String decoded = null; String decoded = null;
if (attrResId != 0) { if (attrResId > 0) {
ResAttr attr = (ResAttr) getCurrentPackage().getResTable() try {
.getResSpec(attrResId).getDefaultResource().getValue(); ResAttr attr = (ResAttr) getCurrentPackage().getResTable()
decoded = attr.convertToResXmlFormat(resValue); .getResSpec(attrResId).getDefaultResource().getValue();
decoded = attr.convertToResXmlFormat(resValue);
} catch (UndefinedResObject ex) {
// ignored
}
} }
return decoded != null ? decoded : resValue.encodeAsResXmlAttr(); return decoded != null ? decoded : resValue.encodeAsResXmlAttr();