首页 > 代码库 > Xposed 学习笔记

Xposed 学习笔记

Xposed框架用法

1、配置AndroidManifest.xml

<meta-data
android:name="xposedmodule"
android:value="http://www.mamicode.com/true" />
<meta-data
android:name="xposeddescription"
android:value="http://www.mamicode.com/获取packageName" />
<meta-data
android:name="xposedminversion"
android:value="http://www.mamicode.com/30" />

2、在assets目录下创建xposed_init文件声明入口类

3、gradle中引入编译时使用
provided ‘de.robv.android.xposed:api:82‘
provided ‘de.robv.android.xposed:api:82:sources‘

4.入口类实现IXposedHookLoadPackage接口即可。

5、使用方法:
XC_LoadPackage.LoadPackageParam

hook方法
XposedHelpers.findAndHookMethod
(1)、获取Class
Class<?> clazz=XposedHelpers.findClass("com.android.mms.data.WorkingMessage", lpparam.classLoader);
获取activity实例findAndHookMethod("com.tencent.mm.ui.LauncherUI", loadPackageParam.classLoader, "onCreate", Bundle.class, new XC_MethodHook() {

@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
Activity activity = (Activity) param.thisObject;
}
});

 

获取Context
Context context = (Context) callMethod(callStaticMethod(findClass("android.app.ActivityThread", null), "currentActivityThread", new Object[0]), "getSystemContext", new Object[0]);

 

(2)、获取field修改

 


相关文档:http://api.xposed.info/reference/packages.html
http://www.tuicool.com/articles/aaaEfmu



Xposed 学习笔记