Expand emulator compatibility coverage
This commit is contained in:
@@ -2,6 +2,7 @@ package se.ajpanton.statusbartweak.runtime.hooks;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@@ -34,6 +35,9 @@ public final class XposedHookSupport {
|
||||
if (!methodName.equals(method.getName())) {
|
||||
continue;
|
||||
}
|
||||
if (Modifier.isAbstract(method.getModifiers())) {
|
||||
continue;
|
||||
}
|
||||
method.setAccessible(true);
|
||||
handles.add(framework.hook(method).intercept(hooker));
|
||||
}
|
||||
@@ -59,6 +63,9 @@ public final class XposedHookSupport {
|
||||
if (!methodName.equals(method.getName())) {
|
||||
continue;
|
||||
}
|
||||
if (Modifier.isAbstract(method.getModifiers())) {
|
||||
continue;
|
||||
}
|
||||
method.setAccessible(true);
|
||||
handles.add(framework.hook(method).intercept(hooker));
|
||||
}
|
||||
@@ -83,4 +90,20 @@ public final class XposedHookSupport {
|
||||
}
|
||||
return handles;
|
||||
}
|
||||
|
||||
public static List<XposedInterface.HookHandle> hookAllConstructorsIfExists(
|
||||
XposedInterface framework,
|
||||
Class<?> type,
|
||||
XposedInterface.Hooker hooker
|
||||
) {
|
||||
Objects.requireNonNull(framework, "framework");
|
||||
Objects.requireNonNull(type, "type");
|
||||
Objects.requireNonNull(hooker, "hooker");
|
||||
List<XposedInterface.HookHandle> handles = new ArrayList<>();
|
||||
for (Constructor<?> constructor : type.getDeclaredConstructors()) {
|
||||
constructor.setAccessible(true);
|
||||
handles.add(framework.hook(constructor).intercept(hooker));
|
||||
}
|
||||
return handles;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ final class DarkIconDispatcherGuard {
|
||||
}
|
||||
|
||||
void install(Class<?> darkIconDispatcherClass) {
|
||||
XposedHookSupport.hookAllConstructors(
|
||||
XposedHookSupport.hookAllConstructorsIfExists(
|
||||
runtimeContext.getFramework(),
|
||||
darkIconDispatcherClass,
|
||||
chain -> {
|
||||
|
||||
Reference in New Issue
Block a user