java_godot_lib_jni.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533
  1. /**************************************************************************/
  2. /* java_godot_lib_jni.cpp */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /**************************************************************************/
  30. #include "java_godot_lib_jni.h"
  31. #include "android_input_handler.h"
  32. #include "api/java_class_wrapper.h"
  33. #include "api/jni_singleton.h"
  34. #include "dir_access_jandroid.h"
  35. #include "display_server_android.h"
  36. #include "file_access_android.h"
  37. #include "file_access_filesystem_jandroid.h"
  38. #include "java_godot_io_wrapper.h"
  39. #include "java_godot_wrapper.h"
  40. #include "jni_utils.h"
  41. #include "net_socket_android.h"
  42. #include "os_android.h"
  43. #include "string_android.h"
  44. #include "thread_jandroid.h"
  45. #include "tts_android.h"
  46. #include "core/config/engine.h"
  47. #include "core/config/project_settings.h"
  48. #include "core/input/input.h"
  49. #include "main/main.h"
  50. #ifdef TOOLS_ENABLED
  51. #include "editor/editor_settings.h"
  52. #endif
  53. #include <android/asset_manager_jni.h>
  54. #include <android/input.h>
  55. #include <android/native_window_jni.h>
  56. #include <unistd.h>
  57. static JavaClassWrapper *java_class_wrapper = nullptr;
  58. static OS_Android *os_android = nullptr;
  59. static AndroidInputHandler *input_handler = nullptr;
  60. static GodotJavaWrapper *godot_java = nullptr;
  61. static GodotIOJavaWrapper *godot_io_java = nullptr;
  62. static SafeNumeric<int> step; // Shared between UI and render threads
  63. static Size2 new_size;
  64. static Vector3 accelerometer;
  65. static Vector3 gravity;
  66. static Vector3 magnetometer;
  67. static Vector3 gyroscope;
  68. static void _terminate(JNIEnv *env, bool p_restart = false) {
  69. step.set(-1); // Ensure no further steps are attempted and no further events are sent
  70. // lets cleanup
  71. if (java_class_wrapper) {
  72. memdelete(java_class_wrapper);
  73. }
  74. if (input_handler) {
  75. delete input_handler;
  76. }
  77. // Whether restarting is handled by 'Main::cleanup()'
  78. bool restart_on_cleanup = false;
  79. if (os_android) {
  80. restart_on_cleanup = os_android->is_restart_on_exit_set();
  81. os_android->main_loop_end();
  82. Main::cleanup();
  83. delete os_android;
  84. }
  85. if (godot_io_java) {
  86. delete godot_io_java;
  87. }
  88. TTS_Android::terminate();
  89. FileAccessAndroid::terminate();
  90. DirAccessJAndroid::terminate();
  91. FileAccessFilesystemJAndroid::terminate();
  92. NetSocketAndroid::terminate();
  93. if (godot_java) {
  94. if (!restart_on_cleanup) {
  95. if (p_restart) {
  96. godot_java->restart(env);
  97. } else {
  98. godot_java->force_quit(env);
  99. }
  100. }
  101. delete godot_java;
  102. }
  103. }
  104. extern "C" {
  105. JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_setVirtualKeyboardHeight(JNIEnv *env, jclass clazz, jint p_height) {
  106. if (godot_io_java) {
  107. godot_io_java->set_vk_height(p_height);
  108. }
  109. }
  110. JNIEXPORT jboolean JNICALL Java_org_godotengine_godot_GodotLib_initialize(JNIEnv *env, jclass clazz, jobject p_activity, jobject p_godot_instance, jobject p_asset_manager, jobject p_godot_io, jobject p_net_utils, jobject p_directory_access_handler, jobject p_file_access_handler, jboolean p_use_apk_expansion) {
  111. JavaVM *jvm;
  112. env->GetJavaVM(&jvm);
  113. // create our wrapper classes
  114. godot_java = new GodotJavaWrapper(env, p_activity, p_godot_instance);
  115. godot_io_java = new GodotIOJavaWrapper(env, p_godot_io);
  116. init_thread_jandroid(jvm, env);
  117. FileAccessAndroid::setup(p_asset_manager);
  118. DirAccessJAndroid::setup(p_directory_access_handler);
  119. FileAccessFilesystemJAndroid::setup(p_file_access_handler);
  120. NetSocketAndroid::setup(p_net_utils);
  121. os_android = new OS_Android(godot_java, godot_io_java, p_use_apk_expansion);
  122. return true;
  123. }
  124. JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_ondestroy(JNIEnv *env, jclass clazz) {
  125. _terminate(env, false);
  126. }
  127. JNIEXPORT jboolean JNICALL Java_org_godotengine_godot_GodotLib_setup(JNIEnv *env, jclass clazz, jobjectArray p_cmdline, jobject p_godot_tts) {
  128. setup_android_thread();
  129. const char **cmdline = nullptr;
  130. jstring *j_cmdline = nullptr;
  131. int cmdlen = 0;
  132. if (p_cmdline) {
  133. cmdlen = env->GetArrayLength(p_cmdline);
  134. if (cmdlen) {
  135. cmdline = (const char **)memalloc((cmdlen + 1) * sizeof(const char *));
  136. ERR_FAIL_NULL_V_MSG(cmdline, false, "Out of memory.");
  137. cmdline[cmdlen] = nullptr;
  138. j_cmdline = (jstring *)memalloc(cmdlen * sizeof(jstring));
  139. ERR_FAIL_NULL_V_MSG(j_cmdline, false, "Out of memory.");
  140. for (int i = 0; i < cmdlen; i++) {
  141. jstring string = (jstring)env->GetObjectArrayElement(p_cmdline, i);
  142. const char *rawString = env->GetStringUTFChars(string, nullptr);
  143. cmdline[i] = rawString;
  144. j_cmdline[i] = string;
  145. }
  146. }
  147. }
  148. Error err = Main::setup(OS_Android::ANDROID_EXEC_PATH, cmdlen, (char **)cmdline, false);
  149. if (cmdline) {
  150. if (j_cmdline) {
  151. for (int i = 0; i < cmdlen; ++i) {
  152. env->ReleaseStringUTFChars(j_cmdline[i], cmdline[i]);
  153. }
  154. memfree(j_cmdline);
  155. }
  156. memfree(cmdline);
  157. }
  158. // Note: --help and --version return ERR_HELP, but this should be translated to 0 if exit codes are propagated.
  159. if (err != OK) {
  160. return false;
  161. }
  162. TTS_Android::setup(p_godot_tts);
  163. java_class_wrapper = memnew(JavaClassWrapper(godot_java->get_activity()));
  164. GDREGISTER_CLASS(JNISingleton);
  165. return true;
  166. }
  167. JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_resize(JNIEnv *env, jclass clazz, jobject p_surface, jint p_width, jint p_height) {
  168. if (os_android) {
  169. os_android->set_display_size(Size2i(p_width, p_height));
  170. // No need to reset the surface during startup
  171. if (step.get() > 0) {
  172. if (p_surface) {
  173. ANativeWindow *native_window = ANativeWindow_fromSurface(env, p_surface);
  174. os_android->set_native_window(native_window);
  175. }
  176. DisplayServerAndroid::get_singleton()->reset_window();
  177. DisplayServerAndroid::get_singleton()->notify_surface_changed(p_width, p_height);
  178. }
  179. }
  180. }
  181. JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_newcontext(JNIEnv *env, jclass clazz, jobject p_surface) {
  182. if (os_android) {
  183. if (step.get() == 0) {
  184. // During startup
  185. if (p_surface) {
  186. ANativeWindow *native_window = ANativeWindow_fromSurface(env, p_surface);
  187. os_android->set_native_window(native_window);
  188. }
  189. } else {
  190. // Rendering context recreated because it was lost; restart app to let it reload everything
  191. _terminate(env, true);
  192. }
  193. }
  194. }
  195. JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_back(JNIEnv *env, jclass clazz) {
  196. if (step.get() == 0) {
  197. return;
  198. }
  199. if (DisplayServerAndroid *dsa = Object::cast_to<DisplayServerAndroid>(DisplayServer::get_singleton())) {
  200. dsa->send_window_event(DisplayServer::WINDOW_EVENT_GO_BACK_REQUEST);
  201. }
  202. }
  203. JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_ttsCallback(JNIEnv *env, jclass clazz, jint event, jint id, jint pos) {
  204. TTS_Android::_java_utterance_callback(event, id, pos);
  205. }
  206. JNIEXPORT jboolean JNICALL Java_org_godotengine_godot_GodotLib_step(JNIEnv *env, jclass clazz) {
  207. if (step.get() == -1) {
  208. return true;
  209. }
  210. if (step.get() == 0) {
  211. // Since Godot is initialized on the UI thread, main_thread_id was set to that thread's id,
  212. // but for Godot purposes, the main thread is the one running the game loop
  213. Main::setup2();
  214. input_handler = new AndroidInputHandler();
  215. step.increment();
  216. return true;
  217. }
  218. if (step.get() == 1) {
  219. if (Main::start() != EXIT_SUCCESS) {
  220. return true; // should exit instead and print the error
  221. }
  222. godot_java->on_godot_setup_completed(env);
  223. os_android->main_loop_begin();
  224. godot_java->on_godot_main_loop_started(env);
  225. step.increment();
  226. }
  227. DisplayServerAndroid::get_singleton()->process_accelerometer(accelerometer);
  228. DisplayServerAndroid::get_singleton()->process_gravity(gravity);
  229. DisplayServerAndroid::get_singleton()->process_magnetometer(magnetometer);
  230. DisplayServerAndroid::get_singleton()->process_gyroscope(gyroscope);
  231. bool should_swap_buffers = false;
  232. if (os_android->main_loop_iterate(&should_swap_buffers)) {
  233. _terminate(env, false);
  234. }
  235. return should_swap_buffers;
  236. }
  237. // Called on the UI thread
  238. JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_dispatchMouseEvent(JNIEnv *env, jclass clazz, jint p_event_type, jint p_button_mask, jfloat p_x, jfloat p_y, jfloat p_delta_x, jfloat p_delta_y, jboolean p_double_click, jboolean p_source_mouse_relative, jfloat p_pressure, jfloat p_tilt_x, jfloat p_tilt_y) {
  239. if (step.get() <= 0) {
  240. return;
  241. }
  242. input_handler->process_mouse_event(p_event_type, p_button_mask, Point2(p_x, p_y), Vector2(p_delta_x, p_delta_y), p_double_click, p_source_mouse_relative, p_pressure, Vector2(p_tilt_x, p_tilt_y));
  243. }
  244. // Called on the UI thread
  245. JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_dispatchTouchEvent(JNIEnv *env, jclass clazz, jint ev, jint pointer, jint pointer_count, jfloatArray position, jboolean p_double_tap) {
  246. if (step.get() <= 0) {
  247. return;
  248. }
  249. Vector<AndroidInputHandler::TouchPos> points;
  250. for (int i = 0; i < pointer_count; i++) {
  251. jfloat p[3];
  252. env->GetFloatArrayRegion(position, i * 3, 3, p);
  253. AndroidInputHandler::TouchPos tp;
  254. tp.pos = Point2(p[1], p[2]);
  255. tp.id = (int)p[0];
  256. points.push_back(tp);
  257. }
  258. input_handler->process_touch_event(ev, pointer, points, p_double_tap);
  259. }
  260. // Called on the UI thread
  261. JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_magnify(JNIEnv *env, jclass clazz, jfloat p_x, jfloat p_y, jfloat p_factor) {
  262. if (step.get() <= 0) {
  263. return;
  264. }
  265. input_handler->process_magnify(Point2(p_x, p_y), p_factor);
  266. }
  267. // Called on the UI thread
  268. JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_pan(JNIEnv *env, jclass clazz, jfloat p_x, jfloat p_y, jfloat p_delta_x, jfloat p_delta_y) {
  269. if (step.get() <= 0) {
  270. return;
  271. }
  272. input_handler->process_pan(Point2(p_x, p_y), Vector2(p_delta_x, p_delta_y));
  273. }
  274. // Called on the UI thread
  275. JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joybutton(JNIEnv *env, jclass clazz, jint p_device, jint p_button, jboolean p_pressed) {
  276. if (step.get() <= 0) {
  277. return;
  278. }
  279. AndroidInputHandler::JoypadEvent jevent;
  280. jevent.device = p_device;
  281. jevent.type = AndroidInputHandler::JOY_EVENT_BUTTON;
  282. jevent.index = p_button;
  283. jevent.pressed = p_pressed;
  284. input_handler->process_joy_event(jevent);
  285. }
  286. // Called on the UI thread
  287. JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joyaxis(JNIEnv *env, jclass clazz, jint p_device, jint p_axis, jfloat p_value) {
  288. if (step.get() <= 0) {
  289. return;
  290. }
  291. AndroidInputHandler::JoypadEvent jevent;
  292. jevent.device = p_device;
  293. jevent.type = AndroidInputHandler::JOY_EVENT_AXIS;
  294. jevent.index = p_axis;
  295. jevent.value = p_value;
  296. input_handler->process_joy_event(jevent);
  297. }
  298. // Called on the UI thread
  299. JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joyhat(JNIEnv *env, jclass clazz, jint p_device, jint p_hat_x, jint p_hat_y) {
  300. if (step.get() <= 0) {
  301. return;
  302. }
  303. AndroidInputHandler::JoypadEvent jevent;
  304. jevent.device = p_device;
  305. jevent.type = AndroidInputHandler::JOY_EVENT_HAT;
  306. BitField<HatMask> hat;
  307. if (p_hat_x != 0) {
  308. if (p_hat_x < 0) {
  309. hat.set_flag(HatMask::LEFT);
  310. } else {
  311. hat.set_flag(HatMask::RIGHT);
  312. }
  313. }
  314. if (p_hat_y != 0) {
  315. if (p_hat_y < 0) {
  316. hat.set_flag(HatMask::UP);
  317. } else {
  318. hat.set_flag(HatMask::DOWN);
  319. }
  320. }
  321. jevent.hat = hat;
  322. input_handler->process_joy_event(jevent);
  323. }
  324. // Called on the UI thread
  325. JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joyconnectionchanged(JNIEnv *env, jclass clazz, jint p_device, jboolean p_connected, jstring p_name) {
  326. if (os_android) {
  327. String name = jstring_to_string(p_name, env);
  328. Input::get_singleton()->joy_connection_changed(p_device, p_connected, name);
  329. }
  330. }
  331. // Called on the UI thread
  332. JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_key(JNIEnv *env, jclass clazz, jint p_physical_keycode, jint p_unicode, jint p_key_label, jboolean p_pressed, jboolean p_echo) {
  333. if (step.get() <= 0) {
  334. return;
  335. }
  336. input_handler->process_key_event(p_physical_keycode, p_unicode, p_key_label, p_pressed, p_echo);
  337. }
  338. JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_accelerometer(JNIEnv *env, jclass clazz, jfloat x, jfloat y, jfloat z) {
  339. accelerometer = Vector3(x, y, z);
  340. }
  341. JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_gravity(JNIEnv *env, jclass clazz, jfloat x, jfloat y, jfloat z) {
  342. gravity = Vector3(x, y, z);
  343. }
  344. JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_magnetometer(JNIEnv *env, jclass clazz, jfloat x, jfloat y, jfloat z) {
  345. magnetometer = Vector3(x, y, z);
  346. }
  347. JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_gyroscope(JNIEnv *env, jclass clazz, jfloat x, jfloat y, jfloat z) {
  348. gyroscope = Vector3(x, y, z);
  349. }
  350. JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_focusin(JNIEnv *env, jclass clazz) {
  351. if (step.get() <= 0) {
  352. return;
  353. }
  354. os_android->main_loop_focusin();
  355. }
  356. JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_focusout(JNIEnv *env, jclass clazz) {
  357. if (step.get() <= 0) {
  358. return;
  359. }
  360. os_android->main_loop_focusout();
  361. }
  362. JNIEXPORT jstring JNICALL Java_org_godotengine_godot_GodotLib_getGlobal(JNIEnv *env, jclass clazz, jstring path) {
  363. String js = jstring_to_string(path, env);
  364. return env->NewStringUTF(GLOBAL_GET(js).operator String().utf8().get_data());
  365. }
  366. JNIEXPORT jstring JNICALL Java_org_godotengine_godot_GodotLib_getEditorSetting(JNIEnv *env, jclass clazz, jstring p_setting_key) {
  367. String editor_setting = "";
  368. #ifdef TOOLS_ENABLED
  369. String godot_setting_key = jstring_to_string(p_setting_key, env);
  370. editor_setting = EDITOR_GET(godot_setting_key).operator String();
  371. #else
  372. WARN_PRINT("Access to the Editor Settings in only available on Editor builds");
  373. #endif
  374. return env->NewStringUTF(editor_setting.utf8().get_data());
  375. }
  376. JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_callobject(JNIEnv *env, jclass clazz, jlong ID, jstring method, jobjectArray params) {
  377. Object *obj = ObjectDB::get_instance(ObjectID(ID));
  378. ERR_FAIL_NULL(obj);
  379. String str_method = jstring_to_string(method, env);
  380. int count = env->GetArrayLength(params);
  381. Variant *vlist = (Variant *)alloca(sizeof(Variant) * count);
  382. const Variant **vptr = (const Variant **)alloca(sizeof(Variant *) * count);
  383. for (int i = 0; i < count; i++) {
  384. jobject jobj = env->GetObjectArrayElement(params, i);
  385. ERR_FAIL_NULL(jobj);
  386. memnew_placement(&vlist[i], Variant(_jobject_to_variant(env, jobj)));
  387. vptr[i] = &vlist[i];
  388. env->DeleteLocalRef(jobj);
  389. }
  390. Callable::CallError err;
  391. obj->callp(str_method, vptr, count, err);
  392. }
  393. JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_calldeferred(JNIEnv *env, jclass clazz, jlong ID, jstring method, jobjectArray params) {
  394. Object *obj = ObjectDB::get_instance(ObjectID(ID));
  395. ERR_FAIL_NULL(obj);
  396. String str_method = jstring_to_string(method, env);
  397. int count = env->GetArrayLength(params);
  398. Variant *args = (Variant *)alloca(sizeof(Variant) * count);
  399. const Variant **argptrs = (const Variant **)alloca(sizeof(Variant *) * count);
  400. for (int i = 0; i < count; i++) {
  401. jobject jobj = env->GetObjectArrayElement(params, i);
  402. ERR_FAIL_NULL(jobj);
  403. memnew_placement(&args[i], Variant(_jobject_to_variant(env, jobj)));
  404. argptrs[i] = &args[i];
  405. env->DeleteLocalRef(jobj);
  406. }
  407. Callable(obj, str_method).call_deferredp(argptrs, count);
  408. }
  409. JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_onNightModeChanged(JNIEnv *env, jclass clazz) {
  410. DisplayServerAndroid *ds = (DisplayServerAndroid *)DisplayServer::get_singleton();
  411. if (ds) {
  412. ds->emit_system_theme_changed();
  413. }
  414. }
  415. JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_requestPermissionResult(JNIEnv *env, jclass clazz, jstring p_permission, jboolean p_result) {
  416. String permission = jstring_to_string(p_permission, env);
  417. if (permission == "android.permission.RECORD_AUDIO" && p_result) {
  418. AudioDriver::get_singleton()->input_start();
  419. }
  420. if (os_android->get_main_loop()) {
  421. os_android->get_main_loop()->emit_signal(SNAME("on_request_permissions_result"), permission, p_result == JNI_TRUE);
  422. }
  423. }
  424. JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_onRendererResumed(JNIEnv *env, jclass clazz) {
  425. if (step.get() <= 0) {
  426. return;
  427. }
  428. // We force redraw to ensure we render at least once when resuming the app.
  429. Main::force_redraw();
  430. if (os_android->get_main_loop()) {
  431. os_android->get_main_loop()->notification(MainLoop::NOTIFICATION_APPLICATION_RESUMED);
  432. }
  433. }
  434. JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_onRendererPaused(JNIEnv *env, jclass clazz) {
  435. if (step.get() <= 0) {
  436. return;
  437. }
  438. if (os_android->get_main_loop()) {
  439. os_android->get_main_loop()->notification(MainLoop::NOTIFICATION_APPLICATION_PAUSED);
  440. }
  441. }
  442. }