mirror of
https://github.com/revanced/Apktool.git
synced 2024-12-11 13:27:47 +01:00
fix: resolve missing namespace on system resources (#3234)
* fix: resolve missing namespace on system resources * refactor: align pkdId check to 2nd of if
This commit is contained in:
parent
57ef8a205a
commit
cd275ff48b
@ -276,6 +276,15 @@ public class AXmlResourceParser implements XmlResourceParser {
|
|||||||
public String getAttributeNamespace(int index) {
|
public String getAttributeNamespace(int index) {
|
||||||
int offset = getAttributeOffset(index);
|
int offset = getAttributeOffset(index);
|
||||||
int namespace = mAttributes[offset + ATTRIBUTE_IX_NAMESPACE_URI];
|
int namespace = mAttributes[offset + ATTRIBUTE_IX_NAMESPACE_URI];
|
||||||
|
|
||||||
|
// #2972 - If the namespace index is -1, the attribute is not present, but if the attribute is from system
|
||||||
|
// we can resolve it to the default namespace. This may prove to be too aggressive as we scope the entire
|
||||||
|
// system namespace, but it is better than not resolving it at all.
|
||||||
|
ResID resId = new ResID(getAttributeNameResource(index));
|
||||||
|
if (namespace == -1 && resId.pkgId == 1) {
|
||||||
|
return ANDROID_RES_NS;
|
||||||
|
}
|
||||||
|
|
||||||
if (namespace == -1) {
|
if (namespace == -1) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
@ -284,12 +293,11 @@ public class AXmlResourceParser implements XmlResourceParser {
|
|||||||
// unless the pkgId of the resource is private. We will grab the non-standard one.
|
// unless the pkgId of the resource is private. We will grab the non-standard one.
|
||||||
String value = mStringBlock.getString(namespace);
|
String value = mStringBlock.getString(namespace);
|
||||||
|
|
||||||
if (value == null || value.length() == 0) {
|
if (value == null || value.isEmpty()) {
|
||||||
ResID resId = new ResID(getAttributeNameResource(index));
|
|
||||||
if (resId.pkgId == PRIVATE_PKG_ID) {
|
if (resId.pkgId == PRIVATE_PKG_ID) {
|
||||||
value = getNonDefaultNamespaceUri(offset);
|
return getNonDefaultNamespaceUri(offset);
|
||||||
} else {
|
} else {
|
||||||
value = "http://schemas.android.com/apk/res/android";
|
return ANDROID_RES_NS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,7 +316,7 @@ public class AXmlResourceParser implements XmlResourceParser {
|
|||||||
// We have the namespaces that can't be touched in the opening tag.
|
// We have the namespaces that can't be touched in the opening tag.
|
||||||
// Though no known way to correlate them at this time.
|
// Though no known way to correlate them at this time.
|
||||||
// So return the res-auto namespace.
|
// So return the res-auto namespace.
|
||||||
return "http://schemas.android.com/apk/res-auto";
|
return ANDROID_RES_NS_AUTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -828,4 +836,7 @@ public class AXmlResourceParser implements XmlResourceParser {
|
|||||||
private static final int ATTRIBUTE_LENGTH = 5;
|
private static final int ATTRIBUTE_LENGTH = 5;
|
||||||
|
|
||||||
private static final int PRIVATE_PKG_ID = 0x7F;
|
private static final int PRIVATE_PKG_ID = 0x7F;
|
||||||
|
|
||||||
|
private static final String ANDROID_RES_NS_AUTO = "http://schemas.android.com/apk/res-auto";
|
||||||
|
private static final String ANDROID_RES_NS = "http://schemas.android.com/apk/res/android";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user