public abstract class XC_MethodHook extends XCallback
Usually, anonymous subclasses of this class are created which override
beforeHookedMethod(de.robv.android.xposed.XC_MethodHook.MethodHookParam<?>)
and/or afterHookedMethod(de.robv.android.xposed.XC_MethodHook.MethodHookParam<?>)
.
Modifier and Type | Class and Description |
---|---|
static class |
XC_MethodHook.MethodHookParam<T extends java.lang.reflect.Executable>
Wraps information about the method call and allows to influence it.
|
class |
XC_MethodHook.Unhook
An object with which the method/constructor can be unhooked.
|
XCallback.Param
priority, PRIORITY_DEFAULT, PRIORITY_HIGHEST, PRIORITY_LOWEST
Constructor and Description |
---|
XC_MethodHook()
Creates a new callback with default priority.
|
XC_MethodHook(int priority)
Creates a new callback with a specific priority.
|
Modifier and Type | Method and Description |
---|---|
protected void |
afterHookedMethod(XC_MethodHook.MethodHookParam<?> param)
Called after the invocation of the method.
|
protected void |
beforeHookedMethod(XC_MethodHook.MethodHookParam<?> param)
Called before the invocation of the method.
|
void |
callAfterHookedMethod(XC_MethodHook.MethodHookParam<?> param) |
void |
callBeforeHookedMethod(XC_MethodHook.MethodHookParam<?> param) |
public XC_MethodHook()
public XC_MethodHook(int priority)
Note that afterHookedMethod(de.robv.android.xposed.XC_MethodHook.MethodHookParam<?>)
will be called in reversed order, i.e.
the callback with the highest priority will be called last. This way, the callback has the
final control over the return value. beforeHookedMethod(de.robv.android.xposed.XC_MethodHook.MethodHookParam<?>)
is called as usual, i.e.
highest priority first.
priority
- See XCallback.priority
.protected void beforeHookedMethod(XC_MethodHook.MethodHookParam<?> param) throws java.lang.Throwable
You can use XC_MethodHook.MethodHookParam.setResult(java.lang.Object)
and XC_MethodHook.MethodHookParam.setThrowable(java.lang.Throwable)
to prevent the original method from being called.
Note that implementations shouldn't call super(param)
, it's not necessary.
param
- Information about the method call.java.lang.Throwable
- Everything the callback throws is caught and logged.public void callBeforeHookedMethod(XC_MethodHook.MethodHookParam<?> param) throws java.lang.Throwable
java.lang.Throwable
protected void afterHookedMethod(XC_MethodHook.MethodHookParam<?> param) throws java.lang.Throwable
You can use XC_MethodHook.MethodHookParam.setResult(java.lang.Object)
and XC_MethodHook.MethodHookParam.setThrowable(java.lang.Throwable)
to modify the return value of the original method.
Note that implementations shouldn't call super(param)
, it's not necessary.
param
- Information about the method call.java.lang.Throwable
- Everything the callback throws is caught and logged.public void callAfterHookedMethod(XC_MethodHook.MethodHookParam<?> param) throws java.lang.Throwable
java.lang.Throwable