Skip to content

Commit

Permalink
fix: skip startRecentsAnimationPre
Browse files Browse the repository at this point in the history
  • Loading branch information
parallelcc committed Dec 14, 2024
1 parent 2e74254 commit ecbef7b
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 30 deletions.
7 changes: 3 additions & 4 deletions app/src/main/java/com/parallelc/micts/ModuleMain.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
13 changes: 1 addition & 12 deletions app/src/main/java/com/parallelc/micts/hooker/CSMSHooker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class CSMSHooker {
fun startContextualSearch(entryPoint: Int): Boolean {
var unhookers = mutableListOf<MethodUnhooker<Method>>()
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")
Expand All @@ -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 {
Expand Down
30 changes: 16 additions & 14 deletions app/src/main/java/com/parallelc/micts/hooker/NavStubViewHooker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions app/src/main/java/com/parallelc/micts/hooker/SkipHooker.kt
Original file line number Diff line number Diff line change
@@ -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)
}
}
}

0 comments on commit ecbef7b

Please sign in to comment.