[ion/simulator/android] Add assert, remove TODO

Change-Id: Id818d0cd9a83727171ebe675ee50e35ef64e31d0
This commit is contained in:
Hugo Saint-Vignes
2021-02-05 17:47:29 +01:00
parent 5a20d914df
commit 73172f8d0c

View File

@@ -1,6 +1,7 @@
#include "../../../shared/haptics.h"
#include <jni.h>
#include <SDL.h>
#include <assert.h>
namespace Ion {
namespace Simulator {
@@ -10,11 +11,8 @@ bool isEnabled() {
JNIEnv * env = static_cast<JNIEnv *>(SDL_AndroidGetJNIEnv());
jobject activity = static_cast<jobject>(SDL_AndroidGetActivity());
jclass j_class = env->FindClass("com/numworks/calculator/EpsilonActivity");
// TODO : GetMethodID is relatively costly, and could be performed only once.
jmethodID j_methodId = env->GetMethodID(j_class,"hapticFeedbackIsEnabled", "()Z");
if (j_methodId == 0) {
return false;
}
assert(j_methodId != 0);
bool result = (env->CallBooleanMethod(activity, j_methodId) != JNI_FALSE);
/* Local references are automatically deleted if a native function called from
* Java side returns. For SDL this native function is main() itself. Therefore