mirror of
https://github.com/revanced/Apktool.git
synced 2025-05-02 23:04:26 +02:00
Add support for getting literal values for references in android:scheme
- side affect of using public.xml to get constant resource ids - fixes #1097
This commit is contained in:
parent
0e0f8b0dee
commit
d0baa841eb
@ -82,6 +82,7 @@ public final class ResXmlPatcher {
|
|||||||
* @throws AndrolibException
|
* @throws AndrolibException
|
||||||
*/
|
*/
|
||||||
public static void fixingPublicAttrsInProviderAttributes(File file) throws AndrolibException {
|
public static void fixingPublicAttrsInProviderAttributes(File file) throws AndrolibException {
|
||||||
|
boolean saved = false;
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
try {
|
try {
|
||||||
Document doc = loadDocument(file);
|
Document doc = loadDocument(file);
|
||||||
@ -104,11 +105,41 @@ public final class ResXmlPatcher {
|
|||||||
|
|
||||||
if (replacement != null) {
|
if (replacement != null) {
|
||||||
provider.setNodeValue(replacement);
|
provider.setNodeValue(replacement);
|
||||||
|
saved = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// android:scheme
|
||||||
|
xPath = XPathFactory.newInstance().newXPath();
|
||||||
|
expression = xPath.compile("/manifest/application/activity/intent-filter/data");
|
||||||
|
|
||||||
|
result = expression.evaluate(doc, XPathConstants.NODESET);
|
||||||
|
nodes = (NodeList) result;
|
||||||
|
|
||||||
|
for (int i = 0; i < nodes.getLength(); i++) {
|
||||||
|
Node node = nodes.item(i);
|
||||||
|
NamedNodeMap attrs = node.getAttributes();
|
||||||
|
|
||||||
|
if (attrs != null) {
|
||||||
|
Node provider = attrs.getNamedItem("android:scheme");
|
||||||
|
|
||||||
|
if (provider != null) {
|
||||||
|
String reference = provider.getNodeValue();
|
||||||
|
String replacement = pullValueFromStrings(file.getParentFile(), reference);
|
||||||
|
|
||||||
|
if (replacement != null) {
|
||||||
|
provider.setNodeValue(replacement);
|
||||||
|
saved = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (saved) {
|
||||||
saveDocument(file, doc);
|
saveDocument(file, doc);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (SAXException | ParserConfigurationException | IOException |
|
} catch (SAXException | ParserConfigurationException | IOException |
|
||||||
XPathExpressionException | TransformerException ignored) {
|
XPathExpressionException | TransformerException ignored) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user