twrpinstall: create library for twrpinstall

This library will need to mirror AOSP for any changes to installing
packages. The library has been separated out in order to make importing
updates from AOSP into the TWRP project.

twinstall.cpp has been removed from the recovery binary and added to
this library. It has been refactored for libziparchive.

Sideload has been reworked to use the newer methods from AOSP on
flashing packages through adb sideload.

We are also removing old libraries for adb and verifier.

Lastly before flashing a zip or image, we want to unlock block devices
for writing so that when an OTA is flashed to the inactive slot,
the flash will succeed.

Change-Id: I6d8702fc9031ffaf9f666b4ba375dc7d9362e473
diff --git a/Android.mk b/Android.mk
index 86a53d3..bf38c04 100755
--- a/Android.mk
+++ b/Android.mk
@@ -69,7 +69,6 @@
     partitionmanager.cpp \
     progresstracking.cpp \
     startupArgs.cpp \
-    twinstall.cpp \
     twrp-functions.cpp \
     twrpDigestDriver.cpp \
     openrecoveryscript.cpp \
@@ -78,7 +77,7 @@
     twrpApex.cpp \
     twrpRepacker.cpp
 
-LOCAL_STATIC_LIBRARIES += libavb
+LOCAL_STATIC_LIBRARIES += libavb libtwrpinstall
 LOCAL_SHARED_LIBRARIES += libfs_mgr libinit
 LOCAL_C_INCLUDES += \
     system/core/fs_mgr/libfs_avb/include/ \
@@ -88,7 +87,8 @@
     system/core/fs_mgr/liblp/include/ \
     system/gsid/include/ \
     system/core/init/ \
-    system/extras/ext4_utils/include
+    system/extras/ext4_utils/include \
+    $(LOCAL_PATH)/twinstall/include
 
 ifneq ($(TARGET_RECOVERY_REBOOT_SRC),)
   LOCAL_SRC_FILES += $(TARGET_RECOVERY_REBOOT_SRC)
@@ -120,12 +120,11 @@
     $(LOCAL_PATH)/install/include \
     $(LOCAL_PATH)/fuse_sideload/include \
     $(LOCAL_PATH)/install/include \
-    $(LOCAL_PATH)/verifier28/
+    $(LOCAL_PATH)/twrpinstall/include
 
 LOCAL_STATIC_LIBRARIES += libguitwrp
 LOCAL_SHARED_LIBRARIES += libz libc libcutils libstdc++ libtar libblkid libminuitwrp libminadbd libmtdutils libtwadbbu libbootloader_message
 LOCAL_SHARED_LIBRARIES += libcrecovery libtwadbbu libtwrpdigest libc++ libaosprecovery libinit libcrypto libbase libziparchive libselinux
-LOCAL_CFLAGS += -DUSE_28_VERIFIER
 
 ifneq ($(wildcard system/core/libsparse/Android.mk),)
 LOCAL_SHARED_LIBRARIES += libsparse
@@ -398,7 +397,8 @@
     toolbox \
     mkshrc_twrp \
     plat_hwservice_contexts \
-    vendor_hwservice_contexts
+    vendor_hwservice_contexts \
+    minadbd
 
 ifneq ($(TW_INCLUDE_CRYPTO),)
 TWRP_REQUIRED_MODULES += \
@@ -575,9 +575,9 @@
 LOCAL_MODULE_TAGS := optional
 
 LOCAL_SRC_FILES := install/adb_install.cpp install/asn1_decoder.cpp install/fuse_sdcard_install.cpp \
-    install/get_args.cpp install/install.cpp install/installcommand.cpp install/legacy_property_service.cpp \
-    install/package.cpp install/verifier.cpp install/wipe_data.cpp install/tw_atomic.cpp \
-    install/set_metadata.cpp verifier28/verifier.cpp install/zipwrap.cpp install/ZipUtil.cpp
+    install/get_args.cpp install/install.cpp install/legacy_property_service.cpp \
+    install/package.cpp install/verifier.cpp install/wipe_data.cpp \
+    install/set_metadata.cpp install/zipwrap.cpp install/ZipUtil.cpp
 LOCAL_SHARED_LIBRARIES += libbase libbootloader_message libcrypto libext4_utils \
     libfs_mgr libfusesideload libhidl-gen-utils libhidlbase \
     liblog libselinux libtinyxml2 libutils libz libziparchive libcutils
@@ -589,6 +589,7 @@
                     $(commands_TWRP_local_path)/otautil/include \
                     $(commands_TWRP_local_path)/minadbd \
                     $(commands_TWRP_local_path)/minzip \
+                    $(commands_TWRP_local_path)/twrpinstall/include \
                     system/libvintf/include
 LOCAL_STATIC_LIBRARIES += libotautil libvintf_recovery libvintf libhidl-gen-utils
 LOCAL_CFLAGS += -DRECOVERY_API_VERSION=$(RECOVERY_API_VERSION)
@@ -599,22 +600,6 @@
 
 include $(BUILD_SHARED_LIBRARY)
 
-# libverifier (static library)
-# ===============================
-include $(CLEAR_VARS)
-LOCAL_CLANG := true
-LOCAL_MODULE := libverifier
-LOCAL_SRC_FILES := \
-    asn1_decoder.cpp \
-    verifier.cpp
-LOCAL_STATIC_LIBRARIES := \
-    libotautil \
-    libcrypto_utils \
-    libcrypto \
-    libbase
-LOCAL_CFLAGS := -Wall -Werror
-include $(BUILD_STATIC_LIBRARY)
-
 commands_recovery_local_path := $(LOCAL_PATH)
 
 #    $(LOCAL_PATH)/edify/Android.mk