Skip to content

Commit

Permalink
fix: Volume button hook
Browse files Browse the repository at this point in the history
Before that, there was a single hook to always skip the method on call. As it turns out, the method was used widely in the app and broke a lot of things. This commit implements checks to avoid this behaviour.
  • Loading branch information
AetherMagee committed Mar 31, 2024
1 parent 1ec4d6a commit 57196b8
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion app/src/main/java/aether/killergram/neo/Hooks.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package aether.killergram.neo

import android.view.KeyEvent
import de.robv.android.xposed.XC_MethodHook
import de.robv.android.xposed.XC_MethodReplacement
import de.robv.android.xposed.XposedBridge

Expand Down Expand Up @@ -86,7 +88,19 @@ class Hooks {
XposedBridge.hookAllMethods(
launchActivityClass,
"dispatchKeyEvent",
XC_MethodReplacement.returnConstant(true)
object : XC_MethodHook() {
override fun beforeHookedMethod(param: MethodHookParam?) {
param?.args?.get(0)?.let { event ->
if (event is KeyEvent &&
event.action == KeyEvent.ACTION_DOWN &&
(event.keyCode == KeyEvent.KEYCODE_VOLUME_UP || event.keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)) {
log("Nullified volume key press", "DEBUG")
param.result = true
}
}
super.beforeHookedMethod(param)
}
}
)
}
}

0 comments on commit 57196b8

Please sign in to comment.