Skip to content

Commit

Permalink
Upgrade to ndk-sys-0.5.0-beta.0, ndk-0.8.0-beta.0
Browse files Browse the repository at this point in the history
  • Loading branch information
MarijnS95 committed Aug 15, 2023
1 parent 2654c96 commit b867fcc
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 20 deletions.
8 changes: 2 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
[workspace]
members = [
"android-activity"
]
members = ["android-activity"]

exclude = [
"examples",
]
exclude = ["examples"]
4 changes: 2 additions & 2 deletions android-activity/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ log = "0.4"
jni-sys = "0.3"
cesu8 = "1"
jni = "0.21"
ndk = "0.7"
ndk-sys = "0.4"
ndk = "0.8.0-beta.0"
ndk-sys = "0.5.0-beta.0"
ndk-context = "0.1"
android-properties = "0.2"
num_enum = "0.7"
Expand Down
4 changes: 2 additions & 2 deletions android-activity/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -537,14 +537,14 @@ impl AndroidApp {
/// [`ALooper_pollAll`]: ndk::looper::ThreadLooper::poll_all
pub fn poll_events<F>(&self, timeout: Option<Duration>, 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()
}

Expand Down
13 changes: 6 additions & 7 deletions android-activity/src/native_activity/glue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u8>,
pub input_queue: *mut ndk_sys::AInputQueue,
pub window: Option<NativeWindow>,
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -681,15 +680,15 @@ 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);
*out_len = 0;
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
});

Expand Down
6 changes: 3 additions & 3 deletions android-activity/src/native_activity/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,14 @@ impl AndroidAppInner {

pub fn poll_events<F>(&self, timeout: Option<Duration>, 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
Expand All @@ -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 {
Expand Down

0 comments on commit b867fcc

Please sign in to comment.