diff --git a/META-INF/com/google/android/updater-script b/META-INF/com/google/android/updater-script index 9a64949..230fcfd 100644 --- a/META-INF/com/google/android/updater-script +++ b/META-INF/com/google/android/updater-script @@ -3,4 +3,4 @@ # Dummy file; update-binary is a shell script (DO NOT CHANGE) # # -# AK_BASE_VERSION=20230406 +# AK_BASE_VERSION=20230416 diff --git a/tools/ak3-core.sh b/tools/ak3-core.sh index 15c8c13..45c6ca6 100755 --- a/tools/ak3-core.sh +++ b/tools/ak3-core.sh @@ -415,7 +415,7 @@ flash_boot() { # flash_generic flash_generic() { - local avb avbblock avbpath file flags img imgblock isro isunmounted path; + local avb avbblock avbpath file flags img imgblock imgsz isro isunmounted path; cd $home; for file in $1 $1.img; do @@ -461,25 +461,34 @@ flash_generic() { cd $home; fi fi - echo "Removing any existing $1_ak3..." >&2; - $bin/lptools_static remove $1_ak3; - echo "Attempting to create $1_ak3..." >&2; - if $bin/lptools_static create $1_ak3 $(wc -c < $img); then - echo "Replacing $1$slot with $1_ak3..." >&2; - $bin/lptools_static unmap $1_ak3 || abort "Unmapping $1_ak3 failed. Aborting..."; - $bin/lptools_static map $1_ak3 || abort "Mapping $1_ak3 failed. Aborting..."; - $bin/lptools_static replace $1_ak3 $1$slot || abort "Replacing $1$slot failed. Aborting..."; - imgblock=/dev/block/mapper/$1_ak3; - else - echo "Creating $1_ak3 failed. Attempting to resize $1$slot..." >&2; - $bin/httools_static umount $1 || abort "Unmounting $1 failed. Aborting..."; - if [ -e $path/$1-verity ]; then - $bin/lptools_static unmap $1-verity || abort "Unmapping $1-verity failed. Aborting..."; + imgsz=$(wc -c < $img); + if [ "$imgsz" != "$(wc -c < $imgblock)" ]; then + if [ -d /postinstall/tmp -a "$slot_select" == "inactive" ]; then + echo "Resizing $1$slot snapshot..." >&2; + $bin/snapshotupdater_static update $1 $imgsz || abort "Resizing $1$slot snapshot failed. Aborting..."; + else + echo "Removing any existing $1_ak3..." >&2; + $bin/lptools_static remove $1_ak3; + echo "Attempting to create $1_ak3..." >&2; + if $bin/lptools_static create $1_ak3 $imgsz; then + echo "Replacing $1$slot with $1_ak3..." >&2; + $bin/lptools_static unmap $1_ak3 || abort "Unmapping $1_ak3 failed. Aborting..."; + $bin/lptools_static map $1_ak3 || abort "Mapping $1_ak3 failed. Aborting..."; + $bin/lptools_static replace $1_ak3 $1$slot || abort "Replacing $1$slot failed. Aborting..."; + imgblock=/dev/block/mapper/$1_ak3; + ui_print " " "Warning: $1$slot replaced in super. Reboot before further logical partition operations."; + else + echo "Creating $1_ak3 failed. Attempting to resize $1$slot..." >&2; + $bin/httools_static umount $1 || abort "Unmounting $1 failed. Aborting..."; + if [ -e $path/$1-verity ]; then + $bin/lptools_static unmap $1-verity || abort "Unmapping $1-verity failed. Aborting..."; + fi + $bin/lptools_static unmap $1$slot || abort "Unmapping $1$slot failed. Aborting..."; + $bin/lptools_static resize $1$slot $imgsz || abort "Resizing $1$slot failed. Aborting..."; + $bin/lptools_static map $1$slot || abort "Mapping $1$slot failed. Aborting..."; + isunmounted=1; + fi fi - $bin/lptools_static unmap $1$slot || abort "Unmapping $1$slot failed. Aborting..."; - $bin/lptools_static resize $1$slot $(wc -c < $img) || abort "Resizing $1$slot failed. Aborting..."; - $bin/lptools_static map $1$slot || abort "Mapping $1$slot failed. Aborting..."; - isunmounted=1; fi elif [ "$(wc -c < $img)" -gt "$(wc -c < $imgblock)" ]; then abort "New $1 image larger than $1 partition. Aborting..."; diff --git a/tools/snapshotupdater_static b/tools/snapshotupdater_static new file mode 100755 index 0000000..062a54b Binary files /dev/null and b/tools/snapshotupdater_static differ