mirror of
https://github.com/revanced/Apktool.git
synced 2025-04-30 06:04:25 +02:00
ResXmlSerializer: parsing of attributes that aren't in android namespace.
This commit is contained in:
parent
7200c2efb8
commit
37bb440daf
@ -21,6 +21,8 @@ import brut.androlib.*;
|
|||||||
import brut.androlib.res.AndrolibResources;
|
import brut.androlib.res.AndrolibResources;
|
||||||
import brut.androlib.res.data.ResPackage;
|
import brut.androlib.res.data.ResPackage;
|
||||||
import brut.androlib.res.data.value.ResAttr;
|
import brut.androlib.res.data.value.ResAttr;
|
||||||
|
import brut.androlib.res.data.value.ResScalarValue;
|
||||||
|
import brut.androlib.res.data.value.ResValue;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import org.xmlpull.mxp1_serializer.MXSerializer;
|
import org.xmlpull.mxp1_serializer.MXSerializer;
|
||||||
import org.xmlpull.v1.XmlSerializer;
|
import org.xmlpull.v1.XmlSerializer;
|
||||||
@ -42,19 +44,20 @@ public class ResXmlSerializer extends MXSerializer {
|
|||||||
if (! mDecodingEnabled) {
|
if (! mDecodingEnabled) {
|
||||||
return super.attribute(namespace, name, value);
|
return super.attribute(namespace, name, value);
|
||||||
}
|
}
|
||||||
if (namespace == null || namespace.isEmpty()) {
|
|
||||||
return super.attribute(namespace, name,
|
|
||||||
AndrolibResources.escapeForResXml(value)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
String pkgName = RES_NAMESPACE.equals(namespace) ?
|
|
||||||
"android" : mCurrentPackage.getName();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
ResScalarValue resValue =
|
||||||
|
mCurrentPackage.getValueFactory().factory(value);
|
||||||
|
|
||||||
|
if (namespace == null || namespace.isEmpty()) {
|
||||||
|
value = resValue.toResXmlFormat();
|
||||||
|
} else {
|
||||||
|
String pkgName = RES_NAMESPACE.equals(namespace) ?
|
||||||
|
"android" : mCurrentPackage.getName();
|
||||||
ResAttr attr = (ResAttr) mCurrentPackage.getResTable()
|
ResAttr attr = (ResAttr) mCurrentPackage.getResTable()
|
||||||
.getValue(pkgName, "attr", name);
|
.getValue(pkgName, "attr", name);
|
||||||
value = attr.convertToResXmlFormat(
|
value = attr.convertToResXmlFormat(resValue);
|
||||||
mCurrentPackage.getValueFactory().factory(value));
|
}
|
||||||
} catch (AndrolibException ex) {
|
} catch (AndrolibException ex) {
|
||||||
throw new IllegalArgumentException(String.format(
|
throw new IllegalArgumentException(String.format(
|
||||||
"could not decode attribute: ns=%s, name=%s, value=%s",
|
"could not decode attribute: ns=%s, name=%s, value=%s",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user