Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix CBManager crash on macOS <10.15 #337

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix CBManager crash on macOS <10.15
oletf authored Sep 7, 2023

Verified

This commit was signed with the committer’s verified signature.
electrovir electrovir
commit b3f4f2c545812654d873330a37256f986f5de8e3
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -49,6 +49,7 @@ jni-utils = "0.1.1"
cocoa = "0.25.0"
objc = "0.2.7"
libc = "0.2.147"
os_info = "3.7.0"

[target.'cfg(target_os = "windows")'.dependencies]
windows = { version = "0.51.1", features = ["Devices_Bluetooth", "Devices_Bluetooth_GenericAttributeProfile", "Devices_Bluetooth_Advertisement", "Devices_Radios", "Foundation_Collections", "Foundation", "Storage_Streams"] }
8 changes: 7 additions & 1 deletion src/corebluetooth/framework.rs
Original file line number Diff line number Diff line change
@@ -174,7 +174,13 @@ pub mod cb {

// CBManager
pub fn manager_authorization() -> CBManagerAuthorization {
unsafe { msg_send![class!(CBManager), authorization] }
use os_info::Version::Semantic as OSSemVer;

if os_info::get().version() >= &OSSemVer(10, 15, 0) {
unsafe { msg_send![class!(CBManager), authorization] }
} else {
CBManagerAuthorization::NotDetermined
}
}

#[derive(Copy, Clone, Debug, Eq, PartialEq)]