From 499d09595b6ff41d00dd35afae8c04acc4dfccc6 Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Sat, 24 Jun 2023 00:45:43 +0200 Subject: [PATCH] Upgrade to `ndk-sys 0.5.0-beta.0`, `ndk-0.8.0 beta.0` --- Cargo.toml | 8 ++------ android-activity/Cargo.toml | 4 ++-- android-activity/src/lib.rs | 4 ++-- android-activity/src/native_activity/glue.rs | 13 ++++++------- android-activity/src/native_activity/mod.rs | 6 +++--- examples/agdk-mainloop/Cargo.toml | 4 ++-- examples/na-mainloop/Cargo.toml | 6 +++--- 7 files changed, 20 insertions(+), 25 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index fc8008d..95c8a86 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,8 +1,4 @@ [workspace] -members = [ - "android-activity" -] +members = ["android-activity"] -exclude = [ - "examples", -] +exclude = ["examples"] diff --git a/android-activity/Cargo.toml b/android-activity/Cargo.toml index a9abcde..bb5310f 100644 --- a/android-activity/Cargo.toml +++ b/android-activity/Cargo.toml @@ -39,8 +39,8 @@ log = "0.4" jni-sys = "0.3" cesu8 = "1" jni = "0.21" -ndk = "0.7" -ndk-sys = "0.4" +ndk-sys = "0.5.0-beta.0" +ndk = "0.8.0-beta.0" ndk-context = "0.1" android-properties = "0.2" num_enum = "0.7" diff --git a/android-activity/src/lib.rs b/android-activity/src/lib.rs index 8b9c46e..cbbe7d2 100644 --- a/android-activity/src/lib.rs +++ b/android-activity/src/lib.rs @@ -537,14 +537,14 @@ impl AndroidApp { /// [`ALooper_pollAll`]: ndk::looper::ThreadLooper::poll_all pub fn poll_events(&self, timeout: Option, callback: F) where - F: FnMut(PollEvent), + F: FnMut(PollEvent<'_>), { self.inner.read().unwrap().poll_events(timeout, callback); } /// Creates a means to wake up the main loop while it is blocked waiting for /// events within [`AndroidApp::poll_events()`]. - pub fn create_waker(&self) -> activity_impl::AndroidAppWaker { + pub fn create_waker(&self) -> AndroidAppWaker { self.inner.read().unwrap().create_waker() } diff --git a/android-activity/src/native_activity/glue.rs b/android-activity/src/native_activity/glue.rs index 495c813..d26af76 100644 --- a/android-activity/src/native_activity/glue.rs +++ b/android-activity/src/native_activity/glue.rs @@ -216,7 +216,7 @@ pub enum NativeThreadState { pub struct NativeActivityState { pub msg_read: libc::c_int, pub msg_write: libc::c_int, - pub config: super::ConfigurationRef, + pub config: ConfigurationRef, pub saved_state: Vec, pub input_queue: *mut ndk_sys::AInputQueue, pub window: Option, @@ -343,9 +343,8 @@ impl WaitableNativeActivityState { } } - let saved_state = unsafe { - std::slice::from_raw_parts(saved_state_in as *const u8, saved_state_size as _) - }; + let saved_state = + unsafe { std::slice::from_raw_parts(saved_state_in as *const u8, saved_state_size) }; let config = unsafe { let config = ndk_sys::AConfiguration_new(); @@ -517,7 +516,7 @@ impl WaitableNativeActivityState { // given via a `malloc()` allocated pointer since it will automatically // `free()` the state after it has been converted to a buffer for the JVM. if !guard.saved_state.is_empty() { - let saved_state_size = guard.saved_state.len() as _; + let saved_state_size = guard.saved_state.len(); let saved_state_src_ptr = guard.saved_state.as_ptr(); unsafe { let saved_state = libc::malloc(saved_state_size); @@ -681,7 +680,7 @@ unsafe extern "C" fn on_resume(activity: *mut ndk_sys::ANativeActivity) { unsafe extern "C" fn on_save_instance_state( activity: *mut ndk_sys::ANativeActivity, - out_len: *mut ndk_sys::size_t, + out_len: *mut usize, ) -> *mut libc::c_void { abort_on_panic(|| { log::debug!("SaveInstanceState: {:p}\n", activity); @@ -689,7 +688,7 @@ unsafe extern "C" fn on_save_instance_state( let mut ret = ptr::null_mut(); try_with_waitable_activity_ref(activity, |waitable_activity| { let (state, len) = waitable_activity.request_save_state(); - *out_len = len as ndk_sys::size_t; + *out_len = len; ret = state }); diff --git a/android-activity/src/native_activity/mod.rs b/android-activity/src/native_activity/mod.rs index 45da83e..f5c5cc1 100644 --- a/android-activity/src/native_activity/mod.rs +++ b/android-activity/src/native_activity/mod.rs @@ -185,14 +185,14 @@ impl AndroidAppInner { pub fn poll_events(&self, timeout: Option, mut callback: F) where - F: FnMut(PollEvent), + F: FnMut(PollEvent<'_>), { trace!("poll_events"); unsafe { let mut fd: i32 = 0; let mut events: i32 = 0; - let mut source: *mut core::ffi::c_void = ptr::null_mut(); + let mut source: *mut c_void = ptr::null_mut(); let timeout_milliseconds = if let Some(timeout) = timeout { timeout.as_millis() as i32 @@ -209,7 +209,7 @@ impl AndroidAppInner { timeout_milliseconds, &mut fd, &mut events, - &mut source as *mut *mut core::ffi::c_void, + &mut source as *mut *mut c_void, ); trace!("pollAll id = {id}"); match id { diff --git a/examples/agdk-mainloop/Cargo.toml b/examples/agdk-mainloop/Cargo.toml index 536146f..acb84a9 100644 --- a/examples/agdk-mainloop/Cargo.toml +++ b/examples/agdk-mainloop/Cargo.toml @@ -9,8 +9,8 @@ edition = "2021" log = "0.4" android_logger = "0.11.0" android-activity = { path="../../android-activity", features = ["game-activity"] } -ndk-sys = "0.4" -ndk = "0.7" +ndk-sys = "0.5.0-beta.0" +ndk = "0.8.0-beta.0" [lib] name="main" diff --git a/examples/na-mainloop/Cargo.toml b/examples/na-mainloop/Cargo.toml index 93da1d9..2014401 100644 --- a/examples/na-mainloop/Cargo.toml +++ b/examples/na-mainloop/Cargo.toml @@ -9,8 +9,8 @@ edition = "2021" log = "0.4" android_logger = "0.11.0" android-activity = { path="../../android-activity", features = [ "native-activity" ] } -ndk-sys = "0.4" -ndk = "0.7" +ndk-sys = "0.5.0-beta.0" +ndk = "0.8.0-beta.0" [lib] #name="na_mainloop" @@ -181,4 +181,4 @@ label = "Application Name" #port = "8080" #path = "/rust-windowing/android-ndk-rs/tree/master/cargo-apk" #path_prefix = "/rust-windowing/" -#mime_type = "image/jpeg" \ No newline at end of file +#mime_type = "image/jpeg"