Skip to content

Commit

Permalink
fix: setting entry on QQ 9.1.20
Browse files Browse the repository at this point in the history
  • Loading branch information
cinit committed Nov 24, 2024
1 parent 481d4c3 commit 2787164
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions app/src/main/java/cc/ioctl/hook/SettingEntryHook.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@
import cc.ioctl.util.HostInfo;
import cc.ioctl.util.LayoutHelper;
import cc.ioctl.util.Reflex;
import io.github.qauxv.util.xpcompat.XC_MethodHook;
import io.github.qauxv.util.xpcompat.XposedBridge;
import io.github.qauxv.util.xpcompat.XposedHelpers;
import io.github.qauxv.BuildConfig;
import io.github.qauxv.R;
import io.github.qauxv.activity.SettingsUiFragmentHostActivity;
Expand All @@ -55,6 +52,9 @@
import io.github.qauxv.util.Initiator;
import io.github.qauxv.util.LicenseStatus;
import io.github.qauxv.util.Log;
import io.github.qauxv.util.xpcompat.XC_MethodHook;
import io.github.qauxv.util.xpcompat.XposedBridge;
import io.github.qauxv.util.xpcompat.XposedHelpers;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
Expand All @@ -76,6 +76,8 @@ public class SettingEntryHook extends BasePersistBackgroundHook {
private static final int BG_TYPE_MIDDLE = 2;
private static final int BG_TYPE_LAST = 3;

// am start "intent:#Intent;component=com.tencent.mobileqq/com.tencent.mobileqq.activity.QPublicFragmentActivity;S.public_fragment_class=com.tencent.mobileqq.setting.main.MainSettingFragment;end"

private SettingEntryHook() {
}

Expand All @@ -101,7 +103,13 @@ private void injectSettingEntryForMainSettingConfigProvider() throws ReflectiveO
Class<?> kMainSettingFragment = Initiator.load("com.tencent.mobileqq.setting.main.MainSettingFragment");
if (kMainSettingFragment != null) {
Class<?> kMainSettingConfigProvider = Initiator.loadClass("com.tencent.mobileqq.setting.main.MainSettingConfigProvider");
Method getItemProcessList = Reflex.findSingleMethod(kMainSettingConfigProvider, List.class, false, Context.class);
// 9.1.20+, NewSettingConfigProvider, A/B test on 9.1.20
Class<?> kNewSettingConfigProvider = Initiator.load("com.tencent.mobileqq.setting.main.NewSettingConfigProvider");
Method getItemProcessListOld = Reflex.findSingleMethod(kMainSettingConfigProvider, List.class, false, Context.class);
Method getItemProcessListNew = null;
if (kNewSettingConfigProvider != null) {
getItemProcessListNew = Reflex.findSingleMethod(kNewSettingConfigProvider, List.class, false, Context.class);
}
Class<?> kAbstractItemProcessor = Initiator.loadClass("com.tencent.mobileqq.setting.main.processor.AccountSecurityItemProcessor").getSuperclass();
// 8.9.70 ~ 9.0.0
Class<?> kSimpleItemProcessor = Initiator.loadClass("com.tencent.mobileqq.setting.processor.g");
Expand All @@ -128,7 +136,7 @@ private void injectSettingEntryForMainSettingConfigProvider() throws ReflectiveO
setOnClickListener = candidates.get(0);
}
Constructor<?> ctorSimpleItemProcessor = kSimpleItemProcessor.getDeclaredConstructor(Context.class, int.class, CharSequence.class, int.class);
HookUtils.hookAfterAlways(this, getItemProcessList, 50, param -> {
XC_MethodHook callback = HookUtils.afterAlways(this, 50, param -> {
List<Object> result = (List<Object>) param.getResult();
Context ctx = (Context) param.args[0];
Class<?> kItemProcessorGroup = result.get(0).getClass();
Expand All @@ -152,8 +160,14 @@ private void injectSettingEntryForMainSettingConfigProvider() throws ReflectiveO
ArrayList<Object> list = new ArrayList<>(1);
list.add(entryItem);
Object group = ctor.newInstance(list, "", "");
result.add(1, group);
boolean isNew = param.thisObject.getClass().getName().contains("NewSettingConfigProvider");
int indexToInsert = isNew ? 2 : 1;
result.add(indexToInsert, group);
});
XposedBridge.hookMethod(getItemProcessListOld, callback);
if (getItemProcessListNew != null) {
XposedBridge.hookMethod(getItemProcessListNew, callback);
}
}
}

Expand Down

0 comments on commit 2787164

Please sign in to comment.