FORUMS

Xposed how to replace XML resource in framework-res android package

117 posts
Thanks Meter: 45
 
By shihabsoft, Senior Member on 13th May 2020, 07:44 PM
Post Reply Email Thread
I am trying to replace the xml resource "config_webview_packages" in android package.

I've tried both systemWideReplacement and setReplacement in hookinit resource

Code:
XposedBridge.log("Detected android package");
		XModuleResources modRes = XModuleResources.createInstance(MODULE_PATH, null);
		XResources.setSystemWideReplacement("android", "xml", "config_webview_packages", modRes.fwd(R.xml.config_webview_packages));
		XposedBridge.log("Replaced config_webview_packages");
		int id = modRes.getIdentifier("config_webview_packages", "xml", "android");
		XposedBridge.log(id + " " + modRes.getXml(id));

When I use system wide replacement in initZygote, the device goes into bootloop, this is the logcat.

Code:
05-13 21:28:06.959  1975  1975 D AndroidRuntime: Shutting down VM
05-13 21:28:06.959  1975  1975 E AndroidRuntime: *** FATAL EXCEPTION IN SYSTEM PROCESS: main
05-13 21:28:06.959  1975  1975 E AndroidRuntime: java.lang.RuntimeException: Failed to create service com.android.server.webkit.WebViewUpdateService: service constructor threw an exception
05-13 21:28:06.959  1975  1975 E AndroidRuntime: 	at com.android.server.SystemServiceManager.startService(SystemServiceManager.java:104)
05-13 21:28:06.959  1975  1975 E AndroidRuntime: 	at com.android.server.SystemServer.startCoreServices(SystemServer.java:516)
05-13 21:28:06.959  1975  1975 E AndroidRuntime: 	at com.android.server.SystemServer.run(SystemServer.java:339)
05-13 21:28:06.959  1975  1975 E AndroidRuntime: 	at com.android.server.SystemServer.main(SystemServer.java:222)
05-13 21:28:06.959  1975  1975 E AndroidRuntime: 	at java.lang.reflect.Method.invoke(Native Method)
05-13 21:28:06.959  1975  1975 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:890)
05-13 21:28:06.959  1975  1975 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:780)
05-13 21:28:06.959  1975  1975 E AndroidRuntime: 	at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:107)
05-13 21:28:06.959  1975  1975 E AndroidRuntime: Caused by: java.lang.reflect.InvocationTargetException
05-13 21:28:06.959  1975  1975 E AndroidRuntime: 	at java.lang.reflect.Constructor.newInstance0(Native Method)
05-13 21:28:06.959  1975  1975 E AndroidRuntime: 	at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
05-13 21:28:06.959  1975  1975 E AndroidRuntime: 	at com.android.server.SystemServiceManager.startService(SystemServiceManager.java:93)
05-13 21:28:06.959  1975  1975 E AndroidRuntime: 	... 7 more
05-13 21:28:06.959  1975  1975 E AndroidRuntime: Caused by: java.lang.NoSuchFieldError: android.content.res.XModuleResources#mCachedXmlBlockIds
05-13 21:28:06.959  1975  1975 E AndroidRuntime: 	at de.robv.android.xposed.XposedHelpers.findField(XposedHelpers.java:116)
05-13 21:28:06.959  1975  1975 E AndroidRuntime: 	at de.robv.android.xposed.XposedHelpers.getObjectField(XposedHelpers.java:894)
05-13 21:28:06.959  1975  1975 E AndroidRuntime: 	at android.content.res.XResources.isXmlCached(XResources.java:1121)
05-13 21:28:06.959  1975  1975 E AndroidRuntime: 	at android.content.res.XResources.getXml(XResources.java:1105)
05-13 21:28:06.959  1975  1975 E AndroidRuntime: 	at com.android.server.webkit.SystemImpl.<init>(SystemImpl.java:81)
05-13 21:28:06.959  1975  1975 E AndroidRuntime: 	at com.android.server.webkit.SystemImpl.<init>(SystemImpl.java)
05-13 21:28:06.959  1975  1975 E AndroidRuntime: 	at com.android.server.webkit.SystemImpl$LazyHolder.<clinit>(SystemImpl.java:67)
05-13 21:28:06.959  1975  1975 E AndroidRuntime: 	at com.android.server.webkit.SystemImpl.getInstance(SystemImpl.java:71)
05-13 21:28:06.959  1975  1975 E AndroidRuntime: 	at com.android.server.webkit.WebViewUpdateService.<init>(WebViewUpdateService.java:58)
05-13 21:28:06.959  1975  1975 E AndroidRuntime: 	... 10 more

When I try setReplacement in handleInitPackageResources, the code works but the resource doesn't get replaced.

Kinda stuck now.. any help?
Post Reply Subscribe to Thread

Tags
framework-res, setsystemwidereplacement, xml, xposed

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes