bypass.patch 2.6 KB

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