am 2466e5ea: Handle devices with two bootloader copies

* commit '2466e5eaa596c7704a78af71a73e86bacca1032e':
  Handle devices with two bootloader copies
diff --git a/clear-factory-images-variables.sh b/clear-factory-images-variables.sh
index 154244d..aa41e7c 100644
--- a/clear-factory-images-variables.sh
+++ b/clear-factory-images-variables.sh
@@ -17,6 +17,7 @@
 unset BOOTLOADER
 unset BOOTLOADERFILE
 unset BOOTLOADERSRC
+unset TWINBOOTLOADERS
 unset BUILD
 unset CDMARADIO
 unset CDMARADIOFILE
diff --git a/generate-factory-images-common.sh b/generate-factory-images-common.sh
index f89bd6f..e1a4b6e 100644
--- a/generate-factory-images-common.sh
+++ b/generate-factory-images-common.sh
@@ -117,6 +117,14 @@
 fi
 cat >> tmp/$PRODUCT-$VERSION/flash-all.sh << EOF
 fastboot flash bootloader bootloader-$DEVICE-$BOOTLOADER.img
+EOF
+if test "$TWINBOOTLOADERS" = "true"
+then
+cat >> tmp/$PRODUCT-$VERSION/flash-all.sh << EOF
+fastboot flash bootloader2 bootloader-$DEVICE-$BOOTLOADER.img
+EOF
+fi
+cat >> tmp/$PRODUCT-$VERSION/flash-all.sh << EOF
 fastboot reboot-bootloader
 sleep $SLEEPDURATION
 EOF
@@ -178,6 +186,14 @@
 fi
 cat >> tmp/$PRODUCT-$VERSION/flash-all.bat << EOF
 fastboot flash bootloader bootloader-$DEVICE-$BOOTLOADER.img
+EOF
+if test "$TWINBOOTLOADERS" = "true"
+then
+cat >> tmp/$PRODUCT-$VERSION/flash-all.bat << EOF
+fastboot flash bootloader2 bootloader-$DEVICE-$BOOTLOADER.img
+EOF
+fi
+cat >> tmp/$PRODUCT-$VERSION/flash-all.bat << EOF
 fastboot reboot-bootloader
 ping -n $SLEEPDURATION 127.0.0.1 >nul
 EOF
@@ -232,6 +248,14 @@
 fi
 cat >> tmp/$PRODUCT-$VERSION/flash-base.sh << EOF
 fastboot flash bootloader bootloader-$DEVICE-$BOOTLOADER.img
+EOF
+if test "$TWINBOOTLOADERS" = "true"
+then
+cat >> tmp/$PRODUCT-$VERSION/flash-base.sh << EOF
+fastboot flash bootloader2 bootloader-$DEVICE-$BOOTLOADER.img
+EOF
+fi
+cat >> tmp/$PRODUCT-$VERSION/flash-base.sh << EOF
 fastboot reboot-bootloader
 sleep $SLEEPDURATION
 EOF