@@ -11,9 +11,11 @@ import com.parallelc.micts.config.XposedConfig.KEY_VIBRATE
1111import com.parallelc.micts.module
1212import com.parallelc.micts.ui.activity.triggerCircleToSearch
1313import io.github.libxposed.api.XposedInterface.AfterHookCallback
14+ import io.github.libxposed.api.XposedInterface.BeforeHookCallback
1415import io.github.libxposed.api.XposedInterface.Hooker
1516import io.github.libxposed.api.XposedModuleInterface.PackageLoadedParam
1617import io.github.libxposed.api.annotations.AfterInvocation
18+ import io.github.libxposed.api.annotations.BeforeInvocation
1719import io.github.libxposed.api.annotations.XposedHooker
1820import java.lang.ref.WeakReference
1921import 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