From ecbef7ba7f73ce287bd510acedc972d13e18aaa7 Mon Sep 17 00:00:00 2001 From: Parallelc Date: Sat, 14 Dec 2024 04:47:51 +0800 Subject: [PATCH] fix: skip startRecentsAnimationPre --- .../java/com/parallelc/micts/ModuleMain.kt | 7 ++--- .../com/parallelc/micts/hooker/CSMSHooker.kt | 13 +------- .../micts/hooker/NavStubViewHooker.kt | 30 ++++++++++--------- .../com/parallelc/micts/hooker/SkipHooker.kt | 17 +++++++++++ 4 files changed, 37 insertions(+), 30 deletions(-) create mode 100644 app/src/main/java/com/parallelc/micts/hooker/SkipHooker.kt diff --git a/app/src/main/java/com/parallelc/micts/ModuleMain.kt b/app/src/main/java/com/parallelc/micts/ModuleMain.kt index a25a8b6..67d0008 100644 --- a/app/src/main/java/com/parallelc/micts/ModuleMain.kt +++ b/app/src/main/java/com/parallelc/micts/ModuleMain.kt @@ -65,16 +65,15 @@ class ModuleMain(base: XposedInterface, param: ModuleLoadedParam) : XposedModule when (param.packageName) { "com.miui.home", "com.mi.android.globallauncher" -> { - runCatching { + val skipHookTouch = runCatching { val circleToSearchHelper = param.classLoader.loadClass("com.miui.home.recents.cts.CircleToSearchHelper") hook(circleToSearchHelper.getDeclaredMethod("invokeOmni", Context::class.java, Int::class.java, Int::class.java), InvokeOmniHooker::class.java) - return }.onFailure { e -> log("hook CircleToSearchHelper fail", e) - } + }.isSuccess runCatching { - NavStubViewHooker.hook(param) + NavStubViewHooker.hook(param, skipHookTouch) }.onFailure { e -> log("hook NavStubView fail", e) } diff --git a/app/src/main/java/com/parallelc/micts/hooker/CSMSHooker.kt b/app/src/main/java/com/parallelc/micts/hooker/CSMSHooker.kt index 70714a4..b927ae0 100644 --- a/app/src/main/java/com/parallelc/micts/hooker/CSMSHooker.kt +++ b/app/src/main/java/com/parallelc/micts/hooker/CSMSHooker.kt @@ -34,7 +34,7 @@ class CSMSHooker { fun startContextualSearch(entryPoint: Int): Boolean { var unhookers = mutableListOf>() return runCatching { - unhookers += module!!.hook(enforcePermission!!, EnforcePermissionHooker::class.java) + unhookers += module!!.hook(enforcePermission!!, SkipHooker::class.java) unhookers += module!!.hook(getContextualSearchPackageName!!, GetCSPackageNameHooker::class.java) val icsmClass = Class.forName("android.app.contextualsearch.IContextualSearchManager") @@ -61,17 +61,6 @@ class CSMSHooker { } } - @XposedHooker - class EnforcePermissionHooker : Hooker { - companion object { - @JvmStatic - @BeforeInvocation - fun before(callback: BeforeHookCallback) { - callback.returnAndSkip(null) - } - } - } - @XposedHooker class GetCSPackageNameHooker : Hooker { companion object { diff --git a/app/src/main/java/com/parallelc/micts/hooker/NavStubViewHooker.kt b/app/src/main/java/com/parallelc/micts/hooker/NavStubViewHooker.kt index 08ac6b9..13e9a60 100644 --- a/app/src/main/java/com/parallelc/micts/hooker/NavStubViewHooker.kt +++ b/app/src/main/java/com/parallelc/micts/hooker/NavStubViewHooker.kt @@ -24,23 +24,25 @@ class NavStubViewHooker { private lateinit var mCurrY: Field private lateinit var mInitY: Field - fun hook(param: PackageLoadedParam) { + fun hook(param: PackageLoadedParam, skipHookTouch: Boolean) { val navStubView = param.classLoader.loadClass("com.miui.home.recents.NavStubView") + runCatching { + module!!.hook(navStubView.getDeclaredMethod("startRecentsAnimationPre"), SkipHooker::class.java) + } + if (skipHookTouch) return runCatching { navStubView.getDeclaredField("mCheckLongPress") } .onSuccess { throw Exception("mCheckLongPress exists") } - .onFailure { - mCurrAction = navStubView.getDeclaredField("mCurrAction") - mCurrAction.isAccessible = true - mCurrX = navStubView.getDeclaredField("mCurrX") - mCurrX.isAccessible = true - mInitX = navStubView.getDeclaredField("mInitX") - mInitX.isAccessible = true - mCurrY = navStubView.getDeclaredField("mCurrY") - mCurrY.isAccessible = true - mInitY = navStubView.getDeclaredField("mInitY") - mInitY.isAccessible = true - module!!.hook(navStubView.getDeclaredMethod("onTouchEvent", MotionEvent::class.java), OnTouchEventHooker::class.java) - } + mCurrAction = navStubView.getDeclaredField("mCurrAction") + mCurrAction.isAccessible = true + mCurrX = navStubView.getDeclaredField("mCurrX") + mCurrX.isAccessible = true + mInitX = navStubView.getDeclaredField("mInitX") + mInitX.isAccessible = true + mCurrY = navStubView.getDeclaredField("mCurrY") + mCurrY.isAccessible = true + mInitY = navStubView.getDeclaredField("mInitY") + mInitY.isAccessible = true + module!!.hook(navStubView.getDeclaredMethod("onTouchEvent", MotionEvent::class.java), OnTouchEventHooker::class.java) } @XposedHooker diff --git a/app/src/main/java/com/parallelc/micts/hooker/SkipHooker.kt b/app/src/main/java/com/parallelc/micts/hooker/SkipHooker.kt new file mode 100644 index 0000000..0ecf3ce --- /dev/null +++ b/app/src/main/java/com/parallelc/micts/hooker/SkipHooker.kt @@ -0,0 +1,17 @@ +package com.parallelc.micts.hooker + +import io.github.libxposed.api.XposedInterface.BeforeHookCallback +import io.github.libxposed.api.XposedInterface.Hooker +import io.github.libxposed.api.annotations.BeforeInvocation +import io.github.libxposed.api.annotations.XposedHooker + +@XposedHooker +class SkipHooker : Hooker { + companion object { + @JvmStatic + @BeforeInvocation + fun before(callback: BeforeHookCallback) { + callback.returnAndSkip(null) + } + } +} \ No newline at end of file