Skip to content

Commit 8c76de0

Browse files
lingqiqi5211nakixii
andcommitted
fix: RecentResource hook failed on HyperOS3
Co-authored-by: nakixii <61456408+nakixii@users.noreply.github.com>
1 parent 7c436e4 commit 8c76de0

1 file changed

Lines changed: 41 additions & 3 deletions

File tree

  • library/hook/src/main/java/com/sevtinge/hyperceiler/hook/module/rules/home/recent

library/hook/src/main/java/com/sevtinge/hyperceiler/hook/module/rules/home/recent/RecentResource.kt

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ package com.sevtinge.hyperceiler.hook.module.rules.home.recent
2121
import android.app.Application
2222
import android.content.Context
2323
import android.content.res.Resources
24-
import com.sevtinge.hyperceiler.hook.module.base.BaseHook
24+
import com.sevtinge.hyperceiler.hook.module.base.pack.home.HomeBaseHookNew
2525
import com.sevtinge.hyperceiler.hook.module.base.tool.HookTool
2626
import com.sevtinge.hyperceiler.hook.utils.ResourcesHookData
2727
import com.sevtinge.hyperceiler.hook.utils.ResourcesHookMap
@@ -31,7 +31,7 @@ import de.robv.android.xposed.XC_MethodHook
3131
import io.github.kyuubiran.ezxhelper.xposed.EzXposed
3232
import io.github.kyuubiran.ezxhelper.xposed.EzXposed.appContext
3333

34-
object RecentResource : BaseHook() {
34+
object RecentResource : HomeBaseHookNew() {
3535
private val hookMap = ResourcesHookMap<String, ResourcesHookData>()
3636
private fun hook(param: XC_MethodHook.MethodHookParam) {
3737
try {
@@ -48,13 +48,51 @@ object RecentResource : BaseHook() {
4848
mPrefsMap.getInt("task_view_corners", 20)
4949
}
5050

51-
override fun init() {
51+
@Version(isPad = false, min = 600000000)
52+
private fun isNewHomeHook() {
53+
// thank nakixii
54+
hookAllMethods("com.miui.home.recents.util.WindowCornerRadiusUtil", "setWindowRadius",
55+
object : MethodHook() {
56+
override fun after(param: MethodHookParam) {
57+
runCatching {
58+
val f = param.method.declaringClass.getDeclaredField("sTaskViewCornerRadius")
59+
f.isAccessible = true
60+
f.setInt(null, sRoundedCorner)
61+
}
62+
}
63+
})
5264

65+
publicHook()
66+
}
67+
68+
@Version(isPad = true, min = 450000000)
69+
private fun isNewHomeHookPad() {
70+
// thank nakixii
71+
hookAllMethods("com.miui.home.recents.util.WindowCornerRadiusUtil", "setWindowRadius",
72+
object : MethodHook() {
73+
override fun after(param: MethodHookParam) {
74+
runCatching {
75+
val f = param.method.declaringClass.getDeclaredField("sTaskViewCornerRadius")
76+
f.isAccessible = true
77+
f.setInt(null, sRoundedCorner)
78+
}
79+
}
80+
})
81+
82+
publicHook()
83+
}
84+
85+
override fun initBase() {
5386
findAndHookMethod("com.miui.home.recents.util.WindowCornerRadiusUtil", "getTaskViewCornerRadius", object : HookTool.MethodHook(){
5487
override fun before(param: MethodHookParam?) {
5588
param?.result = sRoundedCorner
5689
}
5790
})
91+
92+
publicHook()
93+
}
94+
95+
private fun publicHook() {
5896
Application::class.java.hookBeforeMethod("attach", Context::class.java) { it ->
5997
EzXposed.initAppContext(it.args[0] as Context)
6098

0 commit comments

Comments
 (0)