Use name instead of annotation to indicate before/after callback

This commit is contained in:
LoveSy 2024-07-22 22:18:49 +08:00
parent 55efdf9d15
commit 7b6727313c
No known key found for this signature in database
5 changed files with 6 additions and 45 deletions

View File

@ -1 +1,5 @@
-keep class io.github.libxposed.** { *; }
-keepclassmembers,allowoptimization class ** implements io.github.libxposed.api.XposedInterface$Hooker {
public *** before(***);
public *** after(***);
}

View File

@ -15,9 +15,6 @@ import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.nio.ByteBuffer;
import io.github.libxposed.api.annotations.AfterInvocation;
import io.github.libxposed.api.annotations.BeforeInvocation;
import io.github.libxposed.api.annotations.XposedHooker;
import io.github.libxposed.api.errors.HookFailedError;
import io.github.libxposed.api.utils.DexParser;
@ -166,9 +163,8 @@ public interface XposedInterface {
* like the old API.
*
* <p>
* Classes implementing this interface should be annotated with {@link XposedHooker} and should provide
* two public static methods that are annotated with {@link BeforeInvocation} and {@link AfterInvocation},
* respectively.
* Classes implementing this interface should should provide two public static methods named
* before and after for before invocation and after invocation respectively.
* </p>
*
* <p>
@ -187,30 +183,24 @@ public interface XposedInterface {
* <p>Example usage:</p>
*
* <pre>{@code
* @XposedHooker
* public class ExampleHooker implements Hooker {
*
* @BeforeInvocation
* public static void before(@NonNull BeforeHookCallback callback) {
* // Pre-hooking logic goes here
* }
*
* @AfterInvocation
* public static void after(@NonNull AfterHookCallback callback) {
* // 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
* }

View File

@ -1,11 +0,0 @@
package io.github.libxposed.api.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface AfterInvocation {
}

View File

@ -1,11 +0,0 @@
package io.github.libxposed.api.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface BeforeInvocation {
}

View File

@ -1,11 +0,0 @@
package io.github.libxposed.api.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.TYPE_USE})
public @interface XposedHooker {
}