I'm hooking the android framework itself,not a specific app,this is my code:
public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable {
if (lpparam == null||lpparam.packageName == null || lpparam.processName == null)
return;
if (lpparam.packageName.equals("android")) {
XposedBridge.log("Hooked into Android framework.");
if (!sInitialized) {
sInitialized = true;
hookSetVisibility(lpparam);
}
}
}
private void hookSetVisibility(XC_LoadPackage.LoadPackageParam lpparam) {
final Class<?> mViewGroup = XposedHelpers.findClass("android.widget.TextView", 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 {
XposedBridge.log("before hook log");
}
@Override
protected void afterHookedMethod(XC_MethodHook.MethodHookParam param) throws Throwable {
//param.setResult(false);
XposedBridge.log("after hook log");
}
};
The module indeed prints nicely the all class method names as can seen in the android framework,but the BeforeHookedMethod
and the afterHookMethod
never get called......
Your main problem is that you are trying to limiting the hook the "Android framework" only which will fail as the Android framework is not a separate process but included in every app process, respectively the
TextView
elements are part of the app process they are shown in.As far as I remember
handleLoadPackage
is called once per app process which allows you to decide if or if not you want to hook something in this specific app process.But as you want to hook a certain UI element in any app, you should not apply a filter here. So in the end you should remove the filter (or only filter out apps that make problems with your hook) and then directly call
hookSetVisibility
.