super partition: mount super partitions using fs_mgr

We are now requiring fstab v2 for android-10+ trees. You can
specify twrp flags using /etc/twrp.flags to label and
annotate partitions.

This patchset uses fs_mgr to load the super partition and build
device mapper blocks off vendor and system depending on the slot
in use. These are mapped to partitions in TWRP and allowed to
be mounted read-only. The super partition is also mapped into a
TWRP partition in order to backup the entire partition. You cannot
backup individual device mapper blocks due to the device can only
be read-only. Therefore you cannot write back to the device mapper.

Change-Id: Icc1d895dcf96ad5ba03989c9bf759419d83673a3
diff --git a/Android.mk b/Android.mk
index 6875d03..0bbad69 100755
--- a/Android.mk
+++ b/Android.mk
@@ -52,6 +52,9 @@
 
 TARGET_RECOVERY_GUI := true
 
+LOCAL_STATIC_LIBRARIES :=
+LOCAL_SHARED_LIBRARIES :=
+
 ifneq ($(TW_DEVICE_VERSION),)
     LOCAL_CFLAGS += -DTW_DEVICE_VERSION='"-$(TW_DEVICE_VERSION)"'
 else
@@ -77,6 +80,19 @@
     tarWrite.c \
     twrpAdbBuFifo.cpp
 
+ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 29; echo $$?),0)
+    LOCAL_STATIC_LIBRARIES += libavb
+    LOCAL_SHARED_LIBRARIES += libfs_mgr libinit
+    LOCAL_C_INCLUDES += \
+        system/core/fs_mgr/libfs_avb/include/ \
+        system/core/fs_mgr/include_fstab/ \
+        system/core/fs_mgr/include/ \
+        system/core/fs_mgr/libdm/include/ \
+        system/core/fs_mgr/liblp/include/ \
+        system/gsid/include/ \
+        system/core/init/
+endif
+
 ifneq ($(TARGET_RECOVERY_REBOOT_SRC),)
   LOCAL_SRC_FILES += $(TARGET_RECOVERY_REBOOT_SRC)
 endif
@@ -117,9 +133,6 @@
     LOCAL_C_INCLUDES += external/boringssl/include external/libcxx/include
 endif
 
-LOCAL_STATIC_LIBRARIES :=
-LOCAL_SHARED_LIBRARIES :=
-
 LOCAL_STATIC_LIBRARIES += libguitwrp
 LOCAL_SHARED_LIBRARIES += libz libc libcutils libstdc++ libtar libblkid libminuitwrp libminadbd libmtdutils libtwadbbu libbootloader_message_twrp
 LOCAL_SHARED_LIBRARIES += libcrecovery libtwadbbu libtwrpdigest libc++ libaosprecovery
@@ -153,7 +166,6 @@
     else
         LOCAL_SHARED_LIBRARIES += libziparchive
         LOCAL_C_INCLUDES += system/core/libziparchive/include
-        LOCAL_C_FLAGS += -DUSE_
     endif
 else
     LOCAL_SHARED_LIBRARIES += libminzip
@@ -190,6 +202,10 @@
     TWRP_REQUIRED_MODULES += libhardware
 endif
 
+ifeq ($(PRODUCT_USE_DYNAMIC_PARTITIONS),true)
+    LOCAL_CFLAGS += -DPRODUCT_USE_DYNAMIC_PARTITIONS=1
+endif
+
 LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin
 
 ifeq ($(TARGET_RECOVERY_TWRP_LIB),)