Package io.github.libxposed.api
Interface XposedInterface.HookHandle
- Enclosing interface:
XposedInterface
public static interface XposedInterface.HookHandle
Handle for a hook.
-
Method Summary
Modifier and TypeMethodDescriptionGets the method / constructor being hooked.getId()Gets the unique id of the hook, or null if the hook is not assigned with an id.replaceHook(XposedInterface.Hooker hooker) Atomically replaces this hook with a new hooker and returns the new hook handle.voidunhook()Cancels the hook.
-
Method Details
-
getExecutable
Gets the method / constructor being hooked. -
unhook
void unhook()Cancels the hook. This method is idempotent. It is safe to call this method multiple times. -
getId
Gets the unique id of the hook, or null if the hook is not assigned with an id. -
replaceHook
@SinceApi(102) @NonNull XposedInterface.HookHandle replaceHook(@NonNull XposedInterface.Hooker hooker) Atomically replaces this hook with a new hooker and returns the new hook handle.The replacement keeps the executable, priority, exception handling mode, and id of this hook. For a hook with an id, this targets the same hook as creating a new hook on the same executable with the same id. This method is the handle-based form of replacement and can also replace a hook without an id. It is useful during hot reloading when new code receives old hook handles from
XposedModuleInterface.HotReloadedParam.getOldHookHandles(). After a successful replacement, this handle is no longer valid.The hook chain is snapshot based. Replacing a hook while a call is running does not affect that in-flight call.
- Parameters:
hooker- The new hooker object- Returns:
- The new handle for the replaced hook
- Throws:
IllegalArgumentException- if hooker is invalidIllegalStateException- if this hook handle is no longer validHookFailedError- if replacement fails due to framework internal error
-