From b10b10d4a21658437201027e8f5f633792eeefba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E6=B1=A0?= <98259561+whitechi73@users.noreply.github.com> Date: Wed, 31 Jan 2024 12:17:33 +0800 Subject: [PATCH] `Shamrock`: add version restrictions for GuildSdk --- .../shamrock/remote/action/handlers/GetGuildList.kt | 3 +++ .../moe/fuqiuluo/shamrock/utils/PlatformUtils.kt | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/xposed/src/main/java/moe/fuqiuluo/shamrock/remote/action/handlers/GetGuildList.kt b/xposed/src/main/java/moe/fuqiuluo/shamrock/remote/action/handlers/GetGuildList.kt index e510a81..89807bc 100644 --- a/xposed/src/main/java/moe/fuqiuluo/shamrock/remote/action/handlers/GetGuildList.kt +++ b/xposed/src/main/java/moe/fuqiuluo/shamrock/remote/action/handlers/GetGuildList.kt @@ -8,8 +8,10 @@ import moe.fuqiuluo.shamrock.remote.action.ActionSession import moe.fuqiuluo.shamrock.remote.action.IActionHandler import moe.fuqiuluo.shamrock.tools.EmptyJsonArray import moe.fuqiuluo.shamrock.tools.EmptyJsonString +import moe.fuqiuluo.shamrock.utils.PlatformUtils import moe.fuqiuluo.shamrock.xposed.helper.NTServiceFetcher import moe.fuqiuluo.symbols.OneBotHandler +import mqq.app.MobileQQ @OneBotHandler("get_guild_list") internal object GetGuildList : IActionHandler() { @@ -22,6 +24,7 @@ internal object GetGuildList : IActionHandler() { if (refresh) { kernelGProService.refreshGuildList(true) } + PlatformUtils.requireMinQQVersion(version = PlatformUtils.QQ_9_0_8_VER) val result = arrayListOf() kernelGProService.guildListFromCache.forEach { if (it.result != 0) return@forEach diff --git a/xposed/src/main/java/moe/fuqiuluo/shamrock/utils/PlatformUtils.kt b/xposed/src/main/java/moe/fuqiuluo/shamrock/utils/PlatformUtils.kt index 736a67f..2a74dde 100644 --- a/xposed/src/main/java/moe/fuqiuluo/shamrock/utils/PlatformUtils.kt +++ b/xposed/src/main/java/moe/fuqiuluo/shamrock/utils/PlatformUtils.kt @@ -16,11 +16,24 @@ import mqq.app.MobileQQ import kotlin.random.Random internal object PlatformUtils { + const val QQ_9_0_8_VER = 5540 + fun getQQVersion(context: Context): String { val packageInfo: PackageInfo = context.packageManager.getPackageInfo(context.packageName, 0) return packageInfo.versionName } + fun getQQVersionCode(context: Context = MobileQQ.getContext()): Int { + val packageInfo: PackageInfo = context.packageManager.getPackageInfo(context.packageName, 0) + return packageInfo.versionCode + } + + fun requireMinQQVersion(context: Context = MobileQQ.getContext(), version: Int) { + require(getQQVersionCode(context) >= version) { + "require QQ version >= $version, but current version is ${getQQVersionCode(context)}" + } + } + /** * 获取OIDB包的ClientVersion信息 */