java_godot_lib_jni.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526
  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 "java_godot_io_wrapper.h"
  32. #include "java_godot_wrapper.h"
  33. #include "android/asset_manager_jni.h"
  34. #include "android_input_handler.h"
  35. #include "api/java_class_wrapper.h"
  36. #include "api/jni_singleton.h"
  37. #include "core/engine.h"
  38. #include "core/project_settings.h"
  39. #include "dir_access_jandroid.h"
  40. #include "file_access_android.h"
  41. #include "file_access_filesystem_jandroid.h"
  42. #include "jni_utils.h"
  43. #include "main/input_default.h"
  44. #include "main/main.h"
  45. #include "net_socket_android.h"
  46. #include "os_android.h"
  47. #include "string_android.h"
  48. #include "thread_jandroid.h"
  49. #include <android/input.h>
  50. #include <unistd.h>
  51. static JavaClassWrapper *java_class_wrapper = nullptr;
  52. static OS_Android *os_android = nullptr;
  53. static AndroidInputHandler *input_handler = nullptr;
  54. static GodotJavaWrapper *godot_java = nullptr;
  55. static GodotIOJavaWrapper *godot_io_java = nullptr;
  56. static SafeNumeric<int> step; // Shared between UI and render threads
  57. static Size2 new_size;
  58. static Vector3 accelerometer;
  59. static Vector3 gravity;
  60. static Vector3 magnetometer;
  61. static Vector3 gyroscope;
  62. static void _initialize_java_modules() {
  63. if (!ProjectSettings::get_singleton()->has_setting("android/modules")) {
  64. return;
  65. }
  66. String modules = ProjectSettings::get_singleton()->get("android/modules");
  67. modules = modules.strip_edges();
  68. if (modules == String()) {
  69. return;
  70. }
  71. Vector<String> mods = modules.split(",", false);
  72. if (mods.size()) {
  73. jobject cls = godot_java->get_class_loader();
  74. // TODO create wrapper for class loader
  75. JNIEnv *env = get_jni_env();
  76. jclass classLoader = env->FindClass("java/lang/ClassLoader");
  77. jmethodID findClass = env->GetMethodID(classLoader, "loadClass", "(Ljava/lang/String;)Ljava/lang/Class;");
  78. for (int i = 0; i < mods.size(); i++) {
  79. String m = mods[i];
  80. // Deprecated in Godot 3.2.2, it's now a plugin to enable in export preset.
  81. if (m == "org/godotengine/godot/GodotPaymentV3") {
  82. WARN_PRINT("GodotPaymentV3 is deprecated and is replaced by the 'GodotPayment' plugin, which should be enabled in the Android export preset.");
  83. print_line("Skipping Android module: " + m);
  84. continue;
  85. }
  86. print_line("Loading Android module: " + m);
  87. jstring strClassName = env->NewStringUTF(m.utf8().get_data());
  88. jclass singletonClass = (jclass)env->CallObjectMethod(cls, findClass, strClassName);
  89. ERR_CONTINUE_MSG(!singletonClass, "Couldn't find singleton for class: " + m + ".");
  90. jmethodID initialize = env->GetStaticMethodID(singletonClass, "initialize", "(Landroid/app/Activity;)Lorg/godotengine/godot/Godot$SingletonBase;");
  91. ERR_CONTINUE_MSG(!initialize, "Couldn't find proper initialize function 'public static Godot.SingletonBase Class::initialize(Activity p_activity)' initializer for singleton class: " + m + ".");
  92. jobject obj = env->CallStaticObjectMethod(singletonClass, initialize, godot_java->get_activity());
  93. env->NewGlobalRef(obj);
  94. }
  95. }
  96. }
  97. extern "C" {
  98. JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_setVirtualKeyboardHeight(JNIEnv *env, jclass clazz, jint p_height) {
  99. if (godot_io_java) {
  100. godot_io_java->set_vk_height(p_height);
  101. }
  102. }
  103. JNIEXPORT void 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) {
  104. JavaVM *jvm;
  105. env->GetJavaVM(&jvm);
  106. // create our wrapper classes
  107. godot_java = new GodotJavaWrapper(env, p_activity, p_godot_instance);
  108. godot_io_java = new GodotIOJavaWrapper(env, p_godot_io);
  109. init_thread_jandroid(jvm, env);
  110. jobject amgr = env->NewGlobalRef(p_asset_manager);
  111. FileAccessAndroid::asset_manager = AAssetManager_fromJava(env, amgr);
  112. DirAccessJAndroid::setup(p_directory_access_handler);
  113. FileAccessFilesystemJAndroid::setup(p_file_access_handler);
  114. NetSocketAndroid::setup(p_net_utils);
  115. os_android = new OS_Android(godot_java, godot_io_java, p_use_apk_expansion);
  116. godot_java->on_video_init(env);
  117. }
  118. JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_ondestroy(JNIEnv *env, jclass clazz) {
  119. // lets cleanup
  120. if (java_class_wrapper) {
  121. memdelete(java_class_wrapper);
  122. }
  123. if (godot_io_java) {
  124. delete godot_io_java;
  125. }
  126. if (godot_java) {
  127. godot_java->destroy_offscreen_gl(env);
  128. delete godot_java;
  129. }
  130. if (input_handler) {
  131. delete input_handler;
  132. }
  133. if (os_android) {
  134. os_android->main_loop_end();
  135. delete os_android;
  136. }
  137. }
  138. JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_setup(JNIEnv *env, jclass clazz, jobjectArray p_cmdline) {
  139. setup_android_thread();
  140. const char **cmdline = nullptr;
  141. jstring *j_cmdline = nullptr;
  142. int cmdlen = 0;
  143. if (p_cmdline) {
  144. cmdlen = env->GetArrayLength(p_cmdline);
  145. if (cmdlen) {
  146. cmdline = (const char **)memalloc((cmdlen + 1) * sizeof(const char *));
  147. ERR_FAIL_NULL_MSG(cmdline, "Out of memory.");
  148. cmdline[cmdlen] = nullptr;
  149. j_cmdline = (jstring *)memalloc(cmdlen * sizeof(jstring));
  150. ERR_FAIL_NULL_MSG(j_cmdline, "Out of memory.");
  151. for (int i = 0; i < cmdlen; i++) {
  152. jstring string = (jstring)env->GetObjectArrayElement(p_cmdline, i);
  153. const char *rawString = env->GetStringUTFChars(string, nullptr);
  154. cmdline[i] = rawString;
  155. j_cmdline[i] = string;
  156. }
  157. }
  158. }
  159. Error err = Main::setup(OS_Android::ANDROID_EXEC_PATH, cmdlen, (char **)cmdline, false);
  160. if (cmdline) {
  161. if (j_cmdline) {
  162. for (int i = 0; i < cmdlen; ++i) {
  163. env->ReleaseStringUTFChars(j_cmdline[i], cmdline[i]);
  164. }
  165. memfree(j_cmdline);
  166. }
  167. memfree(cmdline);
  168. }
  169. // Note: --help and --version return ERR_HELP, but this should be translated to 0 if exit codes are propagated.
  170. if (err != OK) {
  171. return; // should exit instead and print the error
  172. }
  173. java_class_wrapper = memnew(JavaClassWrapper(godot_java->get_activity()));
  174. ClassDB::register_class<JNISingleton>();
  175. _initialize_java_modules();
  176. }
  177. JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_resize(JNIEnv *env, jclass clazz, jint width, jint height) {
  178. if (os_android) {
  179. os_android->set_display_size(Size2(width, height));
  180. }
  181. }
  182. JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_newcontext(JNIEnv *env, jclass clazz) {
  183. if (os_android) {
  184. if (step.get() == 0) {
  185. // During startup
  186. os_android->set_offscreen_gl_available(godot_java->create_offscreen_gl(env));
  187. } else {
  188. // GL context recreated because it was lost; restart app to let it reload everything
  189. step.set(-1); // Ensure no further steps are attempted and no further events are sent
  190. os_android->main_loop_end();
  191. godot_java->restart(env);
  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 (os_android->get_main_loop()) {
  200. os_android->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_GO_BACK_REQUEST);
  201. }
  202. }
  203. JNIEXPORT jboolean JNICALL Java_org_godotengine_godot_GodotLib_step(JNIEnv *env, jclass clazz) {
  204. if (step.get() == -1) {
  205. return true;
  206. }
  207. if (step.get() == 0) {
  208. // Since Godot is initialized on the UI thread, _main_thread_id was set to that thread's id,
  209. // but for Godot purposes, the main thread is the one running the game loop
  210. Main::setup2(Thread::get_caller_id());
  211. input_handler = new AndroidInputHandler();
  212. step.increment();
  213. return true;
  214. }
  215. if (step.get() == 1) {
  216. if (!Main::start()) {
  217. return true; // should exit instead and print the error
  218. }
  219. godot_java->on_godot_setup_completed(env);
  220. os_android->main_loop_begin();
  221. godot_java->on_godot_main_loop_started(env);
  222. step.increment();
  223. }
  224. os_android->process_accelerometer(accelerometer);
  225. os_android->process_gravity(gravity);
  226. os_android->process_magnetometer(magnetometer);
  227. os_android->process_gyroscope(gyroscope);
  228. bool should_swap_buffers = false;
  229. if (os_android->main_loop_iterate(&should_swap_buffers)) {
  230. godot_java->force_quit(env);
  231. }
  232. return should_swap_buffers;
  233. }
  234. void touch_preprocessing(JNIEnv *env, jclass clazz, jint input_device, jint ev, jint pointer, jint pointer_count, jfloatArray positions, jint buttons_mask, jfloat vertical_factor, jfloat horizontal_factor) {
  235. if (step.get() <= 0) {
  236. return;
  237. }
  238. Vector<AndroidInputHandler::TouchPos> points;
  239. for (int i = 0; i < pointer_count; i++) {
  240. jfloat p[3];
  241. env->GetFloatArrayRegion(positions, i * 3, 3, p);
  242. AndroidInputHandler::TouchPos tp;
  243. tp.pos = Point2(p[1], p[2]);
  244. tp.id = (int)p[0];
  245. points.push_back(tp);
  246. }
  247. if ((input_device & AINPUT_SOURCE_MOUSE) == AINPUT_SOURCE_MOUSE) {
  248. input_handler->process_mouse_event(ev, buttons_mask, points[0].pos, vertical_factor, horizontal_factor);
  249. } else {
  250. input_handler->process_touch(ev, pointer, points);
  251. }
  252. }
  253. // Called on the UI thread
  254. JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_touch__IIII_3F(JNIEnv *env, jclass clazz, jint input_device, jint ev, jint pointer, jint pointer_count, jfloatArray position) {
  255. touch_preprocessing(env, clazz, input_device, ev, pointer, pointer_count, position);
  256. }
  257. // Called on the UI thread
  258. JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_touch__IIII_3FI(JNIEnv *env, jclass clazz, jint input_device, jint ev, jint pointer, jint pointer_count, jfloatArray position, jint buttons_mask) {
  259. touch_preprocessing(env, clazz, input_device, ev, pointer, pointer_count, position, buttons_mask);
  260. }
  261. // Called on the UI thread
  262. JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_touch__IIII_3FIFF(JNIEnv *env, jclass clazz, jint input_device, jint ev, jint pointer, jint pointer_count, jfloatArray position, jint buttons_mask, jfloat vertical_factor, jfloat horizontal_factor) {
  263. touch_preprocessing(env, clazz, input_device, ev, pointer, pointer_count, position, buttons_mask, vertical_factor, horizontal_factor);
  264. }
  265. // Called on the UI thread
  266. JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_hover(JNIEnv *env, jclass clazz, jint p_type, jfloat p_x, jfloat p_y) {
  267. if (step.get() <= 0) {
  268. return;
  269. }
  270. input_handler->process_hover(p_type, Point2(p_x, p_y));
  271. }
  272. // Called on the UI thread
  273. JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_doubleTap(JNIEnv *env, jclass clazz, jint p_button_mask, jint p_x, jint p_y) {
  274. if (step.get() <= 0) {
  275. return;
  276. }
  277. input_handler->process_double_tap(p_button_mask, Point2(p_x, p_y));
  278. }
  279. // Called on the UI thread
  280. JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joybutton(JNIEnv *env, jclass clazz, jint p_device, jint p_button, jboolean p_pressed) {
  281. if (step.get() <= 0) {
  282. return;
  283. }
  284. AndroidInputHandler::JoypadEvent jevent;
  285. jevent.device = p_device;
  286. jevent.type = AndroidInputHandler::JOY_EVENT_BUTTON;
  287. jevent.index = p_button;
  288. jevent.pressed = p_pressed;
  289. input_handler->process_joy_event(jevent);
  290. }
  291. // Called on the UI thread
  292. JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joyaxis(JNIEnv *env, jclass clazz, jint p_device, jint p_axis, jfloat p_value) {
  293. if (step.get() <= 0) {
  294. return;
  295. }
  296. AndroidInputHandler::JoypadEvent jevent;
  297. jevent.device = p_device;
  298. jevent.type = AndroidInputHandler::JOY_EVENT_AXIS;
  299. jevent.index = p_axis;
  300. jevent.value = p_value;
  301. input_handler->process_joy_event(jevent);
  302. }
  303. // Called on the UI thread
  304. JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joyhat(JNIEnv *env, jclass clazz, jint p_device, jint p_hat_x, jint p_hat_y) {
  305. if (step.get() <= 0) {
  306. return;
  307. }
  308. AndroidInputHandler::JoypadEvent jevent;
  309. jevent.device = p_device;
  310. jevent.type = AndroidInputHandler::JOY_EVENT_HAT;
  311. int hat = 0;
  312. if (p_hat_x != 0) {
  313. if (p_hat_x < 0) {
  314. hat |= InputDefault::HAT_MASK_LEFT;
  315. } else {
  316. hat |= InputDefault::HAT_MASK_RIGHT;
  317. }
  318. }
  319. if (p_hat_y != 0) {
  320. if (p_hat_y < 0) {
  321. hat |= InputDefault::HAT_MASK_UP;
  322. } else {
  323. hat |= InputDefault::HAT_MASK_DOWN;
  324. }
  325. }
  326. jevent.hat = hat;
  327. input_handler->process_joy_event(jevent);
  328. }
  329. // Called on the UI thread
  330. JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joyconnectionchanged(JNIEnv *env, jclass clazz, jint p_device, jboolean p_connected, jstring p_name) {
  331. if (step.get() <= 0) {
  332. return;
  333. }
  334. String name = jstring_to_string(p_name, env);
  335. input_handler->joy_connection_changed(p_device, p_connected, name);
  336. }
  337. // Called on the UI thread
  338. JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_key(JNIEnv *env, jclass clazz, jint p_keycode, jint p_scancode, jint p_unicode_char, jboolean p_pressed) {
  339. if (step.get() <= 0) {
  340. return;
  341. }
  342. input_handler->process_key_event(p_keycode, p_scancode, p_unicode_char, p_pressed);
  343. }
  344. JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_accelerometer(JNIEnv *env, jclass clazz, jfloat x, jfloat y, jfloat z) {
  345. accelerometer = Vector3(x, y, z);
  346. }
  347. JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_gravity(JNIEnv *env, jclass clazz, jfloat x, jfloat y, jfloat z) {
  348. gravity = Vector3(x, y, z);
  349. }
  350. JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_magnetometer(JNIEnv *env, jclass clazz, jfloat x, jfloat y, jfloat z) {
  351. magnetometer = Vector3(x, y, z);
  352. }
  353. JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_gyroscope(JNIEnv *env, jclass clazz, jfloat x, jfloat y, jfloat z) {
  354. gyroscope = Vector3(x, y, z);
  355. }
  356. JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_focusin(JNIEnv *env, jclass clazz) {
  357. if (step.get() <= 0) {
  358. return;
  359. }
  360. os_android->main_loop_focusin();
  361. }
  362. JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_focusout(JNIEnv *env, jclass clazz) {
  363. if (step.get() <= 0) {
  364. return;
  365. }
  366. os_android->main_loop_focusout();
  367. }
  368. JNIEXPORT jstring JNICALL Java_org_godotengine_godot_GodotLib_getGlobal(JNIEnv *env, jclass clazz, jstring path) {
  369. String js = jstring_to_string(path, env);
  370. return env->NewStringUTF(ProjectSettings::get_singleton()->get(js).operator String().utf8().get_data());
  371. }
  372. JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_callobject(JNIEnv *env, jclass clazz, jlong ID, jstring method, jobjectArray params) {
  373. Object *obj = ObjectDB::get_instance(ID);
  374. ERR_FAIL_NULL(obj);
  375. int res = env->PushLocalFrame(16);
  376. ERR_FAIL_COND(res != 0);
  377. String str_method = jstring_to_string(method, env);
  378. int count = env->GetArrayLength(params);
  379. Variant *vlist = (Variant *)alloca(sizeof(Variant) * count);
  380. Variant **vptr = (Variant **)alloca(sizeof(Variant *) * count);
  381. for (int i = 0; i < count; i++) {
  382. jobject jobj = env->GetObjectArrayElement(params, i);
  383. Variant v;
  384. if (jobj) {
  385. v = _jobject_to_variant(env, jobj);
  386. }
  387. memnew_placement(&vlist[i], Variant);
  388. vlist[i] = v;
  389. vptr[i] = &vlist[i];
  390. env->DeleteLocalRef(jobj);
  391. }
  392. Variant::CallError err;
  393. obj->call(str_method, (const Variant **)vptr, count, err);
  394. env->PopLocalFrame(nullptr);
  395. }
  396. JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_calldeferred(JNIEnv *env, jclass clazz, jlong ID, jstring method, jobjectArray params) {
  397. Object *obj = ObjectDB::get_instance(ID);
  398. ERR_FAIL_NULL(obj);
  399. int res = env->PushLocalFrame(16);
  400. ERR_FAIL_COND(res != 0);
  401. String str_method = jstring_to_string(method, env);
  402. int count = env->GetArrayLength(params);
  403. Variant args[VARIANT_ARG_MAX];
  404. for (int i = 0; i < MIN(count, VARIANT_ARG_MAX); i++) {
  405. jobject jobj = env->GetObjectArrayElement(params, i);
  406. if (jobj) {
  407. args[i] = _jobject_to_variant(env, jobj);
  408. }
  409. env->DeleteLocalRef(jobj);
  410. }
  411. static_assert(VARIANT_ARG_MAX == 8, "This code needs to be updated if VARIANT_ARG_MAX != 8");
  412. obj->call_deferred(str_method, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]);
  413. env->PopLocalFrame(nullptr);
  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()->capture_start();
  419. }
  420. if (os_android->get_main_loop()) {
  421. os_android->get_main_loop()->emit_signal("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_APP_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_APP_PAUSED);
  440. }
  441. }
  442. }