From 1eff0ee2c98724e8a72c64d19eeff638c95da32a Mon Sep 17 00:00:00 2001 From: Nullptr Date: Thu, 12 Jan 2023 00:59:29 +0800 Subject: [PATCH] Revert "Make all hooks non-null" This reverts commit 0cf4d3170e6f75b02f4cb2a0ee405145fa52ccf4. --- .../libxposed/XposedContextWrapper.java | 24 +++---- .../io/github/libxposed/XposedInterface.java | 68 ++++--------------- 2 files changed, 24 insertions(+), 68 deletions(-) diff --git a/api/src/main/java/io/github/libxposed/XposedContextWrapper.java b/api/src/main/java/io/github/libxposed/XposedContextWrapper.java index d228ad3..8e5dd5c 100644 --- a/api/src/main/java/io/github/libxposed/XposedContextWrapper.java +++ b/api/src/main/java/io/github/libxposed/XposedContextWrapper.java @@ -80,73 +80,73 @@ public class XposedContextWrapper extends ContextWrapper implements XposedInterf return getBaseContext().featuredMethod(name, args); } - @NonNull + @Nullable @Override final public MethodUnhooker, Method> hookBefore(@NonNull Method origin, @NonNull BeforeHooker hooker) { return getBaseContext().hookBefore(origin, hooker); } - @NonNull + @Nullable @Override final public MethodUnhooker, Method> hookAfter(@NonNull Method origin, @NonNull AfterHooker hooker) { return getBaseContext().hookAfter(origin, hooker); } - @NonNull + @Nullable @Override final public MethodUnhooker, Method> hook(@NonNull Method origin, @NonNull Hooker hooker) { return getBaseContext().hook(origin, hooker); } - @NonNull + @Nullable @Override final public MethodUnhooker, Method> hookBefore(@NonNull Method origin, int priority, @NonNull BeforeHooker hooker) { return getBaseContext().hookBefore(origin, priority, hooker); } - @NonNull + @Nullable @Override final public MethodUnhooker, Method> hookAfter(@NonNull Method origin, int priority, @NonNull AfterHooker hooker) { return getBaseContext().hookAfter(origin, priority, hooker); } - @NonNull + @Nullable @Override final public MethodUnhooker, Method> hook(@NonNull Method origin, int priority, @NonNull Hooker hooker) { return getBaseContext().hook(origin, priority, hooker); } - @NonNull + @Nullable @Override final public MethodUnhooker>, Constructor> hookBefore(@NonNull Constructor origin, @NonNull BeforeHooker> hooker) { return getBaseContext().hookBefore(origin, hooker); } - @NonNull + @Nullable @Override final public MethodUnhooker>, Constructor> hookAfter(@NonNull Constructor origin, @NonNull AfterHooker> hooker) { return getBaseContext().hookAfter(origin, hooker); } - @NonNull + @Nullable @Override final public MethodUnhooker>, Constructor> hook(@NonNull Constructor origin, @NonNull Hooker> hooker) { return getBaseContext().hook(origin, hooker); } - @NonNull + @Nullable @Override final public MethodUnhooker>, Constructor> hookBefore(@NonNull Constructor origin, int priority, @NonNull BeforeHooker> hooker) { return getBaseContext().hookBefore(origin, priority, hooker); } - @NonNull + @Nullable @Override final public MethodUnhooker>, Constructor> hookAfter(@NonNull Constructor origin, int priority, @NonNull AfterHooker> hooker) { return getBaseContext().hookAfter(origin, priority, hooker); } - @NonNull + @Nullable @Override final public MethodUnhooker>, Constructor> hook(@NonNull Constructor origin, int priority, @NonNull Hooker> hooker) { return getBaseContext().hook(origin, priority, hooker); diff --git a/api/src/main/java/io/github/libxposed/XposedInterface.java b/api/src/main/java/io/github/libxposed/XposedInterface.java index 541afc3..6ca2e9c 100644 --- a/api/src/main/java/io/github/libxposed/XposedInterface.java +++ b/api/src/main/java/io/github/libxposed/XposedInterface.java @@ -45,19 +45,6 @@ public interface XposedInterface { */ int FRAMEWORK_PRIVILEGE_EMBEDDED = 3; - /** - * The default hook priority. - */ - int PRIORITY_DEFAULT = 50; - /** - * Execute the hook callback late. - */ - int PRIORITY_LOWEST = -10000; - /** - * Execute the hook callback early. - */ - int PRIORITY_HIGHEST = 10000; - /** * The interface Before hook callback. * @@ -319,24 +306,6 @@ public interface XposedInterface { void unhook(); } - /** - * The exception thrown when a hook fails - */ - class HookFailedException extends RuntimeException { - - public HookFailedException(String message) { - super(message); - } - - public HookFailedException(Throwable cause) { - super(cause); - } - - public HookFailedException(String message, Throwable cause) { - super(message, cause); - } - } - /** * Gets framework name. * @@ -374,7 +343,6 @@ public interface XposedInterface { * @param args the args * @return the object */ - @Nullable Object featuredMethod(String name, Object... args); /** @@ -383,9 +351,8 @@ public interface XposedInterface { * @param origin the origin * @param hooker the hooker * @return the method unhooker - * @throws HookFailedException if hook fails */ - @NonNull + @Nullable MethodUnhooker, Method> hookBefore(@NonNull Method origin, @NonNull BeforeHooker hooker); /** @@ -394,9 +361,8 @@ public interface XposedInterface { * @param origin the origin * @param hooker the hooker * @return the method unhooker - * @throws HookFailedException if hook fails */ - @NonNull + @Nullable MethodUnhooker, Method> hookAfter(@NonNull Method origin, @NonNull AfterHooker hooker); /** @@ -405,9 +371,8 @@ public interface XposedInterface { * @param origin the origin * @param hooker the hooker * @return the method unhooker - * @throws HookFailedException if hook fails */ - @NonNull + @Nullable MethodUnhooker, Method> hook(@NonNull Method origin, @NonNull Hooker hooker); /** @@ -417,9 +382,8 @@ public interface XposedInterface { * @param priority the priority * @param hooker the hooker * @return the method unhooker - * @throws HookFailedException if hook fails */ - @NonNull + @Nullable MethodUnhooker, Method> hookBefore(@NonNull Method origin, int priority, @NonNull BeforeHooker hooker); /** @@ -429,9 +393,8 @@ public interface XposedInterface { * @param priority the priority * @param hooker the hooker * @return the method unhooker - * @throws HookFailedException if hook fails */ - @NonNull + @Nullable MethodUnhooker, Method> hookAfter(@NonNull Method origin, int priority, @NonNull AfterHooker hooker); /** @@ -441,9 +404,8 @@ public interface XposedInterface { * @param priority the priority * @param hooker the hooker * @return the method unhooker - * @throws HookFailedException if hook fails */ - @NonNull + @Nullable MethodUnhooker, Method> hook(@NonNull Method origin, int priority, @NonNull Hooker hooker); /** @@ -453,9 +415,8 @@ public interface XposedInterface { * @param origin the origin * @param hooker the hooker * @return the method unhooker - * @throws HookFailedException if hook fails */ - @NonNull + @Nullable MethodUnhooker>, Constructor> hookBefore(@NonNull Constructor origin, @NonNull BeforeHooker> hooker); /** @@ -465,9 +426,8 @@ public interface XposedInterface { * @param origin the origin * @param hooker the hooker * @return the method unhooker - * @throws HookFailedException if hook fails */ - @NonNull + @Nullable MethodUnhooker>, Constructor> hookAfter(@NonNull Constructor origin, @NonNull AfterHooker> hooker); /** @@ -477,9 +437,8 @@ public interface XposedInterface { * @param origin the origin * @param hooker the hooker * @return the method unhooker - * @throws HookFailedException if hook fails */ - @NonNull + @Nullable MethodUnhooker>, Constructor> hook(@NonNull Constructor origin, @NonNull Hooker> hooker); /** @@ -490,9 +449,8 @@ public interface XposedInterface { * @param priority the priority * @param hooker the hooker * @return the method unhooker - * @throws HookFailedException if hook fails */ - @NonNull + @Nullable MethodUnhooker>, Constructor> hookBefore(@NonNull Constructor origin, int priority, @NonNull BeforeHooker> hooker); /** @@ -503,9 +461,8 @@ public interface XposedInterface { * @param priority the priority * @param hooker the hooker * @return the method unhooker - * @throws HookFailedException if hook fails */ - @NonNull + @Nullable MethodUnhooker>, Constructor> hookAfter(@NonNull Constructor origin, int priority, @NonNull AfterHooker> hooker); /** @@ -516,9 +473,8 @@ public interface XposedInterface { * @param priority the priority * @param hooker the hooker * @return the method unhooker - * @throws HookFailedException if hook fails */ - @NonNull + @Nullable MethodUnhooker>, Constructor> hook(@NonNull Constructor origin, int priority, @NonNull Hooker> hooker); /**