(_env: JNIEnv, _class: JClass)
| 73 | |
| 74 | #[no_mangle] |
| 75 | pub extern "system" fn getTrackTitle(_env: JNIEnv, _class: JClass) -> *const c_char { |
| 76 | let result = std::panic::catch_unwind(|| { |
| 77 | block_on(async { |
| 78 | match get_spotify_session()? { |
| 79 | Some(session) => { |
| 80 | let props = session.TryGetMediaPropertiesAsync()?.get()?; |
| 81 | let title = props.Title()?.to_string(); |
| 82 | // Safely create CString, fallback to empty string if null bytes present |
| 83 | Ok(CString::new(title).unwrap_or_default().into_raw()) |
| 84 | } |
| 85 | _ => Err(Error::new(E_FAIL, "Spotify session not found")), |
| 86 | } |
| 87 | }) |
| 88 | }); |
| 89 | |
| 90 | match result { |
| 91 | Ok(Ok(ptr)) => ptr, |
| 92 | _ => std::ptr::null(), |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | #[no_mangle] |
| 97 | pub extern "system" fn getArtistName(_env: JNIEnv, _class: JClass) -> *const c_char { |
nothing calls this directly
no test coverage detected