diff options
author | Eugene Sandulenko | 2019-09-25 21:47:30 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2019-09-27 00:22:20 +0200 |
commit | 580142c9eaf7fafd4f15827545aaa7f4a1d03322 (patch) | |
tree | d5d6fa5625409f3ec19dec07f45a7f411c17976e /backends/platform/android/jni.cpp | |
parent | 2b72cc0b5ce716a8163ef211887df5c9742983a5 (diff) | |
download | scummvm-rg350-580142c9eaf7fafd4f15827545aaa7f4a1d03322.tar.gz scummvm-rg350-580142c9eaf7fafd4f15827545aaa7f4a1d03322.tar.bz2 scummvm-rg350-580142c9eaf7fafd4f15827545aaa7f4a1d03322.zip |
ANDROID: Hook getAllStorageLocations() into JNI
Diffstat (limited to 'backends/platform/android/jni.cpp')
-rw-r--r-- | backends/platform/android/jni.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/backends/platform/android/jni.cpp b/backends/platform/android/jni.cpp index 2c27838f6a..8c330c0e89 100644 --- a/backends/platform/android/jni.cpp +++ b/backends/platform/android/jni.cpp @@ -86,6 +86,7 @@ jmethodID JNI::_MID_setWindowCaption = 0; jmethodID JNI::_MID_showVirtualKeyboard = 0; jmethodID JNI::_MID_showKeyboardControl = 0; jmethodID JNI::_MID_getSysArchives = 0; +jmethodID JNI::_MID_getAllStorageLocations = 0; jmethodID JNI::_MID_initSurface = 0; jmethodID JNI::_MID_deinitSurface = 0; @@ -531,6 +532,7 @@ void JNI::create(JNIEnv *env, jobject self, jobject asset_manager, FIND_METHOD(, showVirtualKeyboard, "(Z)V"); FIND_METHOD(, showKeyboardControl, "(Z)V"); FIND_METHOD(, getSysArchives, "()[Ljava/lang/String;"); + FIND_METHOD(, getAllStorageLocations, "()[Ljava/lang/String;"); FIND_METHOD(, initSurface, "()Ljavax/microedition/khronos/egl/EGLSurface;"); FIND_METHOD(, deinitSurface, "()V"); @@ -697,4 +699,38 @@ jstring JNI::getCurrentCharset(JNIEnv *env, jobject self) { return env->NewStringUTF("ISO-8859-1"); } +Common::Array<Common::String> JNI::getAllStorageLocations() { + Common::Array<Common::String> *res = new Common::Array<Common::String>(); + + JNIEnv *env = JNI::getEnv(); + + jobjectArray array = + (jobjectArray)env->CallObjectMethod(_jobj, _MID_getAllStorageLocations); + + if (env->ExceptionCheck()) { + LOGE("Error finding system archive path"); + + env->ExceptionDescribe(); + env->ExceptionClear(); + + return *res; + } + + jsize size = env->GetArrayLength(array); + for (jsize i = 0; i < size; ++i) { + jstring path_obj = (jstring)env->GetObjectArrayElement(array, i); + const char *path = env->GetStringUTFChars(path_obj, 0); + + if (path != 0) { + res->push_back(path); + env->ReleaseStringUTFChars(path_obj, path); + } + + env->DeleteLocalRef(path_obj); + } + + return *res; +} + + #endif |