Skip to content

Commit

Permalink
fix: function about prevent upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
alphime authored and cinit committed Oct 12, 2023
1 parent 9394261 commit 4da6dda
Show file tree
Hide file tree
Showing 6 changed files with 137 additions and 44 deletions.
3 changes: 1 addition & 2 deletions app/src/main/java/cc/ioctl/hook/misc/AntiUpdate.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ import io.github.qauxv.hook.CommonSwitchFunctionHook
import io.github.qauxv.util.Initiator
import java.lang.reflect.Method

@FunctionHookEntry
@UiItemAgentEntry
// instead HookUpgrade
object AntiUpdate : CommonSwitchFunctionHook() {
override val name: String = "屏蔽更新"

Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/cc/ioctl/hook/qwallet/QWalletNoAD.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ import xyz.nextalone.util.getIdentifier
import xyz.nextalone.util.hookAfter
import xyz.nextalone.util.throwOrTrue

@FunctionHookEntry
@UiItemAgentEntry
//@FunctionHookEntry
//@UiItemAgentEntry
object QWalletNoAD : PluginDelayableHook("ketal_qwallet_noad") {
override val preference = uiSwitchPreference {
title = "隐藏QQ钱包超值精选"
Expand Down
61 changes: 33 additions & 28 deletions app/src/main/java/com/alphi/qhmk/module/DisableX5.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ private DisableX5() {
@Override
protected boolean initOnce() throws Exception {
// NT
Class<?> kQbSdk = Initiator.loadClass("com/tencent/smtt/sdk/QbSdk");
Class<?> kQbSdk = Initiator.load("com/tencent/smtt/sdk/QbSdk");
if (kQbSdk != null) {
Method method = kQbSdk.getDeclaredMethod("getIsSysWebViewForcedByOuter");
HookUtils.hookBeforeIfEnabled(this, method, param -> {
Expand All @@ -36,37 +36,42 @@ protected boolean initOnce() throws Exception {
return true;
}
// older
Class<?> tbsClass = Initiator.loadClass("com.tencent.smtt.sdk.WebView");
Class<?> TbsClassConfig = null;
for (Field field : tbsClass.getDeclaredFields()) {
Class<?> type = field.getType();
if (type.getName().contains("com.tencent.smtt.utils.")) {
TbsClassConfig = type;
Class<?> tbsClass = Initiator.load("com.tencent.smtt.sdk.WebView");
Class<?> tbsClassConfig = null;
if (tbsClass != null) {
for (Field field : tbsClass.getDeclaredFields()) {
Class<?> type = field.getType();
Package tPackage = type.getPackage();
if (tPackage != null && tPackage.getName().equals("com.tencent.smtt.utils")) {
tbsClassConfig = type;
}
}
}
if (TbsClassConfig == null) {
throw new IllegalStateException("X5Settings init fail!!!");
}
Method method = ArraysKt.single(TbsClassConfig.getDeclaredMethods(), m -> m.getReturnType() == void.class);
HookUtils.hookAfterIfEnabled(this, method, param -> {
boolean result = false;
Log.d("hook:" + param.thisObject.getClass());
for (Field field : param.thisObject.getClass().getFields()) {
if (field.getType() == boolean.class) {
try {
field.set(param.thisObject, true);
result = true;
} catch (IllegalAccessException e) {
traceError(e);
if (tbsClassConfig != null) {
Method method = ArraysKt.single(tbsClassConfig.getDeclaredMethods(), m -> m.getReturnType() == void.class);
HookUtils.hookAfterIfEnabled(this, method, param -> {
boolean result = false;
Log.d("hook:" + param.thisObject.getClass());
for (Field field : param.thisObject.getClass().getFields()) {
if (field.getType() == boolean.class) {
try {
field.set(param.thisObject, true);
result = true;
} catch (IllegalAccessException e) {
traceError(e);
}
}
}
}
if (result) {
Log.d("ForceUseSystemWebView success!");
} else {
Log.e("ForceUseSystemWebView fail!!!");
}
});
if (result) {
Log.d("old:ForceUseSystemWebView success!");
} else {
Log.e("old:ForceUseSystemWebView fail!!!");
}
});
}
if (tbsClassConfig == null && kQbSdk == null) {
throw new IllegalStateException("X5Settings init fail!!! cause by not found class...");
}
return true;
}

Expand Down
30 changes: 18 additions & 12 deletions app/src/main/java/com/alphi/qhmk/module/HookQWallet.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import androidx.annotation.Nullable;
import cc.ioctl.util.HookUtils;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XC_MethodReplacement;
import de.robv.android.xposed.XposedBridge;
import io.github.qauxv.base.annotation.FunctionHookEntry;
import io.github.qauxv.base.annotation.UiItemAgentEntry;
Expand All @@ -32,12 +31,15 @@ protected boolean initOnce() throws Exception {
// NT
Class<?> kQWalletHomeFragment = Initiator.load("com/tencent/mobileqq/qwallet/home/QWalletHomeFragment");
if (kQWalletHomeFragment != null) {
Class<?> kQWalletHomePreviewController = Initiator.loadClass("com/tencent/mobileqq/qwallet/home/QWalletHomePreviewController");
// public final QWalletHomePreviewController.?(QWallBaseFragment|QWalletBaseFragment)Z
Method method1 = ArraysKt.single(kQWalletHomePreviewController.getDeclaredMethods(),
it -> it.getReturnType() == boolean.class && it.getParameterTypes().length == 1 &&
it.getParameterTypes()[0].getSimpleName().endsWith("BaseFragment"));
HookUtils.hookBeforeIfEnabled(this, method1, param -> param.setResult(true));
Class<?> kQWalletHomePreviewController = Initiator.load("com/tencent/mobileqq/qwallet/home/QWalletHomePreviewController");
if (kQWalletHomePreviewController != null) {
// 预防广告视图显示导致的黑屏
// public final QWalletHomePreviewController.?(QWallBaseFragment|QWalletBaseFragment)Z
Method methodIsShowAdView = ArraysKt.single(kQWalletHomePreviewController.getDeclaredMethods(),
it -> it.getReturnType() == boolean.class && it.getParameterTypes().length == 1 &&
it.getParameterTypes()[0].getSimpleName().endsWith("BaseFragment"));
HookUtils.hookBeforeIfEnabled(this, methodIsShowAdView, param -> param.setResult(true));
}
Method onViewCreated = kQWalletHomeFragment.getDeclaredMethod("onViewCreated", View.class, Bundle.class);
HookUtils.hookBeforeIfEnabled(this, onViewCreated, param -> {
// 加载广告及视图初始化
Expand All @@ -48,9 +50,13 @@ protected boolean initOnce() throws Exception {
Class<?> aClass = Initiator.load("Lcom/tencent/mobileqq/qwallet/config/impl/QWalletConfigServiceImpl;");
if (aClass != null) {
for (Method method : aClass.getDeclaredMethods()) {
XposedBridge.hookMethod(method, new XC_MethodReplacement() {
HookUtils.hookBeforeIfEnabled(this, method, new HookUtils.BeforeHookedMethod() {
@Override
protected Object replaceHookedMethod(XC_MethodHook.MethodHookParam param) {
public void beforeHookedMethod(XC_MethodHook.MethodHookParam param) {
param.setResult(resultObj());
}

private Object resultObj() {
if (method.getReturnType() == boolean.class) {
return false;
}
Expand All @@ -76,13 +82,13 @@ protected Object replaceHookedMethod(XC_MethodHook.MethodHookParam param) {
@NonNull
@Override
public String getName() {
return "去除QQ钱包广告";
return "隐藏QQ钱包超值精选";
}

@Nullable
@Override
public CharSequence getDescription() {
return "省流量方案需重启 致敬QHMK";
return "致敬 QHMK";
}

@Override
Expand All @@ -93,7 +99,7 @@ public boolean isApplicationRestartRequired() {
@NonNull
@Override
public String[] getUiItemLocation() {
return FunctionEntryRouter.Locations.Simplify.UI_MISC;
return FunctionEntryRouter.Locations.Simplify.SLIDING_UI;
}

}
71 changes: 71 additions & 0 deletions app/src/main/java/com/alphi/qhmk/module/HookUpgrade.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package com.alphi.qhmk.module;


import androidx.annotation.NonNull;
import cc.ioctl.util.HookUtils;
import io.github.qauxv.base.annotation.FunctionHookEntry;
import io.github.qauxv.base.annotation.UiItemAgentEntry;
import io.github.qauxv.dsl.FunctionEntryRouter;
import io.github.qauxv.hook.CommonSwitchFunctionHook;
import io.github.qauxv.util.Initiator;
import io.github.qauxv.util.SyncUtils;
import java.lang.reflect.Method;

/**
* IDEA 2022/1/9
*/

@UiItemAgentEntry
@FunctionHookEntry
public class HookUpgrade extends CommonSwitchFunctionHook {

private HookUpgrade() {
super(SyncUtils.PROC_MAIN | SyncUtils.PROC_TOOL);
}

@NonNull
@Override
public String[] getUiItemLocation() {
return FunctionEntryRouter.Locations.Simplify.UI_MISC;
}

@Override
protected boolean initOnce() throws Exception {
try {
Class<?> configHandlerClass = Initiator.loadClass("com.tencent.mobileqq.app.ConfigHandler");
for (Method m: configHandlerClass.getDeclaredMethods()){
Class<?>[] parameterTypes = m.getParameterTypes();
if (m.getReturnType() == void.class && parameterTypes.length == 1 && parameterTypes[0].getSimpleName().equals("UpgradeDetailWrapper")){
HookUtils.hookBeforeIfEnabled(this, m, param -> param.setResult(null));
}
}

Class<?> upgc;
upgc = Initiator.load("com.tencent.mobileqq.upgrade.UpgradeController");
if (upgc == null) {
upgc = Initiator.load("com.tencent.mobileqq.app.upgrade.UpgradeController");
}
if (upgc == null){
throw new RuntimeException("HookUpgrade: 加载出错");
}

for (Method m : upgc.getDeclaredMethods()) {
if (m.getReturnType() == void.class) {
HookUtils.hookBeforeIfEnabled(this, m, param -> param.setResult(null));
} else if (m.getReturnType() == boolean.class) {
HookUtils.hookBeforeIfEnabled(this, m, param -> param.setResult(false));
}
}

} catch (Exception e) {
throw new RuntimeException("HookUpgrade: 加载出错");
}
return false;
}

@NonNull
@Override
public String getName() {
return "屏蔽更新";
}
}
12 changes: 12 additions & 0 deletions app/src/main/java/xyz/nextalone/hook/CleanRecentChat.kt
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,18 @@ object CleanRecentChat : CommonSwitchFunctionHook(arrayOf(NFriendsStatusUtil_isC
}
}

private fun ntVersion() {
/*
contactType Equal:
== 1 联系人
== 103 公众号
== 2 群聊
== 131 我的关联QQ账号 uid=9992
class: com.tencent.qqnt.chats.core.adapter.holder.deleteMsg extend View.OnClickListener
*/

}


private fun handler(recentAdapter: Any?, app: Any?, all: Boolean, other: Boolean, includeTopped: Boolean, context: Context) {
try {
Expand Down

0 comments on commit 4da6dda

Please sign in to comment.