Add untested function Android_ComputeRecursiveDirectorySize

This commit is contained in:
Henrik Rydgård committed 2021-09-11 18:11:53 +02:00
1 parent cd79a1d92f
commit e842d395fa
4 files changed
+69 -2

No files matched your search

+13
View File
@@ -20,6 +20,7 @@ static jmethodID contentUriFileExists;
static jmethodID contentUriGetFreeStorageSpace;
static jmethodID filePathGetFreeStorageSpace;
static jmethodID isExternalStoragePreservedLegacy;
static jmethodID computeRecursiveDirectorySize;
static jobject g_nativeActivity;
@@ -54,6 +55,8 @@ void Android_RegisterStorageCallbacks(JNIEnv * env, jobject obj) {
_dbg_assert_(filePathGetFreeStorageSpace);
isExternalStoragePreservedLegacy = env->GetMethodID(env->GetObjectClass(obj), "isExternalStoragePreservedLegacy", "()Z");
_dbg_assert_(isExternalStoragePreservedLegacy);
computeRecursiveDirectorySize = env->GetMethodID(env->GetObjectClass(obj), "computeRecursiveDirectorySize", "(Ljava/lang/String;)J");
_dbg_assert_(computeRecursiveDirectorySize);
}
bool Android_IsContentUri(const std::string &filename) {
@@ -258,6 +261,16 @@ int64_t Android_GetFreeSpaceByFilePath(const std::string &filePath) {
return env->CallLongMethod(g_nativeActivity, filePathGetFreeStorageSpace, param);
}
int64_t Android_ComputeRecursiveDirectorySize(const std::string &uri) {
if (!g_nativeActivity) {
return false;
}
auto env = getEnv();
jstring param = env->NewStringUTF(uri.c_str());
return env->CallLongMethod(g_nativeActivity, computeRecursiveDirectorySize, param);
}
bool Android_IsExternalStoragePreservedLegacy() {
if (!g_nativeActivity) {
return false;