cm: Rework boot animation generation
Keep the largest bootanimation extracted
and resize it at build-time.
Change-Id: Iee32f18440ff955d13ed85b273e97cbd540721fc
diff --git a/bootanimation/generate-bootanimation.sh b/bootanimation/generate-bootanimation.sh
new file mode 100755
index 0000000..37b8314
--- /dev/null
+++ b/bootanimation/generate-bootanimation.sh
@@ -0,0 +1,32 @@
+#!/bin/bash
+
+WIDTH="$1"
+HEIGHT="$2"
+HALF_RES="$3"
+OUT="$ANDROID_PRODUCT_OUT/obj/BOOTANIMATION"
+
+if [ "$HEIGHT" -lt "$WIDTH" ]; then
+ SIZE="$HEIGHT"
+else
+ SIZE="$WIDTH"
+fi
+
+if [ "$HALF_RES" = "true" ]; then
+ IMAGESIZE=$(expr $SIZE / 2)
+else
+ IMAGESIZE="$SIZE"
+fi
+
+RESOLUTION=""$IMAGESIZE"x"$IMAGESIZE""
+
+mkdir -p $ANDROID_PRODUCT_OUT/obj/BOOTANIMATION/bootanimation/part{0..2}
+tar xfp "vendor/cm/bootanimation/bootanimation.tar" --to-command="convert - -resize '$RESOLUTION' \"png8:$OUT/bootanimation/\$TAR_FILENAME\""
+
+# Create desc.txt
+echo "$SIZE" "$SIZE" 30 > "$OUT/bootanimation/desc.txt"
+cat "vendor/cm/bootanimation/desc.txt" >> "$OUT/bootanimation/desc.txt"
+
+# Create bootanimation.zip
+cd "$OUT/bootanimation"
+
+zip -qr0 "$OUT/bootanimation.zip" .