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:
Connor Tumbleson 2016-08-06 08:31:58 -04:00
parent 0e0f8b0dee
commit d0baa841eb
No known key found for this signature in database
GPG Key ID: C3CC0A201EC7DA75

View File

@ -82,6 +82,7 @@ public final class ResXmlPatcher {
* @throws AndrolibException
*/
public static void fixingPublicAttrsInProviderAttributes(File file) throws AndrolibException {
boolean saved = false;
if (file.exists()) {
try {
Document doc = loadDocument(file);
@ -104,11 +105,41 @@ public final class ResXmlPatcher {
if (replacement != null) {
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);
}
}
}
}
} catch (SAXException | ParserConfigurationException | IOException |
XPathExpressionException | TransformerException ignored) {