-
|
How can add I want to add <?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true">
<trust-anchors>
<certificates src="system" />
<certificates
overridePins="true"
src="user" />
</trust-anchors>
</base-config>
<debug-overrides>
<trust-anchors>
<certificates src="system" />
<certificates
overridePins="true"
src="user" />
</trust-anchors>
</debug-overrides>
</network-security-config>I think need adding attribute & name in int ID_networkSecurityConfig = ObjectsUtil.of(0x01010527);
int ID_usesCleartextTraffic = ObjectsUtil.of(0x010104ec);
String NAME_networkSecurityConfig = ObjectsUtil.of("networkSecurityConfig");
String NAME_usesCleartextTraffic = ObjectsUtil.of("usesCleartextTraffic");I am patching an APK with dexlib2, can I use it in this with my merge script & or without merge mean (".apk") how do I apply because I am not decompiling the apk My merge script here - Merger.java |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
|
You don't need to add constants to The important part is: Shape of the patch: TableBlock table = apkModule.getTableBlock();
PackageBlock pkg = table.pickOne();
String path = "res/xml/network_security_config.xml";
String xml = """
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true">
<trust-anchors>
<certificates src="system" />
<certificates overridePins="true" src="user" />
</trust-anchors>
</base-config>
<debug-overrides>
<trust-anchors>
<certificates src="system" />
<certificates overridePins="true" src="user" />
</trust-anchors>
</debug-overrides>
</network-security-config>
""";
apkModule.add(new XMLEncodeSource(
pkg,
new XMLStringParserSource(path, xml)
));
Entry xmlEntry = pkg.getOrCreate("", "xml", "network_security_config");
xmlEntry.setValueAsString(path);
AndroidManifestBlock manifest = apkModule.getAndroidManifest();
ResXmlElement app = manifest.getOrCreateApplicationElement();
app.getOrCreateAndroidAttribute("usesCleartextTraffic", 0x010104ec)
.setValueAsBoolean(true);
app.getOrCreateAndroidAttribute("networkSecurityConfig", 0x01010527)
.setTypeAndData(ValueType.REFERENCE, xmlEntry.getResourceId());
manifest.refreshFull();If the XML already exists as a file, use |
Beta Was this translation helpful? Give feedback.
-
|
@krotname Awesome answer ! You have good understanding of this project hope I will see you again in PRs :) |
Beta Was this translation helpful? Give feedback.
You don't need to add constants to
AndroidManifestBlockfor this. You can use the raw Android attribute ids and set the manifest value as a resource reference.The important part is:
android:networkSecurityConfigmust point to a real@xml/...resource id, not to the string"@xml/network_security_config".Shape of the patch: