Merge "reduced the checkforapp function call to reduce unwanted log info" into android-10.0
diff --git a/Android.mk b/Android.mk
index efcf1b6..f82a0ba 100755
--- a/Android.mk
+++ b/Android.mk
@@ -399,7 +399,9 @@
     plat_hwservice_contexts \
     vendor_hwservice_contexts \
     minadbd \
-    twrpbu
+    twrpbu \
+    me.twrp.twrpapp.apk \
+    privapp-permissions-twrpapp.xml
 
 ifneq ($(TW_INCLUDE_CRYPTO),)
 TWRP_REQUIRED_MODULES += \
diff --git a/partition.cpp b/partition.cpp
index 1ca505d..e609f54 100755
--- a/partition.cpp
+++ b/partition.cpp
@@ -692,7 +692,9 @@
 		}
 	} else {
 		Set_FBE_Status();
-		if (!Decrypt_FBE_DE()) {
+		int is_device_fbe;
+		DataManager::GetValue(TW_IS_FBE, is_device_fbe);
+		if (!Decrypt_FBE_DE() && is_device_fbe == 1) {
 			char wrappedvalue[PROPERTY_VALUE_MAX];
 			property_get("fbe.data.wrappedkey", wrappedvalue, "");
 			std::string wrappedkeyvalue(wrappedvalue);
@@ -724,11 +726,11 @@
 	DataManager::SetValue(TW_IS_DECRYPTED, 1);
 	Is_Encrypted = true;
 	Is_Decrypted = true;
-	LOGINFO("Setup_Data_Partition::Key_Directory::%s\n", Key_Directory.c_str());
 	if (Key_Directory.empty()) {
 		Is_FBE = false;
 		DataManager::SetValue(TW_IS_FBE, 0);
 	} else {
+		LOGINFO("Setup_Data_Partition::Key_Directory::%s\n", Key_Directory.c_str());
 		Is_FBE = true;
 		DataManager::SetValue(TW_IS_FBE, 1);
 	}
@@ -930,10 +932,15 @@
 			}
 			break;
 		case TWFLAG_WRAPPEDKEY:
-			// Set fbe.data.wrappedkey to true
+			// Set wrappedkey props to true for data and/or metadata
 			{
-				property_set("fbe.data.wrappedkey", "true");
-				LOGINFO("FBE wrapped key enabled\n");
+				size_t slash_loc = Mount_Point.find('/');
+				std::string partition = Mount_Point.substr(slash_loc + 1);
+				if (Mount_Point == "/data" || Mount_Point == "/metadata") {
+					std::string wrapped_prop = "fbe." + partition + ".wrappedkey";
+					property_set(wrapped_prop.c_str(), "true");
+					LOGINFO("FBE wrapped key enabled for %s\n", Mount_Point.c_str());
+				}
 			}
 			break;
 		case TWFLAG_FLASHIMG:
diff --git a/twrpinstall/adb_install.cpp b/twrpinstall/adb_install.cpp
index 5eb8c0b..917dbe4 100755
--- a/twrpinstall/adb_install.cpp
+++ b/twrpinstall/adb_install.cpp
@@ -43,6 +43,7 @@
 
 #include "fuse_sideload.h"
 #include "twinstall/install.h"
+#include "twinstall.h"
 #include "twinstall/wipe_data.h"
 #include "minadbd_types.h"
 #include "otautil/sysutil.h"
@@ -116,7 +117,8 @@
         break;
       }
     }
-    *result = install_package(FUSE_SIDELOAD_HOST_PATHNAME, false, false, 0);
+    int dummy;
+    *result = TWinstall_zip(FUSE_SIDELOAD_HOST_PATHNAME, &dummy);
     break;
   }