xposed钩住ViewGroup崩溃的所有方法

时间:2019-11-08 17:06:06

标签: xposed

我想钩住ViewGroup的所有方法,所以写下面的代码:

final Class<?> mViewGroup = XposedHelpers.findClass("android.view.ViewGroup", lpparam.classLoader);
for (final Method method : mViewGroup.getDeclaredMethods()) {
    if (true == Modifier.isAbstract(method.getModifiers())){
        XposedBridge.log("skip abstract:" + method.getName());
        continue;
    }
    XposedBridge.log("----" + method.getName());
    XposedBridge.hookMethod(method, methodHook);
}

final StringBuilder sb = new StringBuilder();
XC_MethodHook methodHook = new XC_MethodHook() {
    @Override
    protected void beforeHookedMethod(XC_MethodHook.MethodHookParam param) throws Throwable {
        dumpParams(param);
    }

    @Override
    protected void afterHookedMethod(XC_MethodHook.MethodHookParam param) throws Throwable {
        //param.setResult(false);
        XposedBridge.log("after:" + param.getResult());
    }
};

private void dumpParams(XC_MethodHook.MethodHookParam param) {
    sb.setLength(0);
    sb.append(param.method.getName()).append("(");
    for (Object o:param.args) {
        String typnam = "";
        String value = "null";
        if (o != null) {
            typnam = o.getClass().getName();
            value = o.toString();
        }
        sb.append(typnam).append(":").append(value).append(", ");
    }
    XposedBridge.log(sb.toString());
}

但是当我运行它时,钩子类听起来不错,但是执行时它在android.view.View$AttachInfo处崩溃了:

am_crash: `java.lang.IllegalAccessError,Illegal class access: 'EdHooker45' attempting to access 'android.view.View$AttachInfo' (declaration of 'EdHooker45' appears in /data/user_de/0/.../1129433416.jar),NULL,120]`

0 个答案:

没有答案