WindySha / Xpatch

This is a tool to repackage apk file, then the apk can load any xposed modules installed in the device. It is another way to hook an app without root device.
Apache License 2.0
2.54k stars 388 forks source link

把模块打包进apk后,模块如何访问自己的resource? #57

Closed yujincheng08 closed 4 years ago

yujincheng08 commented 4 years ago

之前我都是用createPackageContext(BuildConfig.APPLICATION_ID, Context.CONTEXT_IGNORE_SECURITY)来获取模块本身资源的。如果把模块打包进apk之后,模块本身是没有安装的,这样就不能用createPackageContext了。而ResourceHook也不能用,那如何访问自己的resource呢?(我现在是想把模块preference的xml加载起来然后再app里面搞一个设置页面)

WindySha commented 4 years ago

可以参考FridaXposedModule项目里的 AppUtils里的getPluginApkPath()方法,获取到当前模块文件的路径,然后反射构造一个AssetManager,反射调用其addAssetPath方法,将此路径设进去,即可以得到模块的AssetManager。