[core] Support interface default method (#420)
This commit is contained in:
parent
0facfb958a
commit
833eef49ec
|
|
@ -169,9 +169,12 @@ public final class XposedBridge {
|
|||
public static XC_MethodHook.Unhook hookMethod(Member hookMethod, XC_MethodHook callback) {
|
||||
if (!(hookMethod instanceof Executable)) {
|
||||
throw new IllegalArgumentException("Only methods and constructors can be hooked: " + hookMethod.toString());
|
||||
} else if (hookMethod.getDeclaringClass().isInterface()) {
|
||||
}
|
||||
// No check interface because there may be default methods
|
||||
/*else if (hookMethod.getDeclaringClass().isInterface()) {
|
||||
throw new IllegalArgumentException("Cannot hook interfaces: " + hookMethod.toString());
|
||||
} else if (Modifier.isAbstract(hookMethod.getModifiers())) {
|
||||
}*/
|
||||
else if (Modifier.isAbstract(hookMethod.getModifiers())) {
|
||||
throw new IllegalArgumentException("Cannot hook abstract methods: " + hookMethod.toString());
|
||||
}
|
||||
|
||||
|
|
@ -196,7 +199,7 @@ public final class XposedBridge {
|
|||
if (newMethod) {
|
||||
AdditionalHookInfo additionalInfo = new AdditionalHookInfo(callbacks);
|
||||
if (!YahfaHooker.shouldDelayHook(targetMethod)) {
|
||||
DynamicBridge.hookMethod(targetMethod, (AdditionalHookInfo) additionalInfo);
|
||||
YahfaHooker.hookMethod(targetMethod, additionalInfo);
|
||||
} else {
|
||||
PendingHooks.recordPendingMethod((Method)hookMethod, additionalInfo);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
|
||||
import de.robv.android.xposed.LspHooker;
|
||||
import de.robv.android.xposed.XposedBridge;
|
||||
|
||||
import org.lsposed.lspd.util.Logger;
|
||||
|
||||
public final class DynamicBridge {
|
||||
|
|
@ -36,9 +37,6 @@ public final class DynamicBridge {
|
|||
|
||||
public static synchronized void hookMethod(Executable hookMethod, XposedBridge.AdditionalHookInfo additionalHookInfo) {
|
||||
Logger.d("hooking " + hookMethod);
|
||||
if (!checkMember(hookMethod)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (hookedInfo.containsKey(hookMethod)) {
|
||||
Logger.w("already hook method:" + hookMethod.toString());
|
||||
|
|
@ -55,17 +53,6 @@ public final class DynamicBridge {
|
|||
}
|
||||
}
|
||||
|
||||
private static boolean checkMember(Executable member) {
|
||||
if (member.getDeclaringClass().isInterface()) {
|
||||
Logger.e("Cannot hook interfaces: " + member.toString());
|
||||
return false;
|
||||
} else if (Modifier.isAbstract(member.getModifiers())) {
|
||||
Logger.e("Cannot hook abstract methods: " + member.toString());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static Object invokeOriginalMethod(Member method, Object thisObject, Object[] args)
|
||||
throws InvocationTargetException, IllegalAccessException {
|
||||
LspHooker hooker = hookedInfo.get(method);
|
||||
|
|
|
|||
|
|
@ -63,11 +63,6 @@ public class HookerDexMaker {
|
|||
|
||||
public void start(Executable member, XposedBridge.AdditionalHookInfo hookInfo,
|
||||
ClassLoader appClassLoader) throws Exception {
|
||||
if (member.getDeclaringClass().isInterface()) {
|
||||
throw new IllegalArgumentException("Cannot hook interfaces: " + member.toString());
|
||||
} else if (Modifier.isAbstract(member.getModifiers())) {
|
||||
throw new IllegalArgumentException("Cannot hook abstract methods: " + member.toString());
|
||||
}
|
||||
if (member instanceof Method) {
|
||||
Method method = (Method) member;
|
||||
mReturnType = method.getReturnType();
|
||||
|
|
|
|||
Loading…
Reference in New Issue