Interface XposedInterface.HookHandle

Enclosing interface:
XposedInterface

public static interface XposedInterface.HookHandle
Handle for a hook.
  • Method Details

    • getExecutable

      @NonNull Executable 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

      @SinceApi(102) @Nullable String 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 invalid
      IllegalStateException - if this hook handle is no longer valid
      HookFailedError - if replacement fails due to framework internal error