Compare commits

...

5 Commits

Author SHA1 Message Date
Robert Bragg 0d299300f4 Merge pull request #158 from rust-mobile/release-0.6.0
Release 0.6.0
2024-04-26 17:23:04 +01:00
Robert Bragg 0a87a84c57 Release 0.6.0 2024-04-26 17:16:38 +01:00
SkyGrel19 7bd3ba6dde native-activity: Check for null saved_state_in pointer
Avoids calling `std::slice::from_raw_parts` with a null `saved_state_in`
pointer.

Fixes: #153
2024-04-26 16:37:42 +01:00
Marijn Suijten 6a0197c28f Upgrade to ndk-sys 0.6.0 and ndk 0.9.0
The next breaking `ndk` release puts a lot of emphasis in improving
`enum`s to finally be marked `non_exhaustive`, and carry possible future
values in `__Unknown(i32)` variants.  This removes the lossy conversions
that previously required `android-activity` to redefine its types, which
could all be removed again.

The `repr()` types have also been updated, as `enum` constants in C are
translated to `u32` by default in `bindgen` even though they're commonly
passed as `int` to every API function that consumes them.
2024-04-26 16:36:38 +01:00
Robert Bragg e5b8242ff2 Bump MSRV to 1.69.0 considering we can't build cargo ndk with 1.68
cargo ndk will fail to build with 1.68 due to a toml_edit dep.

