Merge "includes: update includes for base and ext4 policies" into android-9.0
diff --git a/Android.mk b/Android.mk
index 595d8b4..3d9800d 100755
--- a/Android.mk
+++ b/Android.mk
@@ -143,6 +143,9 @@
LOCAL_SHARED_LIBRARIES += libstlport
LOCAL_CFLAGS += -DTW_NO_SHA2_LIBRARY
endif
+ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 25; echo $$?),0)
+ LOCAL_CFLAGS += -DUSE_OLD_BASE_INCLUDE
+endif
ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 24; echo $$?),0)
LOCAL_SHARED_LIBRARIES += libmincrypttwrp
LOCAL_C_INCLUDES += $(LOCAL_PATH)/libmincrypt/includes
diff --git a/partition.cpp b/partition.cpp
index 3469eb4..cb969a4 100755
--- a/partition.cpp
+++ b/partition.cpp
@@ -2470,6 +2470,7 @@
}
bool TWPartition::Recreate_AB_Cache_Dir(const ext4_encryption_policy &policy) {
+#ifdef TW_INCLUDE_FBE
struct passwd pd;
struct passwd *pwdptr = &pd;
struct passwd *tempPd;
@@ -2519,6 +2520,7 @@
}
}
}
+#endif
return true;
}
diff --git a/twrp-functions.cpp b/twrp-functions.cpp
index 2f563d9..e0e4301 100755
--- a/twrp-functions.cpp
+++ b/twrp-functions.cpp
@@ -1336,6 +1336,7 @@
}
bool TWFunc::Get_Encryption_Policy(ext4_encryption_policy &policy, std::string path) {
+#ifdef TW_INCLUDE_FBE
if (!TWFunc::Path_Exists(path)) {
LOGERR("Unable to find %s to get policy\n", path.c_str());
return false;
@@ -1344,10 +1345,12 @@
LOGERR("No policy set for path %s\n", path.c_str());
return false;
}
+#endif
return true;
}
bool TWFunc::Set_Encryption_Policy(std::string path, const ext4_encryption_policy &policy) {
+#ifdef TW_INCLUDE_FBE
if (!TWFunc::Path_Exists(path)) {
LOGERR("unable to find %s to set policy\n", path.c_str());
return false;
@@ -1359,10 +1362,12 @@
LOGERR("unable to set policy for path: %s\n", path.c_str());
return false;
}
+#endif
return true;
}
bool TWFunc::Is_Data_Wiped(std::string path) {
+#ifdef TW_INCLUDE_FBE
DIR* d = opendir(path.c_str());
size_t file_count = 0;
if (d != NULL) {
@@ -1380,5 +1385,8 @@
}
LOGINFO("file_count: %zu\n", file_count);
return file_count == 0;
+#else
+ return true;
+#endif
}
#endif // ndef BUILD_TWRPTAR_MAIN
diff --git a/twrp-functions.hpp b/twrp-functions.hpp
index 9c83788..21c16a7 100755
--- a/twrp-functions.hpp
+++ b/twrp-functions.hpp
@@ -21,7 +21,12 @@
#include <string>
#include <vector>
+
+#ifdef USE_FSCRYPT
#include <ext4_utils/ext4_crypt.h>
+#else
+#include "ext4crypt_tar.h"
+#endif
#include "twrpDigest/twrpDigest.hpp"
#include "ext4crypt_tar.h"
diff --git a/twrp.cpp b/twrp.cpp
index 1550bfe..cf519bb 100755
--- a/twrp.cpp
+++ b/twrp.cpp
@@ -43,10 +43,11 @@
#include "twrp-functions.hpp"
#include "data.hpp"
#include "partitions.hpp"
-#ifdef __ANDROID_API_N__
-#include <android-base/strings.h>
-#else
+
+#ifdef USE_OLD_BASE_INCLUDE
#include <base/strings.h>
+#else
+#include <android-base/strings.h>
#endif
#include "openrecoveryscript.hpp"
#include "variables.h"