No more default method

This commit is contained in:
LoveSy 2023-01-02 17:44:06 +08:00 committed by LoveSy
parent 53d75bd10e
commit 82dbc52d7b
6 changed files with 94 additions and 16 deletions

View File

@ -60,6 +60,21 @@ public class XposedContextWrapper extends ContextWrapper implements XposedInterf
return getBaseContext().hook(origin, hooker);
}
@Override
public MethodUnhooker<BeforeMethodHooker<Method>, Method> hookBefore(@NonNull Method origin, int priority, @NonNull BeforeMethodHooker<Method> hooker) {
return getBaseContext().hookBefore(origin, priority, hooker);
}
@Override
public MethodUnhooker<AfterMethodHooker<Method>, Method> hookAfter(@NonNull Method origin, int priority, @NonNull AfterMethodHooker<Method> hooker) {
return getBaseContext().hookAfter(origin, priority, hooker);
}
@Override
public MethodUnhooker<MethodHooker<Method>, Method> hook(@NonNull Method origin, int priority, @NonNull MethodHooker<Method> hooker) {
return getBaseContext().hook(origin, priority, hooker);
}
@Override
public <T> MethodUnhooker<BeforeMethodHooker<Constructor<T>>, Constructor<T>> hookBefore(@NonNull Constructor<T> origin, @NonNull BeforeMethodHooker<Constructor<T>> hooker) {
return getBaseContext().hookBefore(origin, hooker);
@ -75,6 +90,21 @@ public class XposedContextWrapper extends ContextWrapper implements XposedInterf
return getBaseContext().hook(origin, hooker);
}
@Override
public <T> MethodUnhooker<BeforeMethodHooker<Constructor<T>>, Constructor<T>> hookBefore(@NonNull Constructor<T> origin, int priority, @NonNull BeforeMethodHooker<Constructor<T>> hooker) {
return getBaseContext().hookBefore(origin, priority, hooker);
}
@Override
public <T> MethodUnhooker<AfterMethodHooker<Constructor<T>>, Constructor<T>> hookAfter(@NonNull Constructor<T> origin, int priority, @NonNull AfterMethodHooker<Constructor<T>> hooker) {
return getBaseContext().hookAfter(origin, priority, hooker);
}
@Override
public <T> MethodUnhooker<MethodHooker<Constructor<T>>, Constructor<T>> hook(@NonNull Constructor<T> origin, int priority, @NonNull MethodHooker<Constructor<T>> hooker) {
return getBaseContext().hook(origin, priority, hooker);
}
@Override
public boolean deoptimize(@Nullable Method method) {
return getBaseContext().deoptimize(method);

View File

@ -57,19 +57,11 @@ public interface XposedInterface {
<U> U getExtra(@NonNull String key);
}
interface PriorityMethodHooker {
int PRIORITY_DEFAULT = 50;
default int getPriority() {
return PRIORITY_DEFAULT;
}
}
interface BeforeMethodHooker<T> extends PriorityMethodHooker {
interface BeforeMethodHooker<T> {
void before(@NonNull BeforeHookCallback<T> callback);
}
interface AfterMethodHooker<T> extends PriorityMethodHooker {
interface AfterMethodHooker<T> {
void after(@NonNull AfterHookCallback<T> callback);
}
@ -100,12 +92,24 @@ public interface XposedInterface {
MethodUnhooker<MethodHooker<Method>, Method> hook(@NonNull Method origin, @NonNull MethodHooker<Method> hooker);
MethodUnhooker<BeforeMethodHooker<Method>, Method> hookBefore(@NonNull Method origin, int priority, @NonNull BeforeMethodHooker<Method> hooker);
MethodUnhooker<AfterMethodHooker<Method>, Method> hookAfter(@NonNull Method origin, int priority, @NonNull AfterMethodHooker<Method> hooker);
MethodUnhooker<MethodHooker<Method>, Method> hook(@NonNull Method origin, int priority, @NonNull MethodHooker<Method> hooker);
<T> MethodUnhooker<BeforeMethodHooker<Constructor<T>>, Constructor<T>> hookBefore(@NonNull Constructor<T> origin, @NonNull BeforeMethodHooker<Constructor<T>> hooker);
<T> MethodUnhooker<AfterMethodHooker<Constructor<T>>, Constructor<T>> hookAfter(@NonNull Constructor<T> origin, @NonNull AfterMethodHooker<Constructor<T>> hooker);
<T> MethodUnhooker<MethodHooker<Constructor<T>>, Constructor<T>> hook(@NonNull Constructor<T> origin, @NonNull MethodHooker<Constructor<T>> hooker);
<T> MethodUnhooker<BeforeMethodHooker<Constructor<T>>, Constructor<T>> hookBefore(@NonNull Constructor<T> origin, int priority, @NonNull BeforeMethodHooker<Constructor<T>> hooker);
<T> MethodUnhooker<AfterMethodHooker<Constructor<T>>, Constructor<T>> hookAfter(@NonNull Constructor<T> origin, int priority, @NonNull AfterMethodHooker<Constructor<T>> hooker);
<T> MethodUnhooker<MethodHooker<Constructor<T>>, Constructor<T>> hook(@NonNull Constructor<T> origin, int priority, @NonNull MethodHooker<Constructor<T>> hooker);
boolean deoptimize(@Nullable Method method);
<T> boolean deoptimize(@Nullable Constructor<T> constructor);

View File

@ -6,4 +6,14 @@ public abstract class XposedModule extends XposedContextWrapper implements Xpose
public XposedModule(XposedContext base, @SuppressWarnings("unused") @NonNull ModuleLoadedParam param) {
super(base);
}
@Override
public void onPackageLoaded(@NonNull PackageLoadedParam param) {
}
@Override
public void onResourceLoaded(@NonNull ResourcesLoadedParam param) {
}
}

View File

@ -51,9 +51,7 @@ public interface XposedModuleInterface {
Bundle getExtras();
}
default void onPackageLoaded(@NonNull PackageLoadedParam param) {
}
void onPackageLoaded(@NonNull PackageLoadedParam param);
default void onResourceLoaded(@NonNull ResourcesLoadedParam param) {
}
void onResourceLoaded(@NonNull ResourcesLoadedParam param);
}

View File

@ -3,7 +3,7 @@ package io.github.libxposed;
import android.content.res.Resources;
import android.content.res.TypedArray;
public class XposedTypedArray extends TypedArray {
public abstract class XposedTypedArray extends TypedArray {
public XposedTypedArray(Resources resources) {
super(resources);
}

View File

@ -150,7 +150,7 @@ public class LSPosedContext extends XposedContext {
Log.e(TAG, " This class doesn't implement any sub-interface of XposedModule, skipping it");
}
try {
if (moduleClass.getMethod("onResourceLoaded", XposedModuleInterface.ResourcesLoadedParam.class).getDeclaringClass() != XposedModuleInterface.class) {
if (moduleClass.getMethod("onResourceLoaded", XposedModuleInterface.ResourcesLoadedParam.class).getDeclaringClass() != XposedModule.class) {
XposedInit.hookResources();
}
var moduleEntry = moduleClass.getConstructor(XposedContext.class, XposedModuleInterface.ModuleLoadedParam.class);
@ -758,6 +758,24 @@ public class LSPosedContext extends XposedContext {
return null;
}
// TODO
@Override
public MethodUnhooker<BeforeMethodHooker<Method>, Method> hookBefore(@NonNull Method origin, int priority, @NonNull BeforeMethodHooker<Method> hooker) {
return null;
}
// TODO
@Override
public MethodUnhooker<AfterMethodHooker<Method>, Method> hookAfter(@NonNull Method origin, int priority, @NonNull AfterMethodHooker<Method> hooker) {
return null;
}
// TODO
@Override
public MethodUnhooker<MethodHooker<Method>, Method> hook(@NonNull Method origin, int priority, @NonNull MethodHooker<Method> hooker) {
return null;
}
// TODO
@Override
public <T> MethodUnhooker<BeforeMethodHooker<Constructor<T>>, Constructor<T>> hookBefore(@NonNull Constructor<T> origin, @NonNull BeforeMethodHooker<Constructor<T>> hooker) {
@ -776,6 +794,24 @@ public class LSPosedContext extends XposedContext {
return null;
}
// TODO
@Override
public <T> MethodUnhooker<BeforeMethodHooker<Constructor<T>>, Constructor<T>> hookBefore(@NonNull Constructor<T> origin, int priority, @NonNull BeforeMethodHooker<Constructor<T>> hooker) {
return null;
}
// TODO
@Override
public <T> MethodUnhooker<AfterMethodHooker<Constructor<T>>, Constructor<T>> hookAfter(@NonNull Constructor<T> origin, int priority, @NonNull AfterMethodHooker<Constructor<T>> hooker) {
return null;
}
// TODO
@Override
public <T> MethodUnhooker<MethodHooker<Constructor<T>>, Constructor<T>> hook(@NonNull Constructor<T> origin, int priority, @NonNull MethodHooker<Constructor<T>> hooker) {
return null;
}
// TODO
@Override
public boolean deoptimize(@Nullable Method method) {