Technically android-activity itself should still build with 1.68
but it's simpler to synchronize the `rust-version` with the minimum
version that we actually test in CI (where we need to build cargo ndk)
2024-04-26 16:11:36 +01:00
8 changed files with 48 additions and 25 deletions
+1 -1
View File
@@ -17,7 +17,7 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
# See top README for MSRV policy # See top README for MSRV policy
rust-version: [1.68.0, stable] rust-version: [1.69.0, stable]
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
+26 -4
View File
@@ -6,6 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
## [0.6.0] - 2024-04-26
### Changed
- rust-version bumped to 1.69.0 ([#156](https://github.com/rust-mobile/android-activity/pull/156))
- Upgrade to `ndk-sys 0.6.0` and `ndk 0.9.0` ([#155](https://github.com/rust-mobile/android-activity/pull/155))
### Fixed
- Check for null `saved_state_in` pointer from `NativeActivity`
## [0.5.2] - 2024-01-30 ## [0.5.2] - 2024-01-30
@@ -176,21 +184,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Removed ### Removed
- Most of the examples were moved to <https://github.com/rust-mobile/rust-android-examples> ([#50](https://github.com/rust-mobile/android-activity/pull/50)) - Most of the examples were moved to <https://github.com/rust-mobile/rust-android-examples> ([#50](https://github.com/rust-mobile/android-activity/pull/50))
## [0.4] - 2022-11-10 ## [0.4.0] - 2022-11-10
### Changed ### Changed
- *Breaking*: `input_events` callback now return whether an event was handled or not to allow for fallback handling ([#31](https://github.com/rust-mobile/android-activity/issues/31)) - *Breaking*: `input_events` callback now return whether an event was handled or not to allow for fallback handling ([#31](https://github.com/rust-mobile/android-activity/issues/31))
- The native-activity backend is now implemented in Rust only, without building on `android_native_app_glue.c` ([#35](https://github.com/rust-mobile/android-activity/pull/35)) - The native-activity backend is now implemented in Rust only, without building on `android_native_app_glue.c` ([#35](https://github.com/rust-mobile/android-activity/pull/35))
### Added ### Added
- Added `Pointer::tool_type()` API to `GameActivity` backend for compatibility with `ndk` events API ([#38](https://github.com/rust-mobile/android-activity/pull/38)) - Added `Pointer::tool_type()` API to `GameActivity` backend for compatibility with `ndk` events API ([#38](https://github.com/rust-mobile/android-activity/pull/38))
## [0.3] - 2022-09-15 ## [0.3.0] - 2022-09-15
### Added ### Added
- `show/hide_sot_input` API for being able to show/hide a soft keyboard (other IME still pending) - `show/hide_sot_input` API for being able to show/hide a soft keyboard (other IME still pending)
- `set_window_flags()` API for setting WindowManager params - `set_window_flags()` API for setting WindowManager params
### Changed ### Changed
- *Breaking*: Created extensible, `#[non_exhaustive]` `InputEvent` wrapper enum instead of exposing `ndk` type directly - *Breaking*: Created extensible, `#[non_exhaustive]` `InputEvent` wrapper enum instead of exposing `ndk` type directly
## [0.2] - 2022-08-25 ## [0.2.0] - 2022-08-25
### Added ### Added
- Emit an `InputAvailable` event for new input with `NativeActivity` and `GameActivity` - Emit an `InputAvailable` event for new input with `NativeActivity` and `GameActivity`
enabling gui apps that don't render continuously enabling gui apps that don't render continuously
@@ -207,6 +215,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed ### Changed
- Documentation fixes - Documentation fixes
## [0.1] - 2022-07-04 ## [0.1.0] - 2022-07-04
### Added ### Added
- Initial release - Initial release
[unreleased]: https://github.com/rust-mobile/android-activity/compare/v0.6.0...HEAD
[0.6.0]: https://github.com/rust-mobile/android-activity/compare/v0.5.2...v0.6.0
[0.5.2]: https://github.com/rust-mobile/android-activity/compare/v0.5.1...v0.5.2
[0.5.1]: https://github.com/rust-mobile/android-activity/compare/v0.5.0...v0.5.1
[0.5.0]: https://github.com/rust-mobile/android-activity/compare/v0.4.3...v0.5.0
[0.4.3]: https://github.com/rust-mobile/android-activity/compare/v0.4.2...v0.4.3
[0.4.2]: https://github.com/rust-mobile/android-activity/compare/v0.4.1...v0.4.2
[0.4.1]: https://github.com/rust-mobile/android-activity/compare/v0.4.0...v0.4.1
[0.4.0]: https://github.com/rust-mobile/android-activity/compare/v0.3.0...v0.4.0
[0.3.0]: https://github.com/rust-mobile/android-activity/compare/v0.2.0...v0.3.0
[0.2.0]: https://github.com/rust-mobile/android-activity/compare/v0.1.1...v0.2.0
[0.1.1]: https://github.com/rust-mobile/android-activity/compare/v0.1.0...v0.1.1
[0.1.0]: https://github.com/rust-mobile/android-activity/releases/tag/v0.1.0
+5 -5
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "android-activity" name = "android-activity"
version = "0.5.2" version = "0.6.0"
edition = "2021" edition = "2021"
keywords = ["android", "ndk"] keywords = ["android", "ndk"]
readme = "../README.md" readme = "../README.md"
@@ -10,12 +10,12 @@ documentation = "https://docs.rs/android-activity"
description = "Glue for building Rust applications on Android with NativeActivity or GameActivity" description = "Glue for building Rust applications on Android with NativeActivity or GameActivity"
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
# 1.68 was when Rust last updated the Android NDK version used to build the # 1.69 was when Rust last updated the Android NDK version used to build the
# standard library which avoids needing the -lunwind workaround in build tools. # standard library which avoids needing the -lunwind workaround in build tools.
# #
# We depend on cargo-ndk for building which has dropped support for the above # We depend on cargo-ndk for building which has dropped support for the above
# linker workaround. # linker workaround.
rust-version = "1.68.0" rust-version = "1.69.0"
[features] [features]
# Note: we don't enable any backend by default since features # Note: we don't enable any backend by default since features
@@ -33,8 +33,8 @@ log = "0.4"
jni-sys = "0.3" jni-sys = "0.3"
cesu8 = "1" cesu8 = "1"
jni = "0.21" jni = "0.21"
ndk-sys = "0.5.0" ndk-sys = "0.6.0"
ndk = { version = "0.8.0", default-features = false } ndk = { version = "0.9.0", default-features = false }
ndk-context = "0.1" ndk-context = "0.1"
android-properties = "0.2" android-properties = "0.2"
num_enum = "0.7" num_enum = "0.7"
+7 -3
View File
@@ -337,8 +337,12 @@ impl WaitableNativeActivityState {
} }
} }
let saved_state = let saved_state = if saved_state_in.is_null() {
unsafe { std::slice::from_raw_parts(saved_state_in as *const u8, saved_state_size) }; Vec::new()
} else {
unsafe { std::slice::from_raw_parts(saved_state_in as *const u8, saved_state_size) }
.to_vec()
};
let config = unsafe { let config = unsafe {
let config = ndk_sys::AConfiguration_new(); let config = ndk_sys::AConfiguration_new();
@@ -357,7 +361,7 @@ impl WaitableNativeActivityState {
msg_read: msgpipe[0], msg_read: msgpipe[0],
msg_write: msgpipe[1], msg_write: msgpipe[1],
config, config,
saved_state: saved_state.into(), saved_state,
input_queue: ptr::null_mut(), input_queue: ptr::null_mut(),
window: None, window: None,
content_rect: Rect::empty().into(), content_rect: Rect::empty().into(),
@@ -262,13 +262,8 @@ impl<'a> PointerImpl<'a> {
#[inline] #[inline]
pub fn axis_value(&self, axis: Axis) -> f32 { pub fn axis_value(&self, axis: Axis) -> f32 {
let value: u32 = axis.into(); let value: u32 = axis.into();
if let Ok(ndk_axis) = value.try_into() { let value = value as i32;
self.ndk_pointer.axis_value(ndk_axis) self.ndk_pointer.axis_value(value.into())
} else {
// FIXME: We should also be able to query `Axis::__Unknown(u32)` values
// that can't currently be queried via the `ndk` `Pointer` API
0.0f32
}
} }
#[inline] #[inline]
@@ -283,7 +278,8 @@ impl<'a> PointerImpl<'a> {
#[inline] #[inline]
pub fn tool_type(&self) -> ToolType { pub fn tool_type(&self) -> ToolType {
let value: u32 = self.ndk_pointer.tool_type().into(); let value: i32 = self.ndk_pointer.tool_type().into();
let value = value as u32;
value.into() value.into()
} }
} }
@@ -507,6 +507,7 @@ impl<'a> InputIteratorInner<'a> {
ndk::event::InputEvent::KeyEvent(e) => { ndk::event::InputEvent::KeyEvent(e) => {
input::InputEvent::KeyEvent(input::KeyEvent::new(e)) input::InputEvent::KeyEvent(input::KeyEvent::new(e))
} }
_ => todo!("NDK added a new type"),
}; };
// `finish_event` needs to be called for each event otherwise // `finish_event` needs to be called for each event otherwise
+2 -2
View File
@@ -9,8 +9,8 @@ edition = "2021"
log = "0.4" log = "0.4"
android_logger = "0.11.0" android_logger = "0.11.0"
android-activity = { path="../../android-activity", features = ["game-activity"] } android-activity = { path="../../android-activity", features = ["game-activity"] }
ndk-sys = "0.5.0" ndk-sys = "0.6.0"
ndk = "0.8.0" ndk = "0.9.0"
[lib] [lib]
name="main" name="main"
+2 -2
View File
@@ -9,8 +9,8 @@ edition = "2021"
log = "0.4" log = "0.4"
android_logger = "0.11.0" android_logger = "0.11.0"
android-activity = { path="../../android-activity", features = [ "native-activity" ] } android-activity = { path="../../android-activity", features = [ "native-activity" ] }
ndk-sys = "0.5.0" ndk-sys = "0.6.0"
ndk = "0.8.0" ndk = "0.9.0"
[lib] [lib]
#name="na_mainloop" #name="na_mainloop"