Migrate PREINITDEVICE in recovery mode

Close #6917
This commit is contained in:
topjohnwu
2023-06-02 16:49:04 -07:00
parent 7eebe62bb6
commit feb44f875e
7 changed files with 23 additions and 44 deletions

View File

@ -125,9 +125,9 @@ case $((STATUS & 3)) in
;;
1 ) # Magisk patched
ui_print "- Magisk patched boot image detected"
# Find SHA1 of stock boot image
[ -z $SHA1 ] && SHA1=$(./magiskboot cpio ramdisk.cpio sha1 2>/dev/null)
./magiskboot cpio ramdisk.cpio restore
./magiskboot cpio ramdisk.cpio \
"extract .backup/.magisk config.orig" \
"restore"
cp -af ramdisk.cpio ramdisk.cpio.orig
rm -f stock_boot.img
;;
@ -143,6 +143,17 @@ if [ $((STATUS & 4)) -ne 0 ]; then
INIT=init.real
fi
if [ -f config.orig ]; then
# Read existing configs
chmod 0644 config.orig
SHA1=$(grep_prop SHA1 config.orig)
if ! $BOOTMODE; then
# Do not inherit config if not in recovery
PREINITDEVICE=$(grep_prop PREINITDEVICE config.orig)
fi
rm config.orig
fi
##################
# Ramdisk Patches
##################
@ -169,7 +180,7 @@ echo "KEEPFORCEENCRYPT=$KEEPFORCEENCRYPT" >> config
echo "PATCHVBMETAFLAG=$PATCHVBMETAFLAG" >> config
echo "RECOVERYMODE=$RECOVERYMODE" >> config
if [ -n "$PREINITDEVICE" ]; then
ui_print "- Pre-init storage partition device ID: $PREINITDEVICE"
ui_print "- Pre-init storage partition: $PREINITDEVICE"
echo "PREINITDEVICE=$PREINITDEVICE" >> config
fi
[ -n "$SHA1" ] && echo "SHA1=$SHA1" >> config

View File

@ -104,7 +104,12 @@ case $((STATUS & 3)) in
1 ) # Magisk patched
ui_print "- Magisk patched image detected"
# Find SHA1 of stock boot image
SHA1=$(./magiskboot cpio ramdisk.cpio sha1 2>/dev/null)
./magiskboot cpio ramdisk.cpio "extract .backup/.magisk config.orig"
if [ -f config.orig ]; then
chmod 0644 config.orig
SHA1=$(grep_prop SHA1 config.orig)
rm config.orig
fi
BACKUPDIR=/data/magisk_backup_$SHA1
if [ -d $BACKUPDIR ]; then
ui_print "- Restoring stock boot image"