From a026708a357d8280cf2c89a71237d6755b1d7ab4 Mon Sep 17 00:00:00 2001 From: LoveSy Date: Tue, 24 Jan 2023 18:11:28 +0800 Subject: [PATCH] Global invoke origin --- .../libxposed/api/XposedContextWrapper.java | 13 +++++++ .../github/libxposed/api/XposedInterface.java | 37 +++++++++++++------ settings.gradle.kts | 2 +- 3 files changed, 39 insertions(+), 13 deletions(-) diff --git a/api/src/main/java/io/github/libxposed/api/XposedContextWrapper.java b/api/src/main/java/io/github/libxposed/api/XposedContextWrapper.java index aa6b302..a1e083f 100644 --- a/api/src/main/java/io/github/libxposed/api/XposedContextWrapper.java +++ b/api/src/main/java/io/github/libxposed/api/XposedContextWrapper.java @@ -8,6 +8,7 @@ import androidx.annotation.Nullable; import java.io.IOException; import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.nio.ByteBuffer; @@ -213,6 +214,18 @@ public class XposedContextWrapper extends ContextWrapper implements XposedInterf return getBaseContext().deoptimize(constructor); } + @Nullable + @Override + public Object invokeOrigin(@NonNull Method method, @Nullable Object thisObject, Object[] args) throws InvocationTargetException, IllegalAccessException { + return getBaseContext().invokeOrigin(method, thisObject, args); + } + + @Nullable + @Override + public T newInstanceOrigin(@NonNull Constructor constructor, Object[] args) throws InvocationTargetException, IllegalAccessException { + return getBaseContext().newInstanceOrigin(constructor, args); + } + /** * {@inheritDoc} */ 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 2718f16..35d0d85 100644 --- a/api/src/main/java/io/github/libxposed/api/XposedInterface.java +++ b/api/src/main/java/io/github/libxposed/api/XposedInterface.java @@ -223,18 +223,6 @@ public interface XposedInterface { */ void setThrowable(@Nullable Throwable throwable); - /** - * Invoke origin object. - * - * @param thisObject the this object - * @param args the args - * @return the object - * @throws InvocationTargetException the invocation target exception - * @throws IllegalAccessException the illegal access exception - */ - @Nullable - Object invokeOrigin(@Nullable Object thisObject, Object[] args) throws InvocationTargetException, IllegalAccessException; - /** * Invoke origin object. * @@ -538,6 +526,31 @@ public interface XposedInterface { */ boolean deoptimize(@NonNull Constructor constructor); + /** + * Invoke origin object. + * + * @param method the method + * @param thisObject the this object + * @param args the args + * @return the object + * @throws InvocationTargetException the invocation target exception + * @throws IllegalAccessException the illegal access exception + */ + @Nullable + Object invokeOrigin(@NonNull Method method, @Nullable Object thisObject, Object[] args) throws InvocationTargetException, IllegalAccessException; + + /** + * new origin object. + * + * @param constructor the constructor + * @param args the args + * @return the object + * @throws InvocationTargetException the invocation target exception + * @throws IllegalAccessException the illegal access exception + */ + @Nullable + T newInstanceOrigin(@NonNull Constructor constructor, Object[] args) throws InvocationTargetException, IllegalAccessException; + /** * Log. * diff --git a/settings.gradle.kts b/settings.gradle.kts index 261d48f..11f3b19 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -17,6 +17,6 @@ dependencyResolutionManagement { } } -rootProject.name = "libxposed" +rootProject.name = "api" include(":api")