mirror of
https://github.com/revanced/Apktool.git
synced 2025-04-30 06:04:25 +02:00
ResXmlSerializer: normal value serializing if attr is undefined.
This commit is contained in:
parent
8c0a1a0c98
commit
2d9580eb86
@ -18,11 +18,11 @@
|
|||||||
package brut.androlib.res.decoder;
|
package brut.androlib.res.decoder;
|
||||||
|
|
||||||
import brut.androlib.*;
|
import brut.androlib.*;
|
||||||
|
import brut.androlib.err.UndefinedResObject;
|
||||||
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.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;
|
||||||
@ -44,24 +44,35 @@ public class ResXmlSerializer extends MXSerializer {
|
|||||||
if (! mDecodingEnabled) {
|
if (! mDecodingEnabled) {
|
||||||
return super.attribute(namespace, name, value);
|
return super.attribute(namespace, name, value);
|
||||||
}
|
}
|
||||||
|
String origVal = value;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ResScalarValue resValue =
|
ResScalarValue resValue =
|
||||||
mCurrentPackage.getValueFactory().factory(value);
|
mCurrentPackage.getValueFactory().factory(value);
|
||||||
|
value = null;
|
||||||
|
|
||||||
if (namespace == null || namespace.isEmpty()) {
|
if (namespace != null && ! namespace.isEmpty()) {
|
||||||
value = resValue.toResXmlFormat();
|
|
||||||
} else {
|
|
||||||
String pkgName = RES_NAMESPACE.equals(namespace) ?
|
String pkgName = RES_NAMESPACE.equals(namespace) ?
|
||||||
"android" : mCurrentPackage.getName();
|
"android" : mCurrentPackage.getName();
|
||||||
|
try {
|
||||||
ResAttr attr = (ResAttr) mCurrentPackage.getResTable()
|
ResAttr attr = (ResAttr) mCurrentPackage.getResTable()
|
||||||
.getValue(pkgName, "attr", name);
|
.getValue(pkgName, "attr", name);
|
||||||
value = attr.convertToResXmlFormat(resValue);
|
value = attr.convertToResXmlFormat(resValue);
|
||||||
|
} catch (UndefinedResObject ex) {
|
||||||
|
System.err.println(String.format(
|
||||||
|
"warning: udefined attr when decoding: " +
|
||||||
|
"ns=%s, name=%s, value=%s",
|
||||||
|
namespace, name, origVal));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value == null) {
|
||||||
|
value = resValue.toResXmlFormat();
|
||||||
}
|
}
|
||||||
} 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",
|
||||||
namespace, name, value), ex);
|
namespace, name, origVal), ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user