diff --git a/Cargo.toml b/Cargo.toml index 5673fe4..fd932a2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,3 +3,7 @@ resolver = "2" members = ["android-activity"] exclude = ["examples"] + +[patch.crates-io] +# https://github.com/rust-mobile/ndk/pull/495 +ndk = { git = "https://github.com/rust-mobile/ndk", rev = "9c63222" } diff --git a/android-activity/Cargo.toml b/android-activity/Cargo.toml index 276d1bd..77b9401 100644 --- a/android-activity/Cargo.toml +++ b/android-activity/Cargo.toml @@ -42,7 +42,6 @@ jni = "0.21" ndk-sys = "0.6.0" ndk = { version = "0.9.0", default-features = false } ndk-context = "0.1.1" -android-properties = "0.2" num_enum = "0.7" bitflags = "2.0" libc = "0.2.139" diff --git a/android-activity/src/lib.rs b/android-activity/src/lib.rs index 42c207c..ded7c76 100644 --- a/android-activity/src/lib.rs +++ b/android-activity/src/lib.rs @@ -855,15 +855,14 @@ impl AndroidApp { /// The user-visible SDK version of the framework /// - /// Also referred to as [`Build.VERSION_CODES`](https://developer.android.com/reference/android/os/Build.VERSION_CODES) + /// The same value as [`Build.VERSION.SDK_INT`], containing a value from [`Build.VERSION_CODES`]. + /// + /// [`Build.VERSION.SDK_INT`]: https://developer.android.com/reference/android/os/Build.VERSION#SDK_INT + /// [`Build.VERSION_CODES`]: https://developer.android.com/reference/android/os/Build.VERSION_CODES pub fn sdk_version() -> i32 { - let mut prop = android_properties::getprop("ro.build.version.sdk"); - if let Some(val) = prop.value() { - val.parse::() - .expect("Failed to parse ro.build.version.sdk property") - } else { - panic!("Couldn't read ro.build.version.sdk system property"); - } + // TODO: Replace with ndk::api_level::device_api_level() from https://github.com/rust-mobile/ndk/pull/479? + ndk::system_properties::get::(c"ro.build.version.sdk") + .expect("Failed to get or parse `ro.build.version.sdk` property") } /// Path to this application's internal data directory