mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-21 15:05:28 +00:00
Simplify ramdisk test
This commit is contained in:
parent
c2eb603957
commit
7cf56b4406
@ -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<()> {
|
||||
|
@ -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"
|
||||
;;
|
||||
|
Loading…
Reference in New Issue
Block a user