Use name instead of annotation to indicate before/after callback
This commit is contained in:
parent
55efdf9d15
commit
7b6727313c
|
|
@ -1 +1,5 @@
|
||||||
-keep class io.github.libxposed.** { *; }
|
-keep class io.github.libxposed.** { *; }
|
||||||
|
-keepclassmembers,allowoptimization class ** implements io.github.libxposed.api.XposedInterface$Hooker {
|
||||||
|
public *** before(***);
|
||||||
|
public *** after(***);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,9 +15,6 @@ import java.lang.reflect.Member;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.nio.ByteBuffer;
|
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.errors.HookFailedError;
|
||||||
import io.github.libxposed.api.utils.DexParser;
|
import io.github.libxposed.api.utils.DexParser;
|
||||||
|
|
||||||
|
|
@ -166,9 +163,8 @@ public interface XposedInterface {
|
||||||
* like the old API.
|
* like the old API.
|
||||||
*
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* Classes implementing this interface should be annotated with {@link XposedHooker} and should provide
|
* Classes implementing this interface should should provide two public static methods named
|
||||||
* two public static methods that are annotated with {@link BeforeInvocation} and {@link AfterInvocation},
|
* before and after for before invocation and after invocation respectively.
|
||||||
* respectively.
|
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* <p>
|
* <p>
|
||||||
|
|
@ -187,30 +183,24 @@ public interface XposedInterface {
|
||||||
* <p>Example usage:</p>
|
* <p>Example usage:</p>
|
||||||
*
|
*
|
||||||
* <pre>{@code
|
* <pre>{@code
|
||||||
* @XposedHooker
|
|
||||||
* public class ExampleHooker implements Hooker {
|
* public class ExampleHooker implements Hooker {
|
||||||
*
|
*
|
||||||
* @BeforeInvocation
|
|
||||||
* public static void before(@NonNull BeforeHookCallback callback) {
|
* public static void before(@NonNull BeforeHookCallback callback) {
|
||||||
* // Pre-hooking logic goes here
|
* // Pre-hooking logic goes here
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* @AfterInvocation
|
|
||||||
* public static void after(@NonNull AfterHookCallback callback) {
|
* public static void after(@NonNull AfterHookCallback callback) {
|
||||||
* // Post-hooking logic goes here
|
* // Post-hooking logic goes here
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* @XposedHooker
|
|
||||||
* public class ExampleHookerWithContext implements Hooker {
|
* public class ExampleHookerWithContext implements Hooker {
|
||||||
*
|
*
|
||||||
* @BeforeInvocation
|
|
||||||
* public static MyContext before(@NonNull BeforeHookCallback callback) {
|
* public static MyContext before(@NonNull BeforeHookCallback callback) {
|
||||||
* // Pre-hooking logic goes here
|
* // Pre-hooking logic goes here
|
||||||
* return new MyContext();
|
* return new MyContext();
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* @AfterInvocation
|
|
||||||
* public static void after(@NonNull AfterHookCallback callback, MyContext context) {
|
* public static void after(@NonNull AfterHookCallback callback, MyContext context) {
|
||||||
* // Post-hooking logic goes here
|
* // Post-hooking logic goes here
|
||||||
* }
|
* }
|
||||||
|
|
|
||||||
|
|
@ -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 {
|
|
||||||
}
|
|
||||||
|
|
@ -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 {
|
|
||||||
}
|
|
||||||
|
|
@ -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 {
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue