allow flashing sparse images

if the image has the right magic bytes to be a sparse image,
use simg2img to flash the image

create a rule to make a fully dynamic simg2img which results in a
much smaller increase in gzip ramdisk size (2KB vs 40KB)

Change-Id: I1b0f6bc127da46103888b1154a9bddd8ac02c01d
diff --git a/Android.mk b/Android.mk
index 52c2907..0a5692c 100644
--- a/Android.mk
+++ b/Android.mk
@@ -99,6 +99,7 @@
     system/vold \
     system/extras/ext4_utils \
     system/core/adb \
+    system/core/libsparse
 
 LOCAL_C_INCLUDES += bionic external/openssl/include $(LOCAL_PATH)/libmincrypt/includes
 ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 23; echo $$?),0)
@@ -351,7 +352,8 @@
     fsck.fat \
     fatlabel \
     mkfs.fat \
-    permissive.sh
+    permissive.sh \
+    simg2img_twrp
 
 ifneq ($(TARGET_ARCH), arm64)
     ifneq ($(TARGET_ARCH), x86_64)
@@ -586,6 +588,7 @@
     $(commands_recovery_local_path)/dosfstools/Android.mk \
     $(commands_recovery_local_path)/etc/Android.mk \
     $(commands_recovery_local_path)/toybox/Android.mk \
+    $(commands_recovery_local_path)/simg2img/Android.mk \
     $(commands_recovery_local_path)/libpixelflinger/Android.mk
 
 ifeq ($(TW_INCLUDE_CRYPTO), true)