bypass.patch 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. diff --git a/anykernel.sh b/anykernel.sh
  2. index 35b6e59..e2bcb62 100755
  3. --- a/anykernel.sh
  4. +++ b/anykernel.sh
  5. @@ -45,6 +45,52 @@ esac
  6. ui_print " " " -> Wild Kernels Supported: $ksu_supported"
  7. $ksu_supported || abort " -> Non-GKI device, abort."
  8. +handle_input() {
  9. + # Listen for the first key DOWN event across input devices.
  10. + # Some recoveries (OrangeFox) expose different /dev/input/eventN numbers,
  11. + # so avoid hardcoding the node and read from all devices instead.
  12. + while true; do
  13. + # getevent with no device typically listens to all input devices in recovery
  14. + ev=$(getevent -lqc 2>/dev/null | grep -m1 'DOWN' || true)
  15. + case "$ev" in
  16. + *KEY_POWER*) echo "cancel"; return ;;
  17. + *KEY_VOLUMEUP*) echo "bypass"; return ;;
  18. + *KEY_VOLUMEDOWN*) echo "normal"; return ;;
  19. + esac
  20. + done
  21. +}
  22. +
  23. +choose_flash_mode() {
  24. + ui_print " "
  25. + ui_print " -> Most users do not need this; try Normal first"
  26. + ui_print " -> This does not help bypass root detection; it only swaps the Image for compatibility workarounds"
  27. + ui_print " -> Use it only when Normal fails to boot due to kernel module incompatibilities"
  28. + ui_print " "
  29. + ui_print " -> Choose Kernel Image:"
  30. + ui_print " -> VOL+ = Bypass"
  31. + ui_print " -> VOL- = Normal"
  32. + ui_print " -> POWER = Cancel"
  33. + ui_print " "
  34. +
  35. + while true; do
  36. + case $(handle_input) in
  37. + normal)
  38. + ui_print " -> Selected: Normal"
  39. + return 0
  40. + ;;
  41. + bypass)
  42. + ui_print " -> Selected: Bypass"
  43. + if [ -f "$AKHOME/Bypass-Image" ]; then
  44. + cp -f "$AKHOME/Bypass-Image" "$AKHOME/Image"
  45. + ui_print " -> Using Bypass-Image for this flash"
  46. + return 0
  47. + fi
  48. + abort " -> ERROR: Bypass-Image not found. Abort."
  49. + ;;
  50. + cancel)
  51. + abort " -> Cancelled by POWER button. Abort."
  52. + ;;
  53. + esac
  54. + done
  55. +}
  56. +
  57. +choose_flash_mode
  58. +
  59. # boot install
  60. split_boot