diff options
| author | JosJuice <josjuice@gmail.com> | 2020-06-26 17:52:31 +0200 |
|---|---|---|
| committer | JosJuice <josjuice@gmail.com> | 2020-09-16 18:38:53 +0200 |
| commit | 6e1e6d2311df787e800be199df369b5d12aa6cae (patch) | |
| tree | 6679d4714979bda6527f6dd8d84854eb3fc5bc17 /Source/Android/jni/AndroidCommon/AndroidCommon.cpp | |
| parent | d9f3e382fe1b2f1c7d9de54cefa920b4f0502af6 (diff) | |
Android: Add content provider support to File::IOFile
Taking the hit now to prepare us for when Google Play will
force us to use scoped storage...
Diffstat (limited to 'Source/Android/jni/AndroidCommon/AndroidCommon.cpp')
| -rw-r--r-- | Source/Android/jni/AndroidCommon/AndroidCommon.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Source/Android/jni/AndroidCommon/AndroidCommon.cpp b/Source/Android/jni/AndroidCommon/AndroidCommon.cpp index 1f9973d451..c8312048e9 100644 --- a/Source/Android/jni/AndroidCommon/AndroidCommon.cpp +++ b/Source/Android/jni/AndroidCommon/AndroidCommon.cpp @@ -11,6 +11,7 @@ #include <jni.h> #include "Common/StringUtil.h" +#include "jni/AndroidCommon/IDCache.h" std::string GetJString(JNIEnv* env, jstring jstr) { @@ -40,3 +41,20 @@ std::vector<std::string> JStringArrayToVector(JNIEnv* env, jobjectArray array) return result; } + +int OpenAndroidContent(const std::string& uri, const std::string& mode) +{ + JNIEnv* env = IDCache::GetEnvForThread(); + const jint fd = env->CallStaticIntMethod(IDCache::GetContentHandlerClass(), + IDCache::GetContentHandlerOpenFd(), ToJString(env, uri), + ToJString(env, mode)); + + // We can get an IllegalArgumentException when passing an invalid mode + if (env->ExceptionCheck()) + { + env->ExceptionDescribe(); + abort(); + } + + return fd; +} |
