From 9b3896fd3dd5f16d282f603dc6c2569c50d89a05 Mon Sep 17 00:00:00 2001 From: osm0sis Date: Sat, 2 Sep 2023 11:48:22 -0300 Subject: [PATCH] Retain PREINITDEVICE during A-only addon.d --- scripts/addon.d.sh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/scripts/addon.d.sh b/scripts/addon.d.sh index 28617ed0a..d284a538a 100644 --- a/scripts/addon.d.sh +++ b/scripts/addon.d.sh @@ -72,6 +72,12 @@ initialize() { main() { if ! $backuptool_ab; then + # Restore PREINITDEVICE from previous A-only partition + if [ -f config.orig ]; then + PREINITDEVICE=$(grep_prop PREINITDEVICE config.orig) + rm config.orig + fi + # Wait for post addon.d-v1 processes to finish sleep 5 fi @@ -128,7 +134,15 @@ case "$1" in # Stub ;; pre-backup) - # Stub + # Back up PREINITDEVICE from existing partition before OTA on A-only devices + if ! $backuptool_ab; then + initialize + RECOVERYMODE=false + find_boot_image + $MAGISKBIN/magiskboot unpack "$BOOTIMAGE" + $MAGISKBIN/magiskboot cpio ramdisk.cpio "extract .backup/.magisk config.orig" + $MAGISKBIN/magiskboot cleanup + fi ;; post-backup) # Stub