Skip to content

Commit 727bd08

Browse files
committed
fix: skip startRecentsAnimationPre
1 parent 0a0f063 commit 727bd08

File tree

2 files changed

+34
-18
lines changed

2 files changed

+34
-18
lines changed

app/src/main/java/com/parallelc/micts/ModuleMain.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,15 @@ class ModuleMain(base: XposedInterface, param: ModuleLoadedParam) : XposedModule
6565

6666
when (param.packageName) {
6767
"com.miui.home", "com.mi.android.globallauncher" -> {
68-
runCatching {
68+
val skipHookTouch = runCatching {
6969
val circleToSearchHelper = param.classLoader.loadClass("com.miui.home.recents.cts.CircleToSearchHelper")
7070
hook(circleToSearchHelper.getDeclaredMethod("invokeOmni", Context::class.java, Int::class.java, Int::class.java), InvokeOmniHooker::class.java)
71-
return
7271
}.onFailure { e ->
7372
log("hook CircleToSearchHelper fail", e)
74-
}
73+
}.isSuccess
7574

7675
runCatching {
77-
NavStubViewHooker.hook(param)
76+
NavStubViewHooker.hook(param, skipHookTouch)
7877
}.onFailure { e ->
7978
log("hook NavStubView fail", e)
8079
}

app/src/main/java/com/parallelc/micts/hooker/NavStubViewHooker.kt

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ import com.parallelc.micts.config.XposedConfig.KEY_VIBRATE
1111
import com.parallelc.micts.module
1212
import com.parallelc.micts.ui.activity.triggerCircleToSearch
1313
import io.github.libxposed.api.XposedInterface.AfterHookCallback
14+
import io.github.libxposed.api.XposedInterface.BeforeHookCallback
1415
import io.github.libxposed.api.XposedInterface.Hooker
1516
import io.github.libxposed.api.XposedModuleInterface.PackageLoadedParam
1617
import io.github.libxposed.api.annotations.AfterInvocation
18+
import io.github.libxposed.api.annotations.BeforeInvocation
1719
import io.github.libxposed.api.annotations.XposedHooker
1820
import java.lang.ref.WeakReference
1921
import java.lang.reflect.Field
@@ -28,24 +30,39 @@ class NavStubViewHooker {
2830
private lateinit var mInitY: Field
2931
private var mContext: WeakReference<Context>? = null
3032

31-
fun hook(param: PackageLoadedParam) {
33+
fun hook(param: PackageLoadedParam, skipHookTouch: Boolean) {
3234
val navStubView = param.classLoader.loadClass("com.miui.home.recents.NavStubView")
35+
runCatching {
36+
module!!.hook(navStubView.getDeclaredMethod("startRecentsAnimationPre"), SkipHooker::class.java)
37+
}
38+
if (skipHookTouch) return
3339
runCatching { navStubView.getDeclaredField("mCheckLongPress") }
3440
.onSuccess { throw Exception("mCheckLongPress exists") }
35-
.onFailure {
36-
mCurrAction = navStubView.getDeclaredField("mCurrAction")
37-
mCurrAction.isAccessible = true
38-
mCurrX = navStubView.getDeclaredField("mCurrX")
39-
mCurrX.isAccessible = true
40-
mInitX = navStubView.getDeclaredField("mInitX")
41-
mInitX.isAccessible = true
42-
mCurrY = navStubView.getDeclaredField("mCurrY")
43-
mCurrY.isAccessible = true
44-
mInitY = navStubView.getDeclaredField("mInitY")
45-
mInitY.isAccessible = true
46-
module!!.hook(navStubView.getDeclaredMethod("onTouchEvent", MotionEvent::class.java), OnTouchEventHooker::class.java)
47-
module!!.hook(navStubView.getDeclaredConstructor(Context::class.java), ConstructorHooker::class.java)
41+
mCurrAction = navStubView.getDeclaredField("mCurrAction")
42+
mCurrAction.isAccessible = true
43+
mCurrX = navStubView.getDeclaredField("mCurrX")
44+
mCurrX.isAccessible = true
45+
mInitX = navStubView.getDeclaredField("mInitX")
46+
mInitX.isAccessible = true
47+
mCurrY = navStubView.getDeclaredField("mCurrY")
48+
mCurrY.isAccessible = true
49+
mInitY = navStubView.getDeclaredField("mInitY")
50+
mInitY.isAccessible = true
51+
module!!.hook(navStubView.getDeclaredMethod("onTouchEvent", MotionEvent::class.java), OnTouchEventHooker::class.java)
52+
module!!.hook(navStubView.getDeclaredConstructor(Context::class.java), ConstructorHooker::class.java)
53+
}
54+
55+
@XposedHooker
56+
class SkipHooker : Hooker {
57+
companion object {
58+
@JvmStatic
59+
@BeforeInvocation
60+
fun before(callback: BeforeHookCallback) {
61+
if (module!!.getRemotePreferences(CONFIG_NAME).getBoolean(KEY_GESTURE_TRIGGER, DEFAULT_CONFIG[KEY_GESTURE_TRIGGER] as Boolean)) {
62+
callback.returnAndSkip(null)
63+
}
4864
}
65+
}
4966
}
5067

5168
@XposedHooker

0 commit comments

Comments
 (0)