use crate::app::Command; use color_eyre::eyre::Error; use dioxus::hooks::UnboundedReceiver; use mumble_web2_common::{ProxyOverrides, ServerStatus}; use std::time::Duration; /// Mobile platform implementation using Tokio, native audio, and Android permissions. pub struct MobilePlatform; impl super::PlatformInterface for MobilePlatform { type AudioSystem = super::native_audio::NativeAudioSystem; type ConfigSystem = super::native_config::NativeConfigSystem; async fn load_proxy_overrides() -> color_eyre::Result { Ok(ProxyOverrides { proxy_url: None, cert_hash: None, any_server: true, }) } async fn network_connect( address: String, username: String, event_rx: &mut UnboundedReceiver, overrides: &ProxyOverrides, ) -> Result<(), Error> { super::connect::network_connect(address, username, event_rx, overrides).await } async fn get_status(client: &reqwest::Client) -> color_eyre::Result { super::connect::get_status(client).await } fn init_logging() { use tracing::level_filters::LevelFilter; use tracing_subscriber::filter::EnvFilter; let env_filter = EnvFilter::builder() .with_default_directive(LevelFilter::INFO.into()) .from_env_lossy(); tracing_subscriber::fmt() .with_target(true) .with_level(true) .with_env_filter(env_filter) .init(); } fn request_permissions() { request_recording_permission(); } async fn sleep(duration: Duration) { tokio::time::sleep(duration).await; } } #[cfg(not(target_os = "android"))] pub fn request_recording_permission() {} #[cfg(target_os = "android")] pub fn request_recording_permission() { use android_permissions::{PermissionManager, RECORD_AUDIO}; use jni::{objects::JObject, JavaVM}; let ctx = ndk_context::android_context(); let vm = unsafe { JavaVM::from_raw(ctx.vm().cast()).unwrap() }; let activity = unsafe { JObject::from_raw(ctx.context().cast()) }; let manager = PermissionManager::create(vm, activity).unwrap(); if !manager.check(&RECORD_AUDIO).unwrap() { manager.request(&[&RECORD_AUDIO]).unwrap(); } }