diff --git a/native/src/boot/cpio.rs b/native/src/boot/cpio.rs index 22fa5caa8..9fcb87771 100644 --- a/native/src/boot/cpio.rs +++ b/native/src/boot/cpio.rs @@ -175,9 +175,8 @@ Supported commands: extract [ENTRY OUT] Extract ENTRY to OUT, or extract all entries to current directory test - Test the cpio's status - Return value is 0 or bitwise or-ed of following values: - 0x1:Magisk 0x2:unsupported + Test the cpio's status. Return values: + 0:stock 1:Magisk 2:unsupported patch Apply ramdisk patches Configure with env variables: KEEPVERITY KEEPFORCEENCRYPT @@ -544,7 +543,6 @@ impl Cpio { } fn test(&self) -> i32 { - let mut ret = 0; for file in [ "sbin/launch_daemonsu.sh", "sbin/su", @@ -561,11 +559,10 @@ impl Cpio { "overlay/init.magisk.rc", ] { if self.exists(file) { - ret |= MAGISK_PATCHED; - break; + return MAGISK_PATCHED; } } - ret + 0 } fn restore(&mut self) -> LoggedResult<()> { diff --git a/scripts/boot_patch.sh b/scripts/boot_patch.sh index 419431398..2287544e2 100644 --- a/scripts/boot_patch.sh +++ b/scripts/boot_patch.sh @@ -119,14 +119,16 @@ else STATUS=0 SKIP_BACKUP="#" fi -case $((STATUS & 3)) in - 0 ) # Stock boot +case $STATUS in + 0 ) + # Stock boot ui_print "- Stock boot image detected" SHA1=$(./magiskboot sha1 "$BOOTIMAGE" 2>/dev/null) cat $BOOTIMAGE > stock_boot.img cp -af ramdisk.cpio ramdisk.cpio.orig 2>/dev/null ;; - 1 ) # Magisk patched + 1 ) + # Magisk patched ui_print "- Magisk patched boot image detected" ./magiskboot cpio ramdisk.cpio \ "extract .backup/.magisk config.orig" \ @@ -134,7 +136,8 @@ case $((STATUS & 3)) in cp -af ramdisk.cpio ramdisk.cpio.orig rm -f stock_boot.img ;; - 2 ) # Unsupported + 2 ) + # Unsupported ui_print "! Boot image patched by unsupported programs" abort "! Please restore back to stock boot image" ;;