anykernel-flash-mode-menu.patch 2.0 KB

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