anykernel-flash-mode-menu.patch 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. diff --git a/anykernel.sh b/anykernel.sh
  2. index 35b6e59..aecf80b 100755
  3. --- a/anykernel.sh
  4. +++ b/anykernel.sh
  5. @@ -33,6 +33,50 @@ no_magisk_check=1
  6. # import functions/variables and setup patching - see for reference (DO NOT REMOVE)
  7. . tools/ak3-core.sh
  8. +handle_input() {
  9. + while true; do
  10. + case $(getevent -lqc "/dev/input/event2" 2>/dev/null | grep -m1 'DOWN') in
  11. + *KEY_VOLUMEUP*) echo "normal"; return ;;
  12. + *KEY_VOLUMEDOWN*) echo "bypass"; return ;;
  13. + *KEY_POWER*) echo "cancel"; return ;;
  14. + esac
  15. + done
  16. +}
  17. +
  18. +choose_flash_mode() {
  19. + ui_print " "
  20. + ui_print " -> Most users do not need this; try Normal first"
  21. + ui_print " -> This does not help bypass root detection; it only swaps the Image for compatibility workarounds"
  22. + ui_print " -> Use it only when Normal fails to boot due to kernel module incompatibilities"
  23. + ui_print " "
  24. + ui_print " -> Choose Kernel Image:"
  25. + ui_print " -> VOL+ = Normal"
  26. + ui_print " -> VOL- = Bypass"
  27. + ui_print " -> POWER = Cancel"
  28. + ui_print " "
  29. +
  30. + while true; do
  31. + case $(handle_input) in
  32. + normal)
  33. + ui_print " -> Selected: Normal"
  34. + return 0
  35. + ;;
  36. + bypass)
  37. + ui_print " -> Selected: Bypass"
  38. + if [ -f "$AKHOME/Bypass-Image" ]; then
  39. + cp -f "$AKHOME/Bypass-Image" "$AKHOME/Image"
  40. + ui_print " -> Using Bypass-Image for this flash"
  41. + return 0
  42. + fi
  43. + abort " -> ERROR: Bypass-Image not found. Abort."
  44. + ;;
  45. + cancel)
  46. + abort " -> Cancelled by POWER button. Abort."
  47. + ;;
  48. + esac
  49. + done
  50. +}
  51. +
  52. # GKI check
  53. kernel_version=$(cat /proc/version | awk -F '-' '{print $1}' | awk '{print $3}')
  54. case $kernel_version in
  55. @@ -45,6 +89,8 @@ esac
  56. ui_print " " " -> Wild Kernels Supported: $ksu_supported"
  57. $ksu_supported || abort " -> Non-GKI device, abort."
  58. +choose_flash_mode
  59. +
  60. # boot install
  61. split_boot