1use tauri::{plugin::TauriPlugin, Runtime};
2
3#[cfg(target_os = "android")]
4const PLUGIN_IDENTIFIER: &str = "org.jakebot.blew";
5
6pub fn are_ble_permissions_granted() -> bool {
10 #[cfg(target_os = "android")]
11 {
12 blew::platform::android::are_ble_permissions_granted()
13 }
14 #[cfg(not(target_os = "android"))]
15 {
16 true
17 }
18}
19
20pub fn is_emulator() -> bool {
25 #[cfg(target_os = "android")]
26 {
27 blew::platform::android::is_emulator()
28 }
29 #[cfg(not(target_os = "android"))]
30 {
31 std::env::var("SIMULATOR_DEVICE_NAME").is_ok()
32 }
33}
34
35pub fn init<R: Runtime>() -> TauriPlugin<R> {
36 tauri::plugin::Builder::<R>::new("blew")
37 .setup(|_app, api| {
38 #[cfg(target_os = "android")]
39 {
40 let ctx = ndk_context::android_context();
41 let vm = unsafe { jni::JavaVM::from_raw(ctx.vm().cast()) };
42 blew::platform::android::init_jvm(vm);
43 api.register_android_plugin(PLUGIN_IDENTIFIER, "BlewPlugin")?;
44 }
45 let _ = api;
46 Ok(())
47 })
48 .build()
49}