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 | |
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')
5 files changed, 44 insertions, 4 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 diff --git a/backends/platform/android/jni.h b/backends/platform/android/jni.h index b6e5df819e..fe4b948070 100644 --- a/backends/platform/android/jni.h +++ b/backends/platform/android/jni.h @@ -30,6 +30,7 @@ #include "common/fs.h" #include "common/archive.h" +#include "common/array.h" class OSystem_Android; @@ -79,6 +80,8 @@ public: static inline int writeAudio(JNIEnv *env, jbyteArray &data, int offset, int size); + static Common::Array<Common::String> getAllStorageLocations(); + private: static JavaVM *_vm; // back pointer to (java) peer instance @@ -104,6 +107,7 @@ private: static jmethodID _MID_showVirtualKeyboard; static jmethodID _MID_showKeyboardControl; static jmethodID _MID_getSysArchives; + static jmethodID _MID_getAllStorageLocations; static jmethodID _MID_initSurface; static jmethodID _MID_deinitSurface; diff --git a/backends/platform/android/org/scummvm/scummvm/ExternalStorage.java b/backends/platform/android/org/scummvm/scummvm/ExternalStorage.java index 234fba9bff..d8bab31517 100644 --- a/backends/platform/android/org/scummvm/scummvm/ExternalStorage.java +++ b/backends/platform/android/org/scummvm/scummvm/ExternalStorage.java @@ -104,7 +104,7 @@ public class ExternalStorage { List<String> mountHash = new ArrayList<String>(10); - for (String mount : mMounts){ + for (String mount : mMounts) { File root = new File(mount); if (root.exists() && root.isDirectory() && root.canRead()) { File[] list = root.listFiles(); diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVM.java b/backends/platform/android/org/scummvm/scummvm/ScummVM.java index ea7bf5242d..34349d4606 100644 --- a/backends/platform/android/org/scummvm/scummvm/ScummVM.java +++ b/backends/platform/android/org/scummvm/scummvm/ScummVM.java @@ -63,7 +63,7 @@ public abstract class ScummVM implements SurfaceHolder.Callback, Runnable { abstract protected void showVirtualKeyboard(boolean enable); abstract protected void showKeyboardControl(boolean enable); abstract protected String[] getSysArchives(); - abstract protected List<String> getAllStorageLocations(); + abstract protected String[] getAllStorageLocations(); public ScummVM(AssetManager asset_manager, SurfaceHolder holder) { _asset_manager = asset_manager; diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java index a955f02327..6978f6e3b0 100644 --- a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java +++ b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java @@ -157,8 +157,8 @@ public class ScummVMActivity extends Activity { } @Override - protected List<String> getAllStorageLocations() { - return _externalStorage.getAllStorageLocations(); + protected String[] getAllStorageLocations() { + return _externalStorage.getAllStorageLocations().toArray(new String[0]); } } |