Unmount vendor after apex

BUG: prebuilt vendor blobs are being overriden by vendor partition, which causes failed to decrypt the device
TEST: after this patch vendor is no more overriding and decryption working as expected.

 * Devices using the stock or the rom based libs then it needed to add the TW_USES_VENDOR_LIBS := true in the BoardConfig

Change-Id: I3cbc7fe6df2289081e9198941cfb65a1a7e0e6a3
Signed-off-by: Mohd Faraz <androiabledroid@gmail.com>
diff --git a/Android.mk b/Android.mk
index bfd5797..ef067cc 100755
--- a/Android.mk
+++ b/Android.mk
@@ -153,6 +153,10 @@
     LOCAL_CFLAGS += -DPRODUCT_USE_DYNAMIC_PARTITIONS=1
 endif
 
+ifeq ($(TW_USES_VENDOR_LIBS),true)
+    LOCAL_CFLAGS += -DUSE_VENDOR_LIBS=1
+endif
+
 ifneq ($(BOARD_GOOGLE_DYNAMIC_PARTITIONS_PARTITION_LIST),)
 	BOARD_DYNAMIC_PARTITIONS_PARTITION_LIST := $(BOARD_GOOGLE_DYNAMIC_PARTITIONS_PARTITION_LIST)
 else ifneq ($(BOARD_QTI_DYNAMIC_PARTITIONS_PARTITION_LIST),)
diff --git a/partitionmanager.cpp b/partitionmanager.cpp
index 5c279ab..d85ae2a 100755
--- a/partitionmanager.cpp
+++ b/partitionmanager.cpp
@@ -295,6 +295,12 @@
 			}
 		}
 	}
+#ifndef USE_VENDOR_LIBS
+	if (ven)
+		ven->UnMount(true);
+	if (sys)
+		sys->UnMount(true);
+#endif
 
 	if (!datamedia && !settings_partition && Find_Partition_By_Path("/sdcard") == NULL && Find_Partition_By_Path("/internal_sd") == NULL && Find_Partition_By_Path("/internal_sdcard") == NULL && Find_Partition_By_Path("/emmc") == NULL) {
 		// Attempt to automatically identify /data/media emulated storage devices