소스 검색

refactor: add patching for AnyKernel flash mode selection in build process

TheWildJames 3 달 전
부모
커밋
d7c04c80fe
2개의 변경된 파일70개의 추가작업 그리고 0개의 파일을 삭제
  1. 5 0
      .github/actions/build-kernel/action.yml
  2. 65 0
      .github/actions/build-kernel/patches/anykernel-flash-mode-menu.patch

+ 5 - 0
.github/actions/build-kernel/action.yml

@@ -95,6 +95,11 @@ runs:
     working-directory: ${{ github.workspace }}
     run: |
       set -euo pipefail
+      PATCH_FILE="${{ github.action_path }}/patches/anykernel-flash-mode-menu.patch"
+      if [ -f "$PATCH_FILE" ]; then
+        patch -d "${{ github.workspace }}/AnyKernel3" -p1 < "$PATCH_FILE"
+      fi
+
       if [ -f "${{ github.workspace }}/kernel/out/${{ inputs.version }}/dist/Image" ]; then
         if [[ ${{ inputs.bypass }} == "true" ]]; then
           cp "${{ github.workspace }}/kernel/out/${{ inputs.version }}/dist/Image" "${{ github.workspace }}/AnyKernel3/Bypass-Image"

+ 65 - 0
.github/actions/build-kernel/patches/anykernel-flash-mode-menu.patch

@@ -0,0 +1,65 @@
+diff --git a/anykernel.sh b/anykernel.sh
+index 35b6e59..aecf80b 100755
+--- a/anykernel.sh
++++ b/anykernel.sh
+@@ -33,6 +33,50 @@ no_magisk_check=1
+ # import functions/variables and setup patching - see for reference (DO NOT REM
+OVE)
+ . tools/ak3-core.sh
+ 
++handle_input() {
++    while true; do
++        case $(getevent -lqc "/dev/input/event2" 2>/dev/null | grep -m1 'DOWN') in
++            *KEY_VOLUMEUP*) echo "normal"; return ;;
++            *KEY_VOLUMEDOWN*) echo "bypass"; return ;;
++            *KEY_POWER*) echo "cancel"; return ;;
++        esac
++    done
++}
++
++choose_flash_mode() {
++    ui_print " "
++    ui_print "  -> Most users do not need this; try Normal first"
++    ui_print "  -> This does not help bypass root detection; it only swaps the Image for compatibility workarounds"
++    ui_print "  -> Use it only when Normal fails to boot due to kernel module incompatibilities"
++    ui_print " "
++    ui_print "  -> Choose Kernel Image:"
++    ui_print "  -> VOL+ = Normal"
++    ui_print "  -> VOL- = Bypass"
++    ui_print "  -> POWER = Cancel"
++    ui_print " "
++
++    while true; do
++        case $(handle_input) in
++            normal)
++                ui_print "  -> Selected: Normal"
++                return 0
++                ;;
++            bypass)
++                ui_print "  -> Selected: Bypass"
++                if [ -f "$AKHOME/Bypass-Image" ]; then
++                    cp -f "$AKHOME/Bypass-Image" "$AKHOME/Image"
++                    ui_print "  -> Using Bypass-Image for this flash"
++                    return 0
++                fi
++                abort "  -> ERROR: Bypass-Image not found. Abort."
++                ;;
++            cancel)
++                abort "  -> Cancelled by POWER button. Abort."
++                ;;
++        esac
++    done
++}
++
+ # GKI check
+ kernel_version=$(cat /proc/version | awk -F '-' '{print $1}' | awk '{print $3}')
+ case $kernel_version in
+@@ -45,6 +89,8 @@ esac
+ ui_print " " "  -> Wild Kernels Supported: $ksu_supported"
+ $ksu_supported || abort "  -> Non-GKI device, abort."
+ 
++choose_flash_mode
++
+ # boot install
+ split_boot
+