From fe9d68c99e07e44b58a2280d5f5be0a163893302 Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Sat, 1 Apr 2023 15:11:48 +0200 Subject: [PATCH] Clean up partial module imports Some items were imported in scope while most of the code uses fully qualified names. --- android-activity/src/native_activity/glue.rs | 7 +++---- android-activity/src/native_activity/mod.rs | 15 +++++---------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/android-activity/src/native_activity/glue.rs b/android-activity/src/native_activity/glue.rs index 908e63f..4e2b863 100644 --- a/android-activity/src/native_activity/glue.rs +++ b/android-activity/src/native_activity/glue.rs @@ -14,7 +14,6 @@ use std::{ use log::Level; use ndk::{configuration::Configuration, input_queue::InputQueue, native_window::NativeWindow}; -use ndk_sys::ANativeActivity; use crate::ConfigurationRef; @@ -99,7 +98,7 @@ impl Deref for NativeActivityGlue { impl NativeActivityGlue { pub fn new( - activity: *mut ANativeActivity, + activity: *mut ndk_sys::ANativeActivity, saved_state: *const libc::c_void, saved_state_size: libc::size_t, ) -> Self { @@ -149,7 +148,7 @@ impl NativeActivityGlue { self.inner.mutex.lock().unwrap().read_cmd() } - /// For the Rust main thread to get an ndk::InputQueue that wraps the AInputQueue pointer + /// For the Rust main thread to get an [`InputQueue`] that wraps the AInputQueue pointer /// we have and at the same time ensure that the input queue is attached to the given looper. /// /// NB: it's expected that the input queue is detached as soon as we know there is new @@ -837,7 +836,7 @@ extern "C" fn ANativeActivity_onCreate( // Note: we drop the thread handle which will detach the thread std::thread::spawn(move || { - let activity: *mut ANativeActivity = activity_ptr as *mut _; + let activity: *mut ndk_sys::ANativeActivity = activity_ptr as *mut _; let jvm = unsafe { let na = activity; diff --git a/android-activity/src/native_activity/mod.rs b/android-activity/src/native_activity/mod.rs index a67f56a..e0bb330 100644 --- a/android-activity/src/native_activity/mod.rs +++ b/android-activity/src/native_activity/mod.rs @@ -7,12 +7,7 @@ use std::time::Duration; use libc::c_void; use log::{error, trace}; - -use ndk_sys::ALooper_wake; -use ndk_sys::{ALooper, ALooper_pollAll}; - -use ndk::asset::AssetManager; -use ndk::native_window::NativeWindow; +use ndk::{asset::AssetManager, native_window::NativeWindow}; use crate::{ util, AndroidApp, ConfigurationRef, InputStatus, MainEvent, PollEvent, Rect, WindowManagerFlags, @@ -63,7 +58,7 @@ pub struct AndroidAppWaker { // The looper pointer is owned by the android_app and effectively // has a 'static lifetime, and the ALooper_wake C API is thread // safe, so this can be cloned safely and is send + sync safe - looper: NonNull, + looper: NonNull, } unsafe impl Send for AndroidAppWaker {} unsafe impl Sync for AndroidAppWaker {} @@ -77,7 +72,7 @@ impl AndroidAppWaker { /// [wake_event]: crate::PollEvent::Wake pub fn wake(&self) { unsafe { - ALooper_wake(self.looper.as_ptr()); + ndk_sys::ALooper_wake(self.looper.as_ptr()); } } } @@ -119,7 +114,7 @@ impl AndroidApp { #[derive(Debug)] struct Looper { - pub ptr: *mut ALooper, + pub ptr: *mut ndk_sys::ALooper, } unsafe impl Send for Looper {} unsafe impl Sync for Looper {} @@ -174,7 +169,7 @@ impl AndroidAppInner { !ndk_sys::ALooper_forThread().is_null(), "Application tried to poll events from non-main thread" ); - let id = ALooper_pollAll( + let id = ndk_sys::ALooper_pollAll( timeout_milliseconds, &mut fd, &mut events,