diff --git a/api/src/main/java/io/github/libxposed/api/XposedInterface.java b/api/src/main/java/io/github/libxposed/api/XposedInterface.java index 7e072bf..4e6a3e2 100644 --- a/api/src/main/java/io/github/libxposed/api/XposedInterface.java +++ b/api/src/main/java/io/github/libxposed/api/XposedInterface.java @@ -100,16 +100,6 @@ public interface XposedInterface { * @param throwable The exception to be thrown */ void throwAndSkip(@Nullable Throwable throwable); - - /** - * Sets an extra object to the hook context in order to share additional contextual information - * between the before and after invocation callbacks of the same procedure call. - * - * @param The type of the extra object - * @param key The name of the extra object - * @param value The extra object - */ - void setExtra(@NonNull String key, @Nullable T value); } /** @@ -167,16 +157,6 @@ public interface XposedInterface { * @param throwable The exception to be thrown. */ void setThrowable(@Nullable Throwable throwable); - - /** - * Gets an extra object saved by the before invocation callback of the same procedure call. - * - * @param The type of the extra object - * @param key The name of the extra object - * @return The extra object, or {@code null} if not found - */ - @Nullable - T getExtra(@NonNull String key); } /** @@ -193,19 +173,22 @@ public interface XposedInterface { * *

* The before invocation method should have the following signature:
- * params: {@code callback} - The {@link BeforeHookCallback} of the procedure call
+ * Param {@code callback}: The {@link BeforeHookCallback} of the procedure call.
+ * Return value: If you want to save contextual information of one procedure call between the before + * and after callback, it could be a self-defined class, otherwise it should be {@code void}. *

* *

* The after invocation method should have the following signature:
- * params: {@code callback} - The {@link AfterHookCallback} of the procedure call
+ * Param {@code callback}: The {@link AfterHookCallback} of the procedure call.
+ * Param {@code context} (optional): The contextual object returned by the before invocation. *

* *

Example usage:

* *
{@code
      *   @XposedHooker
-     *   public class ExampleHooker implements XposedInterface.Hooker {
+     *   public class ExampleHooker implements Hooker {
      *
      *       @BeforeInvocation
      *       public static void before(@NonNull BeforeHookCallback callback) {
@@ -217,6 +200,21 @@ public interface XposedInterface {
      *           // Post-hooking logic goes here
      *       }
      *   }
+     *
+     *   @XposedHooker
+     *   public class ExampleHookerWithContext implements Hooker {
+     *
+     *       @BeforeInvocation
+     *       public static MyContext before(@NonNull BeforeHookCallback callback) {
+     *           // Pre-hooking logic goes here
+     *           return new MyContext();
+     *       }
+     *
+     *       @AfterInvocation
+     *       public static void after(@NonNull AfterHookCallback callback, MyContext context) {
+     *           // Post-hooking logic goes here
+     *       }
+     *   }
      * }
*/ interface Hooker {