diff --git a/core/src/main/java/de/robv/android/xposed/XposedBridge.java b/core/src/main/java/de/robv/android/xposed/XposedBridge.java index 39e6901..b87edb0 100644 --- a/core/src/main/java/de/robv/android/xposed/XposedBridge.java +++ b/core/src/main/java/de/robv/android/xposed/XposedBridge.java @@ -301,10 +301,10 @@ public static boolean invokeConstructor(T instance, Constructor } /** - * Simplified version of {@link java.util.concurrent.CopyOnWriteArrayList} + * Simplified version of {@link java.util.concurrent.CopyOnWriteArrayList} with sorting * @hide */ - public static final class CopyOnWriteArrayList { + public static final class CopyOnWriteSortedList { private volatile Object[] elements = EMPTY_ARRAY; public Object[] getSnapshot() { @@ -320,6 +320,8 @@ public synchronized void add(E e) { Object[] newElements = new Object[snapshot.length + 1]; System.arraycopy(snapshot, 0, newElements, 0, snapshot.length); newElements[snapshot.length] = e; + if (newElements.length >= 2) + Arrays.sort(newElements); elements = newElements; } @@ -348,7 +350,7 @@ private static int indexOf(Object[] arr, Object o) { // Aliucord changed: public, so that it can be passed as lsplant context object public static class HookInfo { Member backup; - final CopyOnWriteArrayList callbacks = new CopyOnWriteArrayList<>(); + final CopyOnWriteSortedList callbacks = new CopyOnWriteSortedList<>(); private final Member method; private final boolean isStatic; private final Class returnType;