From 1176e19406d3e29501eba2f09b2bb7ffdcd15dde Mon Sep 17 00:00:00 2001 From: osm0sis Date: Thu, 22 Mar 2018 14:14:23 -0300 Subject: [PATCH] AK2: only AVB sign if dumped original dumped image is signed (#20) - avoids issues for broad AK2-based mod zips on devices where AVB 1.0 signed images cause issues, while maintaining signing on AVB 1.0 devices --- tools/ak2-core.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/ak2-core.sh b/tools/ak2-core.sh index fc2a143..00491fe 100755 --- a/tools/ak2-core.sh +++ b/tools/ak2-core.sh @@ -270,9 +270,11 @@ flash_boot() { esac; savedpath="$LD_LIBRARY_PATH"; unset LD_LIBRARY_PATH; - /system/bin/dalvikvm -Xbootclasspath:/system/framework/core-oj.jar:/system/framework/core-libart.jar:/system/framework/conscrypt.jar:/system/framework/bouncycastle.jar -Xnodex2oat -Xnoimage-dex2oat -cp $bin/BootSignature_Android.jar com.android.verity.BootSignature /$avbtype boot-new.img $pk8 $cert boot-new-signed.img; - if [ $? != 0 ]; then - ui_print " "; ui_print "Signing image failed. Aborting..."; exit 1; + if [ "$(/system/bin/dalvikvm -Xbootclasspath:/system/framework/core-oj.jar:/system/framework/core-libart.jar:/system/framework/conscrypt.jar:/system/framework/bouncycastle.jar -Xnodex2oat -Xnoimage-dex2oat -cp $bin/BootSignature_Android.jar com.android.verity.BootSignature -verify boot.img | grep VALID)" ]; then + /system/bin/dalvikvm -Xbootclasspath:/system/framework/core-oj.jar:/system/framework/core-libart.jar:/system/framework/conscrypt.jar:/system/framework/bouncycastle.jar -Xnodex2oat -Xnoimage-dex2oat -cp $bin/BootSignature_Android.jar com.android.verity.BootSignature /$avbtype boot-new.img $pk8 $cert boot-new-signed.img; + if [ $? != 0 ]; then + ui_print " "; ui_print "Signing image failed. Aborting..."; exit 1; + fi; fi; test "$savedpath" && export LD_LIBRARY_PATH="$savedpath"; mv -f boot-new-signed.img boot-new.img;