Skip to content

Commit

Permalink
fix: NtStartupDirector not found on NT 4288
Browse files Browse the repository at this point in the history
  • Loading branch information
cinit committed Jul 15, 2023
1 parent e300b51 commit 347675d
Showing 1 changed file with 43 additions and 3 deletions.
46 changes: 43 additions & 3 deletions app/src/main/java/io/github/qauxv/util/Initiator.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.tencent.mobileqq.app.QQAppInterface;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.Arrays;
import java.util.HashMap;
import mqq.app.AppRuntime;
Expand Down Expand Up @@ -217,12 +219,50 @@ public static Class<?> _StartupDirector() {
return findClassWithSynthetics("com/tencent/mobileqq/startup/director/StartupDirector", 1);
}

private static Class<?> skNtStartupDirector = null;
private static boolean sNotHaveNtStartupDirector = false;

public static Class<?> _NtStartupDirector() {
Class<?> klass = Initiator.load("com.tencent.mobileqq.startup.director.a");
if (klass == _StartupDirector()) {
if (skNtStartupDirector != null) {
return skNtStartupDirector;
}
if (sNotHaveNtStartupDirector) {
return null;
}
return klass;
String[] candidates = new String[]{
"com.tencent.mobileqq.startup.director.a",
"com.tencent.mobileqq.g3.a.a"
};
for (String candidate : candidates) {
Class<?> klass = load(candidate);
if (isNtStartupDirector(klass)) {
skNtStartupDirector = klass;
return klass;
}
}
sNotHaveNtStartupDirector = true;
return null;
}

private static boolean isNtStartupDirector(Class<?> klass) {
if (klass == null || klass == _StartupDirector()) {
return false;
}
if (!android.os.Handler.Callback.class.isAssignableFrom(klass)) {
return false;
}
// have a static instance field
boolean hasStaticInstance = false;
for (Field field : klass.getDeclaredFields()) {
if (Modifier.isStatic(field.getModifiers()) && field.getType() == klass) {
hasStaticInstance = true;
break;
}
}
if (!hasStaticInstance) {
return false;
}
return true;
}

public static Class<?> _BaseQQMessageFacade() {
Expand Down

0 comments on commit 347675d

Please sign in to comment.