diff --git a/META-INF/com/google/android/updater-script b/META-INF/com/google/android/updater-script index b8376c1..6e19c46 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=20220727 +# AK_BASE_VERSION=20220802 diff --git a/tools/ak3-core.sh b/tools/ak3-core.sh index a64f2da..0e298c3 100755 --- a/tools/ak3-core.sh +++ b/tools/ak3-core.sh @@ -415,7 +415,7 @@ flash_boot() { # flash_generic flash_generic() { - local avb avbblock file flags img imgblock isro path; + local avb avbblock avbpath file flags img imgblock isro isunmounted path; cd $home; for file in $1 $1.img; do @@ -444,27 +444,37 @@ flash_generic() { flags=$($bin/httools_static disable-flags); [ $? == 0 ] || abort "Failed to parse top-level vbmeta. Aborting..."; if [ "$flags" == "enabled" ]; then - [ "$1" == "vendor_dlkm" -a "$avb" == "vbmeta" ] || abort "Unable to patch $1 on $avb. Aborting ..."; - ui_print " " "dm-verity detected! Patching vbmeta..."; - for path in /dev/block/bootdevice/by-name /dev/block/mapper; do + ui_print " " "dm-verity detected! Patching $avb..."; + for avbpath in /dev/block/bootdevice/by-name /dev/block/mapper; do for file in $avb $avb$slot; do - if [ -e $path/$file ]; then - avbblock=$path/$file; + if [ -e $avbpath/$file ]; then + avbblock=$avbpath/$file; break 2; fi; done; done; cd $bin; - $bin/httools_static patch $home/$img $avbblock || abort "Failed to patch $1 on $avb. Aborting..."; + $bin/httools_static patch $1 $home/$img $avbblock || abort "Failed to patch $1 on $avb. Aborting..."; cd $home; fi fi $bin/lptools_static remove $1_ak3; - $bin/lptools_static create $1_ak3 $(wc -c < $img) || abort "Creating $1_ak3 failed. Aborting..."; - $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; + if $bin/lptools_static create $1_ak3 $(wc -c < $img); then + $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 + ui_print "Creating $1_ak3 failed. Attempting to resize $1$slot..."; + $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 $(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..."; fi; @@ -488,6 +498,9 @@ flash_generic() { if [ "$isro" != 0 ]; then blockdev --setro $imgblock 2>/dev/null; fi; + if [ "$isunmounted" -a "$path" == "/dev/block/mapper" ]; then + $bin/httools_static mount $1 || abort "Mounting $1 failed. Aborting..."; + fi touch ${1}_flashed; fi; } diff --git a/tools/httools_static b/tools/httools_static index cbb02bd..574fcfb 100755 Binary files a/tools/httools_static and b/tools/httools_static differ