bypass.patch 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. diff --git a/AnyKernel3/anykernel.sh b/AnyKernel3/anykernel.sh
  2. --- a/AnyKernel3/anykernel.sh 2026-05-23 20:16:58.305522267 -0400
  3. +++ b/AnyKernel3/anykernel.sh 2026-05-23 21:32:11.537813431 -0400
  4. @@ -45,6 +45,72 @@
  5. ui_print " " " -> Wild Kernels Supported: $ksu_supported"
  6. $ksu_supported || abort " -> Non-GKI device, abort."
  7. +handle_input() {
  8. + # 1) try picking a node that advertises volume/power keys via /proc
  9. + if [ -r /proc/bus/input/devices ]; then
  10. + node=$(awk -v RS= '/KEY/ && /KEY_VOLUMEUP|KEY_VOLUMEDOWN|KEY_POWER/ {
  11. + if (match($0, /event[0-9]+/)) print "/dev/input/" substr($0, RSTART, RLENGTH)
  12. + }' /proc/bus/input/devices | head -n1)
  13. + if [ -n "$node" ] && [ -e "$node" ]; then
  14. + case $(getevent -lqc "$node" 2>/dev/null | grep -m1 'DOWN' || true) in
  15. + *KEY_VOLUMEUP*) echo "bypass"; return 0 ;;
  16. + *KEY_VOLUMEDOWN*) echo "normal"; return 0 ;;
  17. + *KEY_POWER*) echo "cancel"; return 0 ;;
  18. + esac
  19. + fi
  20. + fi
  21. +
  22. + # 2) fallback: scan a small range of common event nodes
  23. + for ev in /dev/input/event{0..12}; do
  24. + [ -e "$ev" ] || continue
  25. + case $(getevent -lqc "$ev" 2>/dev/null | grep -m1 'DOWN' || true) in
  26. + *KEY_VOLUMEUP*) echo "bypass"; return 0 ;;
  27. + *KEY_VOLUMEDOWN*) echo "normal"; return 0 ;;
  28. + *KEY_POWER*) echo "cancel"; return 0 ;;
  29. + esac
  30. + done
  31. +
  32. + # 3) final global attempt (may block on some recoveries)
  33. + case $(getevent -lqc 2>/dev/null | grep -m1 'DOWN' || true) in
  34. + *KEY_VOLUMEUP*) echo "bypass"; return 0 ;;
  35. + *KEY_VOLUMEDOWN*) echo "normal"; return 0 ;;
  36. + *KEY_POWER*) echo "cancel"; return 0 ;;
  37. + esac
  38. +
  39. + return 1
  40. +}
  41. +
  42. +choose_flash_mode() {
  43. + ui_print " "
  44. + ui_print " -> Most users do not need Bypass; try Normal first!"
  45. + ui_print " -> This only swaps the Image for compatibility workarounds."
  46. + ui_print " -> VOL+ = Bypass | VOL- = Normal | POWER = Cancel"
  47. + ui_print " "
  48. +
  49. + while true; do
  50. + case $(handle_input) in
  51. + normal)
  52. + ui_print " -> Selected: Normal"
  53. + return 0
  54. + ;;
  55. + bypass)
  56. + ui_print " -> Selected: Bypass"
  57. + if [ -f "$AKHOME/Bypass-Image" ]; then
  58. + cp -f "$AKHOME/Bypass-Image" "$AKHOME/Image"
  59. + ui_print " -> Using Bypass-Image for this flash"
  60. + return 0
  61. + fi
  62. + abort " -> ERROR: Bypass-Image not found. Abort."
  63. + ;;
  64. + cancel)
  65. + abort " -> Cancelled by POWER button. Abort."
  66. + ;;
  67. + esac
  68. + done
  69. +}
  70. +
  71. +choose_flash_mode
  72. +
  73. # boot install
  74. split_boot