diff options
| author | echosys <echosys@noreply.localhost> | 2024-10-03 12:08:28 +0000 |
|---|---|---|
| committer | Mike Lothian <mike@fireburn.co.uk> | 2024-12-20 15:24:58 +0000 |
| commit | 15b173988a151fb4aa513dd0c556ef290a91a794 (patch) | |
| tree | c470eff26ffd8255aa20e05014488e9004a0ea9e /src/common/android/id_cache.cpp | |
| parent | 2ed4e7a2aef999dd3569d043546dbc6d7a6a08b8 (diff) | |
Fix Android crash caused by incorrect type in progress dialog callbacks (#58)
Bug discovered via an incomplete fix in Sudachi.
Some Progress Dialog callbacks pass the wrong type (Double instead of Long) from C++ to Java code causing a crash at runtime.
To fix this a new function is implemented to convert to a Java Long and that is used instead of the function that converts to a Double.
Reviewed-on: http://vub63vv26q6v27xzv2dtcd25xumubshogm67yrpaz2rculqxs7jlfqad.onion/torzu-emu/torzu/pulls/58
Co-authored-by: echosys <echosys@noreply.localhost>
Co-committed-by: echosys <echosys@noreply.localhost>
Diffstat (limited to 'src/common/android/id_cache.cpp')
| -rw-r--r-- | src/common/android/id_cache.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/common/android/id_cache.cpp b/src/common/android/id_cache.cpp index 1145cbdf2..94bb5fab6 100644 --- a/src/common/android/id_cache.cpp +++ b/src/common/android/id_cache.cpp @@ -61,6 +61,10 @@ static jclass s_integer_class; static jmethodID s_integer_constructor; static jfieldID s_integer_value_field; +static jclass s_long_class; +static jmethodID s_long_constructor; +static jfieldID s_long_value_field; + static jclass s_boolean_class; static jmethodID s_boolean_constructor; static jfieldID s_boolean_value_field; @@ -288,6 +292,18 @@ jfieldID GetIntegerValueField() { return s_integer_value_field; } +jclass GetLongClass() { + return s_long_class; +} + +jmethodID GetLongConstructor() { + return s_long_constructor; +} + +jfieldID GetLongValueField() { + return s_long_value_field; +} + jclass GetBooleanClass() { return s_boolean_class; } @@ -493,6 +509,12 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved) { s_integer_value_field = env->GetFieldID(int_class, "value", "I"); env->DeleteLocalRef(int_class); + const jclass long_class = env->FindClass("java/lang/Long"); + s_long_class = reinterpret_cast<jclass>(env->NewGlobalRef(long_class)); + s_long_constructor = env->GetMethodID(long_class, "<init>", "(J)V"); + s_long_value_field = env->GetFieldID(long_class, "value", "J"); + env->DeleteLocalRef(long_class); + const jclass boolean_class = env->FindClass("java/lang/Boolean"); s_boolean_class = reinterpret_cast<jclass>(env->NewGlobalRef(boolean_class)); s_boolean_constructor = env->GetMethodID(boolean_class, "<init>", "(Z)V"); |
