Skip to content

Commit

Permalink
feat(android): update jni to 0.21 (#776)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog committed Aug 8, 2023
1 parent 0f3b0ed commit 06b617e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changes/jni-0.21.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tao": minor
---

Update jni to 0.21.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions src/platform_impl/android/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
};
Expand Down Expand Up @@ -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(
Expand All @@ -818,7 +818,7 @@ impl MonitorHandle {
.l()
.unwrap();
let width = env
.call_method(rect, "width", "()I", &[])
.call_method(&rect, "width", "()I", &[])
.unwrap()
.i()
.unwrap();
Expand Down
6 changes: 3 additions & 3 deletions src/platform_impl/android/ndk_glue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -163,7 +163,7 @@ pub unsafe fn create(
// Initialize global context
let window_manager = env
.call_method(
jobject,
&jobject,
"getWindowManager",
"()Landroid/view/WindowManager;",
&[],
Expand All @@ -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();
Expand Down

0 comments on commit 06b617e

Please sign in to comment.