From 087a3144140b21ae9064001b42c3bba4c7e4e1a5 Mon Sep 17 00:00:00 2001 From: Lucas Nogueira Date: Tue, 8 Aug 2023 16:54:52 -0300 Subject: [PATCH] feat(android): update jni to 0.21 --- .changes/jni-0.21.md | 5 +++++ Cargo.toml | 2 +- src/platform_impl/android/mod.rs | 6 +++--- src/platform_impl/android/ndk_glue.rs | 6 +++--- 4 files changed, 12 insertions(+), 7 deletions(-) create mode 100644 .changes/jni-0.21.md diff --git a/.changes/jni-0.21.md b/.changes/jni-0.21.md new file mode 100644 index 000000000..e92e0916d --- /dev/null +++ b/.changes/jni-0.21.md @@ -0,0 +1,5 @@ +--- +"tao": minor +--- + +Update jni to 0.21. diff --git a/Cargo.toml b/Cargo.toml index 0d8a2d88f..1b23ad26a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -53,7 +53,7 @@ image = "0.24" env_logger = "0.10" [target."cfg(target_os = \"android\")".dependencies] -jni = "0.20" +jni = "0.21" ndk = "0.7" ndk-sys = "0.4" ndk-context = "0.1" diff --git a/src/platform_impl/android/mod.rs b/src/platform_impl/android/mod.rs index 198af776b..ae5b590f0 100644 --- a/src/platform_impl/android/mod.rs +++ b/src/platform_impl/android/mod.rs @@ -751,7 +751,7 @@ impl Window { // TODO: Use main activity instead? let mut handle = AndroidNdkWindowHandle::empty(); if let Some(w) = ndk_glue::window_manager() { - handle.a_native_window = w.as_obj().into_raw() as *mut _; + handle.a_native_window = w.as_obj().as_raw() as *mut _; } else { panic!("Cannot get the native window, it's null and will always be null before Event::Resumed and after Event::Suspended. Make sure you only call this function between those events."); }; @@ -800,7 +800,7 @@ impl MonitorHandle { if let Some(w) = ndk_glue::window_manager() { let ctx = ndk_context::android_context(); let vm = unsafe { jni::JavaVM::from_raw(ctx.vm().cast()) }.unwrap(); - let env = vm.attach_current_thread().unwrap(); + let mut env = vm.attach_current_thread().unwrap(); let window_manager = w.as_obj(); let metrics = env .call_method( @@ -818,7 +818,7 @@ impl MonitorHandle { .l() .unwrap(); let width = env - .call_method(rect, "width", "()I", &[]) + .call_method(&rect, "width", "()I", &[]) .unwrap() .i() .unwrap(); diff --git a/src/platform_impl/android/ndk_glue.rs b/src/platform_impl/android/ndk_glue.rs index ab125bfb3..384eff926 100644 --- a/src/platform_impl/android/ndk_glue.rs +++ b/src/platform_impl/android/ndk_glue.rs @@ -153,7 +153,7 @@ pub enum Event { } pub unsafe fn create( - env: JNIEnv, + mut env: JNIEnv, _jclass: JClass, jobject: JObject, setup: unsafe fn(JNIEnv, &ForeignLooper, GlobalRef), @@ -163,7 +163,7 @@ pub unsafe fn create( // Initialize global context let window_manager = env .call_method( - jobject, + &jobject, "getWindowManager", "()Landroid/view/WindowManager;", &[], @@ -178,7 +178,7 @@ pub unsafe fn create( let env = vm.attach_current_thread_as_daemon().unwrap(); ndk_context::initialize_android_context( vm.get_java_vm_pointer() as *mut _, - activity.as_obj().into_raw() as *mut _, + activity.as_obj().as_raw() as *mut _, ); let looper = ThreadLooper::for_thread().unwrap().into_foreign();