Skip to content

Commit

Permalink
fix: ForcePadMode,ForcePhoneMode on TIM_NT
Browse files Browse the repository at this point in the history
Closes #1266
  • Loading branch information
HdShare committed Dec 12, 2024
1 parent be9e14a commit dda17e2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
12 changes: 8 additions & 4 deletions app/src/main/java/cc/ioctl/hook/experimental/ForcePadMode.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ import io.github.qauxv.hook.CommonSwitchFunctionHook
import io.github.qauxv.util.Initiator
import io.github.qauxv.util.QQVersion
import io.github.qauxv.util.SyncUtils
import io.github.qauxv.util.TIMVersion
import io.github.qauxv.util.requireMinQQVersion
import io.github.qauxv.util.requireMinTimVersion
import xyz.nextalone.util.throwOrTrue

@FunctionHookEntry
Expand All @@ -43,7 +45,7 @@ object ForcePadMode : CommonSwitchFunctionHook(targetProc = SyncUtils.PROC_ANY)
override val extraSearchKeywords: Array<String> = arrayOf("pad")
override val uiItemLocation = FunctionEntryRouter.Locations.Auxiliary.EXPERIMENTAL_CATEGORY
override val isApplicationRestartRequired = true
override val isAvailable = requireMinQQVersion(QQVersion.QQ_8_9_15)
override val isAvailable = requireMinQQVersion(QQVersion.QQ_8_9_15) || requireMinTimVersion(TIMVersion.TIM_4_0_95)

override fun initOnce() = throwOrTrue {
check(isAvailable) { "ForcePadMode is not available" }
Expand All @@ -59,9 +61,11 @@ object ForcePadMode : CommonSwitchFunctionHook(targetProc = SyncUtils.PROC_ANY)
// }
val appSettingClass = Initiator.loadClass("com.tencent.common.config.AppSetting")
appSettingClass.getDeclaredMethod("f").hookAfter {
val appIdPhone = appSettingClass.getStaticObject("e")
val appIdPad = appSettingClass.getStaticObject("f")
it.result = appIdPad
val (appIdPhone, appIdPad) = Pair(
if (requireMinTimVersion(TIMVersion.TIM_4_0_95)) "f" else "e",
if (requireMinTimVersion(TIMVersion.TIM_4_0_95)) "g" else "f",
)
it.result = appSettingClass.getStaticObject(appIdPad)
}
}

Expand Down
12 changes: 8 additions & 4 deletions app/src/main/java/cc/ioctl/hook/experimental/ForcePhoneMode.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ import io.github.qauxv.hook.CommonSwitchFunctionHook
import io.github.qauxv.util.Initiator
import io.github.qauxv.util.QQVersion
import io.github.qauxv.util.SyncUtils
import io.github.qauxv.util.TIMVersion
import io.github.qauxv.util.requireMinQQVersion
import io.github.qauxv.util.requireMinTimVersion
import xyz.nextalone.util.throwOrTrue

@FunctionHookEntry
Expand All @@ -43,15 +45,17 @@ object ForcePhoneMode : CommonSwitchFunctionHook(targetProc = SyncUtils.PROC_ANY
override val extraSearchKeywords: Array<String> = arrayOf("phone")
override val uiItemLocation = FunctionEntryRouter.Locations.Auxiliary.EXPERIMENTAL_CATEGORY
override val isApplicationRestartRequired = true
override val isAvailable = requireMinQQVersion(QQVersion.QQ_8_9_15)
override val isAvailable = requireMinQQVersion(QQVersion.QQ_8_9_15) || requireMinTimVersion(TIMVersion.TIM_4_0_95)

override fun initOnce() = throwOrTrue {
check(isAvailable) { "ForcePhoneMode is not available" }
val appSettingClass = Initiator.loadClass("com.tencent.common.config.AppSetting")
appSettingClass.getDeclaredMethod("f").hookAfter {
val appIdPhone = appSettingClass.getStaticObject("e")
val appIdPad = appSettingClass.getStaticObject("f")
it.result = appIdPhone
val (appIdPhone, appIdPad) = Pair(
if (requireMinTimVersion(TIMVersion.TIM_4_0_95)) "f" else "e",
if (requireMinTimVersion(TIMVersion.TIM_4_0_95)) "g" else "f",
)
it.result = appSettingClass.getStaticObject(appIdPhone)
}
}

Expand Down

0 comments on commit dda17e2

Please sign in to comment.