Skip to content

Commit

Permalink
fix: proxy activity crash on NT 4288
Browse files Browse the repository at this point in the history
  • Loading branch information
cinit committed Jul 14, 2023
1 parent 07ad7b3 commit 58442b9
Showing 1 changed file with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,24 @@ public static ActivityInfo makeProxyActivityInfo(@NonNull String className, long
try {
Context ctx = HostInfo.getApplication();
Class<?> cl = Class.forName(className);
try {
// TODO: 2022-02-11 cast flags from long to int loses information
ActivityInfo proto = ctx.getPackageManager().getActivityInfo(new ComponentName(
ctx.getPackageName(), "com.tencent.mobileqq.activity.QQSettingSettingActivity"), (int) flags);
// init style here, comment it out if it crashes on Android >= 10
proto.theme = R.style.Theme_MaiTungTMDesign_DayNight;
return initCommon(proto, className);
} catch (PackageManager.NameNotFoundException e) {
throw new IllegalStateException(
"QQSettingSettingActivity not found, are we in the host?", e);
String[] candidates = new String[]{
"com.tencent.mobileqq.activity.QQSettingSettingActivity",
"com.tencent.mobileqq.activity.QPublicFragmentActivity"
};
PackageManager.NameNotFoundException last = null;
for (String activityName : candidates) {
try {
// TODO: 2022-02-11 cast flags from long to int loses information
ActivityInfo proto = ctx.getPackageManager().getActivityInfo(new ComponentName(
ctx.getPackageName(), activityName), (int) flags);
// init style here, comment it out if it crashes on Android >= 10
proto.theme = R.style.Theme_MaiTungTMDesign_DayNight;
return initCommon(proto, className);
} catch (PackageManager.NameNotFoundException e) {
last = e;
}
}
throw new IllegalStateException("QQSettingSettingActivity not found, are we in the host?", last);
} catch (ClassNotFoundException e) {
return null;
}
Expand Down

0 comments on commit 58442b9

Please sign in to comment.