From 8cb361c51e6c9d67c5a131c721c46f7a09a319ef Mon Sep 17 00:00:00 2001 From: fufesou Date: Mon, 27 Mar 2023 19:13:29 +0800 Subject: [PATCH] remove android build warns Signed-off-by: fufesou --- libs/hbb_common/src/config.rs | 1 + src/client/io_loop.rs | 21 +++++++++++++++------ src/core_main.rs | 1 + src/flutter_ffi.rs | 12 +++++------- src/hbbs_http/sync.rs | 1 + src/keyboard.rs | 28 ++++++++++++++++++++-------- src/lan.rs | 11 ++++++++--- src/platform/mod.rs | 2 +- src/server.rs | 2 +- src/server/audio_service.rs | 1 + src/server/connection.rs | 19 ++++++++++++++----- src/server/video_service.rs | 3 +-- src/ui_cm_interface.rs | 16 +++++++++++++--- src/ui_interface.rs | 23 ++++++++++++++++------- src/ui_session_interface.rs | 3 +++ 15 files changed, 101 insertions(+), 43 deletions(-) diff --git a/libs/hbb_common/src/config.rs b/libs/hbb_common/src/config.rs index 0624af672..76a87153e 100644 --- a/libs/hbb_common/src/config.rs +++ b/libs/hbb_common/src/config.rs @@ -297,6 +297,7 @@ pub struct TransferSerde { pub read_jobs: Vec, } +#[cfg(not(any(target_os = "android", target_os = "ios")))] fn patch(path: PathBuf) -> PathBuf { if let Some(_tmp) = path.to_str() { #[cfg(windows)] diff --git a/src/client/io_loop.rs b/src/client/io_loop.rs index 4a020d197..135e92a75 100644 --- a/src/client/io_loop.rs +++ b/src/client/io_loop.rs @@ -1,7 +1,11 @@ use std::collections::HashMap; use std::num::NonZeroI64; -use std::sync::atomic::{AtomicUsize, Ordering}; -use std::sync::{Arc, Mutex}; +#[cfg(not(any(target_os = "android", target_os = "ios")))] +use std::sync::Mutex; +use std::sync::{ + atomic::{AtomicUsize, Ordering}, + Arc, +}; #[cfg(windows)] use clipboard::{cliprdr::CliprdrClientContext, ContextSend}; @@ -13,6 +17,8 @@ use hbb_common::fs::{ use hbb_common::message_proto::permission_info::Permission; use hbb_common::protobuf::Message as _; use hbb_common::rendezvous_proto::ConnType; +#[cfg(not(any(target_os = "android", target_os = "ios")))] +use hbb_common::sleep; use hbb_common::tokio::sync::mpsc::error::TryRecvError; #[cfg(windows)] use hbb_common::tokio::sync::Mutex as TokioMutex; @@ -21,18 +27,17 @@ use hbb_common::tokio::{ sync::mpsc, time::{self, Duration, Instant, Interval}, }; -use hbb_common::{allow_err, get_time, message_proto::*, sleep}; -use hbb_common::{fs, log, Stream}; +use hbb_common::{allow_err, fs, get_time, log, message_proto::*, Stream}; use crate::client::{ new_voice_call_request, Client, CodecFormat, MediaData, MediaSender, QualityStatus, MILLI1, SEC30, }; #[cfg(not(any(target_os = "android", target_os = "ios")))] -use crate::common::update_clipboard; +use crate::common::{self, update_clipboard}; use crate::common::{get_default_sound_input, set_sound_input}; use crate::ui_session_interface::{InvokeUiSession, Session}; -use crate::{audio_service, common, ConnInner, CLIENT_SERVER}; +use crate::{audio_service, ConnInner, CLIENT_SERVER}; use crate::{client::Data, client::Interface}; pub struct Remote { @@ -44,6 +49,7 @@ pub struct Remote { // Stop sending local audio to remote client. stop_voice_call_sender: Option>, voice_call_request_timestamp: Option, + #[cfg(not(any(target_os = "android", target_os = "ios")))] old_clipboard: Arc>, read_jobs: Vec, write_jobs: Vec, @@ -74,6 +80,7 @@ impl Remote { audio_sender, receiver, sender, + #[cfg(not(any(target_os = "android", target_os = "ios")))] old_clipboard: Default::default(), read_jobs: Vec::new(), write_jobs: Vec::new(), @@ -840,7 +847,9 @@ impl Remote { self.handler.handle_peer_info(pi); self.check_clipboard_file_context(); if !(self.handler.is_file_transfer() || self.handler.is_port_forward()) { + #[cfg(not(any(target_os = "android", target_os = "ios")))] let sender = self.sender.clone(); + #[cfg(not(any(target_os = "android", target_os = "ios")))] let permission_config = self.handler.get_permission_config(); #[cfg(feature = "flutter")] diff --git a/src/core_main.rs b/src/core_main.rs index 2c209bd07..e5eb64136 100644 --- a/src/core_main.rs +++ b/src/core_main.rs @@ -8,6 +8,7 @@ use hbb_common::platform::register_breakdown_handler; /// [Note] /// If it returns [`None`], then the process will terminate, and flutter gui will not be started. /// If it returns [`Some`], then the process will continue, and flutter gui will be started. +#[cfg(not(any(target_os = "android", target_os = "ios")))] pub fn core_main() -> Option> { let mut args = Vec::new(); let mut flutter_args = Vec::new(); diff --git a/src/flutter_ffi.rs b/src/flutter_ffi.rs index a3e8c38f2..aee486b94 100644 --- a/src/flutter_ffi.rs +++ b/src/flutter_ffi.rs @@ -168,14 +168,12 @@ pub fn session_reconnect(id: String, force_relay: bool) { } pub fn session_toggle_option(id: String, value: String) { - let mut is_found = false; if let Some(session) = SESSIONS.write().unwrap().get_mut(&id) { - is_found = true; log::warn!("toggle option {}", &value); session.toggle_option(value.clone()); } #[cfg(not(any(target_os = "android", target_os = "ios")))] - if is_found && value == "disable-clipboard" { + if SESSIONS.read().unwrap().get(&id).is_some() && value == "disable-clipboard" { crate::flutter::update_text_clipboard_required(); } } @@ -338,10 +336,10 @@ pub fn session_handle_flutter_key_event( } } -pub fn session_enter_or_leave(id: String, enter: bool) { +pub fn session_enter_or_leave(_id: String, _enter: bool) { #[cfg(not(any(target_os = "android", target_os = "ios")))] - if let Some(session) = SESSIONS.read().unwrap().get(&id) { - if enter { + if let Some(session) = SESSIONS.read().unwrap().get(&_id) { + if _enter { session.enter(); } else { session.leave(); @@ -1405,7 +1403,7 @@ pub mod server_side { #[no_mangle] pub unsafe extern "system" fn Java_com_carriez_flutter_1hbb_MainService_startService( - env: JNIEnv, + _env: JNIEnv, _class: JClass, ) { log::debug!("startService from jvm"); diff --git a/src/hbbs_http/sync.rs b/src/hbbs_http/sync.rs index a060d6a20..ae91c60aa 100644 --- a/src/hbbs_http/sync.rs +++ b/src/hbbs_http/sync.rs @@ -16,6 +16,7 @@ lazy_static::lazy_static! { static ref SENDER : Mutex>> = Mutex::new(start_hbbs_sync()); } +#[cfg(not(any(target_os = "android", target_os = "ios")))] pub fn start() { let _sender = SENDER.lock().unwrap(); } diff --git a/src/keyboard.rs b/src/keyboard.rs index 5a41d6c5c..294e058c5 100644 --- a/src/keyboard.rs +++ b/src/keyboard.rs @@ -179,6 +179,7 @@ pub mod client { } #[inline] + #[cfg(not(any(target_os = "android", target_os = "ios")))] pub fn lock_screen() { send_key_event(&event_lock_screen()); } @@ -198,6 +199,7 @@ pub mod client { } #[inline] + #[cfg(not(any(target_os = "android", target_os = "ios")))] pub fn ctrl_alt_del() { send_key_event(&event_ctrl_alt_del()); } @@ -364,6 +366,7 @@ pub fn get_keyboard_mode_enum() -> KeyboardMode { } #[inline] +#[cfg(not(any(target_os = "android", target_os = "ios")))] fn is_numpad_key(event: &Event) -> bool { matches!(event.event_type, EventType::KeyPress(key) | EventType::KeyRelease(key) if match key { Key::Kp0 | Key::Kp1 | Key::Kp2 | Key::Kp3 | Key::Kp4 | Key::Kp5 | Key::Kp6 | Key::Kp7 | Key::Kp8 | @@ -373,6 +376,7 @@ fn is_numpad_key(event: &Event) -> bool { } #[inline] +#[cfg(not(any(target_os = "android", target_os = "ios")))] fn is_letter_key(event: &Event) -> bool { matches!(event.event_type, EventType::KeyPress(key) | EventType::KeyRelease(key) if match key { Key::KeyA | Key::KeyB | Key::KeyC | Key::KeyD | Key::KeyE | Key::KeyF | Key::KeyG | Key::KeyH | @@ -456,7 +460,7 @@ fn update_modifiers_state(event: &Event) { pub fn event_to_key_events( event: &Event, keyboard_mode: KeyboardMode, - lock_modes: Option, + _lock_modes: Option, ) -> Vec { let mut key_event = KeyEvent::new(); update_modifiers_state(event); @@ -475,7 +479,12 @@ pub fn event_to_key_events( peer.retain(|c| !c.is_whitespace()); key_event.mode = keyboard_mode.into(); - let mut key_events = match keyboard_mode { + + #[cfg(not(any(target_os = "android", target_os = "ios")))] + let mut key_events; + #[cfg(any(target_os = "android", target_os = "ios"))] + let key_events; + key_events = match keyboard_mode { KeyboardMode::Map => match map_keyboard_mode(peer.as_str(), event, key_event) { Some(event) => [event].to_vec(), None => Vec::new(), @@ -493,12 +502,12 @@ pub fn event_to_key_events( } }; + #[cfg(not(any(target_os = "android", target_os = "ios")))] if keyboard_mode != KeyboardMode::Translate { let is_numpad_key = is_numpad_key(&event); let is_letter_key = is_letter_key(&event); for key_event in &mut key_events { - #[cfg(not(any(target_os = "android", target_os = "ios")))] - if let Some(lock_modes) = lock_modes { + if let Some(lock_modes) = _lock_modes { parse_add_lock_modes_modifiers(key_event, lock_modes, is_numpad_key, is_letter_key); } else { add_lock_modes_modifiers(key_event, is_numpad_key, is_letter_key); @@ -778,7 +787,7 @@ pub fn legacy_keyboard_mode(event: &Event, mut key_event: KeyEvent) -> Vec Option { +pub fn map_keyboard_mode(_peer: &str, event: &Event, mut key_event: KeyEvent) -> Option { match event.event_type { EventType::KeyPress(..) => { key_event.down = true; @@ -790,7 +799,7 @@ pub fn map_keyboard_mode(peer: &str, event: &Event, mut key_event: KeyEvent) -> }; #[cfg(target_os = "windows")] - let keycode = match peer { + let keycode = match _peer { OS_LOWER_WINDOWS => { // https://github.com/rustdesk/rustdesk/issues/1371 // Filter scancodes that are greater than 255 and the hight word is not 0xE0. @@ -809,13 +818,13 @@ pub fn map_keyboard_mode(peer: &str, event: &Event, mut key_event: KeyEvent) -> _ => rdev::win_scancode_to_linux_code(event.position_code)?, }; #[cfg(target_os = "macos")] - let keycode = match peer { + let keycode = match _peer { OS_LOWER_WINDOWS => rdev::macos_code_to_win_scancode(event.platform_code as _)?, OS_LOWER_MACOS => event.platform_code as _, _ => rdev::macos_code_to_linux_code(event.platform_code as _)?, }; #[cfg(target_os = "linux")] - let keycode = match peer { + let keycode = match _peer { OS_LOWER_WINDOWS => rdev::linux_code_to_win_scancode(event.position_code as _)?, OS_LOWER_MACOS => { if hbb_common::config::LocalConfig::get_kb_layout_type() == "ISO" { @@ -833,6 +842,7 @@ pub fn map_keyboard_mode(peer: &str, event: &Event, mut key_event: KeyEvent) -> Some(key_event) } +#[cfg(not(any(target_os = "android", target_os = "ios")))] fn try_fill_unicode(event: &Event, key_event: &KeyEvent, events: &mut Vec) { match &event.unicode { Some(unicode_info) => { @@ -925,6 +935,8 @@ pub fn translate_keyboard_mode(peer: &str, event: &Event, key_event: KeyEvent) - return events; } } + + #[cfg(not(any(target_os = "android", target_os = "ios")))] if is_numpad_key(&event) { if let Some(evt) = translate_key_code(peer, event, key_event) { events.push(evt); diff --git a/src/lan.rs b/src/lan.rs index 5b52ee1a9..15914965b 100644 --- a/src/lan.rs +++ b/src/lan.rs @@ -1,7 +1,9 @@ +#[cfg(not(any(target_os = "android", target_os = "ios")))] +use hbb_common::config::Config; use hbb_common::{ allow_err, anyhow::bail, - config::{self, Config, RENDEZVOUS_PORT}, + config::{self, RENDEZVOUS_PORT}, log, protobuf::Message as _, rendezvous_proto::*, @@ -11,6 +13,7 @@ use hbb_common::{ }, ResultType, }; + use std::{ collections::{HashMap, HashSet}, net::{IpAddr, Ipv4Addr, SocketAddr, ToSocketAddrs, UdpSocket}, @@ -19,6 +22,7 @@ use std::{ type Message = RendezvousMessage; +#[cfg(not(any(target_os = "android", target_os = "ios")))] pub(super) fn start_listening() -> ResultType<()> { let addr = SocketAddr::from(([0, 0, 0, 0], get_broadcast_port())); let socket = std::net::UdpSocket::bind(addr)?; @@ -98,9 +102,9 @@ fn get_broadcast_port() -> u16 { (RENDEZVOUS_PORT + 3) as _ } -fn get_mac(ip: &IpAddr) -> String { +fn get_mac(_ip: &IpAddr) -> String { #[cfg(not(any(target_os = "android", target_os = "ios")))] - if let Ok(mac) = get_mac_by_ip(ip) { + if let Ok(mac) = get_mac_by_ip(_ip) { mac.to_string() } else { "".to_owned() @@ -119,6 +123,7 @@ fn get_all_ipv4s() -> ResultType> { Ok(ipv4s) } +#[cfg(not(any(target_os = "android", target_os = "ios")))] fn get_mac_by_ip(ip: &IpAddr) -> ResultType { for interface in default_net::get_interfaces() { match ip { diff --git a/src/platform/mod.rs b/src/platform/mod.rs index 2ef39e92a..c30083155 100644 --- a/src/platform/mod.rs +++ b/src/platform/mod.rs @@ -19,7 +19,7 @@ pub mod linux; #[cfg(not(any(target_os = "android", target_os = "ios")))] use hbb_common::{message_proto::CursorData, ResultType}; -#[cfg(not(target_os = "macos"))] +#[cfg(not(any(target_os = "macos", target_os = "android", target_os = "ios")))] const SERVICE_INTERVAL: u64 = 300; pub fn is_xfce() -> bool { diff --git a/src/server.rs b/src/server.rs index 1f174ef03..681e7bed1 100644 --- a/src/server.rs +++ b/src/server.rs @@ -365,7 +365,7 @@ pub fn check_zombie() { /// Otherwise, client will check if there's already a server and start one if not. #[cfg(any(target_os = "android", target_os = "ios"))] #[tokio::main] -pub async fn start_server(is_server: bool) { +pub async fn start_server(_is_server: bool) { crate::RendezvousMediator::start_all().await; } diff --git a/src/server/audio_service.rs b/src/server/audio_service.rs index bef1ac1f3..3d2c226c5 100644 --- a/src/server/audio_service.rs +++ b/src/server/audio_service.rs @@ -64,6 +64,7 @@ mod pa_impl { ))) .await ); + #[cfg(target_os = "linux")] let zero_audio_frame: Vec = vec![0.; AUDIO_DATA_SIZE_U8 / 4]; while sp.ok() && !RESTARTING.load(Ordering::SeqCst) { sp.snapshot(|sps| { diff --git a/src/server/connection.rs b/src/server/connection.rs index 1f89d905f..ed7476284 100644 --- a/src/server/connection.rs +++ b/src/server/connection.rs @@ -64,7 +64,9 @@ pub struct ConnInner { } enum MessageInput { + #[cfg(not(any(target_os = "android", target_os = "ios")))] Mouse((MouseEvent, i32)), + #[cfg(not(any(target_os = "android", target_os = "ios")))] Key((KeyEvent, bool)), BlockOn, BlockOff, @@ -125,6 +127,7 @@ pub struct Connection { #[cfg(windows)] portable: PortableState, from_switch: bool, + #[cfg(not(any(target_os = "android", target_os = "ios")))] origin_resolution: HashMap, voice_call_request_timestamp: Option, audio_input_device_before_voice_call: Option, @@ -187,9 +190,10 @@ impl Connection { let (tx_to_cm, rx_to_cm) = mpsc::unbounded_channel::(); let (tx, mut rx) = mpsc::unbounded_channel::<(Instant, Arc)>(); let (tx_video, mut rx_video) = mpsc::unbounded_channel::<(Instant, Arc)>(); - let (tx_input, rx_input) = std_mpsc::channel(); + let (tx_input, _rx_input) = std_mpsc::channel(); let mut hbbs_rx = crate::hbbs_http::sync::signal_receiver(); + #[cfg(not(any(target_os = "android", target_os = "ios")))] let tx_cloned = tx.clone(); let mut conn = Self { inner: ConnInner { @@ -233,6 +237,7 @@ impl Connection { #[cfg(windows)] portable: Default::default(), from_switch: false, + #[cfg(not(any(target_os = "android", target_os = "ios")))] origin_resolution: Default::default(), audio_sender: None, voice_call_request_timestamp: None, @@ -282,7 +287,7 @@ impl Connection { ); #[cfg(not(any(target_os = "android", target_os = "ios")))] - std::thread::spawn(move || Self::handle_input(rx_input, tx_cloned)); + std::thread::spawn(move || Self::handle_input(_rx_input, tx_cloned)); let mut second_timer = time::interval(Duration::from_secs(1)); loop { @@ -1042,11 +1047,13 @@ impl Connection { } #[inline] + #[cfg(not(any(target_os = "android", target_os = "ios")))] fn input_mouse(&self, msg: MouseEvent, conn_id: i32) { self.tx_input.send(MessageInput::Mouse((msg, conn_id))).ok(); } #[inline] + #[cfg(not(any(target_os = "android", target_os = "ios")))] fn input_key(&self, msg: KeyEvent, press: bool) { self.tx_input.send(MessageInput::Key((msg, press))).ok(); } @@ -1342,8 +1349,10 @@ impl Connection { self.input_mouse(me, self.inner.id()); } } + #[cfg(any(target_os = "android", target_os = "ios"))] + Some(message::Union::KeyEvent(..)) => {} + #[cfg(not(any(target_os = "android", target_os = "ios")))] Some(message::Union::KeyEvent(me)) => { - #[cfg(not(any(target_os = "android", target_os = "ios")))] if self.peer_keyboard_enabled() { if is_enter(&me) { CLICK_TIME.store(get_time(), Ordering::SeqCst); @@ -1371,11 +1380,11 @@ impl Connection { } } } - Some(message::Union::Clipboard(cb)) => + Some(message::Union::Clipboard(_cb)) => { #[cfg(not(any(target_os = "android", target_os = "ios")))] if self.clipboard { - update_clipboard(cb, None); + update_clipboard(_cb, None); } } Some(message::Union::Cliprdr(_clip)) => { diff --git a/src/server/video_service.rs b/src/server/video_service.rs index 3b9db0697..205d0584c 100644 --- a/src/server/video_service.rs +++ b/src/server/video_service.rs @@ -831,14 +831,13 @@ pub fn handle_one_frame_encoded( } Ok(()) })?; - let mut send_conn_ids: HashSet = Default::default(); let vp9_frame = EncodedVideoFrame { data: frame.to_vec().into(), key: true, pts: ms, ..Default::default() }; - send_conn_ids = sp.send_video_frame(create_msg(vec![vp9_frame])); + let send_conn_ids = sp.send_video_frame(create_msg(vec![vp9_frame])); Ok(send_conn_ids) } diff --git a/src/ui_cm_interface.rs b/src/ui_cm_interface.rs index bd6eab3bf..8612b5751 100644 --- a/src/ui_cm_interface.rs +++ b/src/ui_cm_interface.rs @@ -15,7 +15,11 @@ use std::{ use clipboard::{cliprdr::CliprdrClientContext, empty_clipboard, set_conn_enabled, ContextSend}; use serde_derive::Serialize; -use crate::ipc::{self, Connection, Data}; +#[cfg(not(any(target_os = "android", target_os = "ios")))] +use crate::ipc::Connection; +use crate::ipc::{self, Data}; +#[cfg(not(any(target_os = "android", target_os = "ios")))] +use hbb_common::tokio::sync::mpsc::unbounded_channel; #[cfg(windows)] use hbb_common::tokio::sync::Mutex as TokioMutex; use hbb_common::{ @@ -28,7 +32,7 @@ use hbb_common::{ protobuf::Message as _, tokio::{ self, - sync::mpsc::{self, unbounded_channel, UnboundedSender}, + sync::mpsc::{self, UnboundedSender}, task::spawn_blocking, }, }; @@ -55,6 +59,7 @@ pub struct Client { tx: UnboundedSender, } +#[cfg(not(any(target_os = "android", target_os = "ios")))] struct IpcTaskRunner { stream: Connection, cm: ConnectionManager, @@ -143,7 +148,7 @@ impl ConnectionManager { from_switch, tx, in_voice_call: false, - incoming_voice_call: false + incoming_voice_call: false, }; CLIENTS .write() @@ -183,10 +188,12 @@ impl ConnectionManager { self.ui_handler.remove_connection(id, close); } + #[cfg(not(any(target_os = "android", target_os = "ios")))] fn show_elevation(&self, show: bool) { self.ui_handler.show_elevation(show); } + #[cfg(not(any(target_os = "android", target_os = "ios")))] fn voice_call_started(&self, id: i32) { if let Some(client) = CLIENTS.write().unwrap().get_mut(&id) { client.incoming_voice_call = false; @@ -195,6 +202,7 @@ impl ConnectionManager { } } + #[cfg(not(any(target_os = "android", target_os = "ios")))] fn voice_call_incoming(&self, id: i32) { if let Some(client) = CLIENTS.write().unwrap().get_mut(&id) { client.incoming_voice_call = true; @@ -203,6 +211,7 @@ impl ConnectionManager { } } + #[cfg(not(any(target_os = "android", target_os = "ios")))] fn voice_call_closed(&self, id: i32, _reason: &str) { if let Some(client) = CLIENTS.write().unwrap().get_mut(&id) { client.incoming_voice_call = false; @@ -282,6 +291,7 @@ pub fn switch_back(id: i32) { }; } +#[cfg(not(any(target_os = "android", target_os = "ios")))] impl IpcTaskRunner { #[cfg(windows)] async fn enable_cliprdr_file_context(&mut self, conn_id: i32, enabled: bool) { diff --git a/src/ui_interface.rs b/src/ui_interface.rs index 17b4fafca..11357be4a 100644 --- a/src/ui_interface.rs +++ b/src/ui_interface.rs @@ -9,8 +9,12 @@ use hbb_common::password_security; use hbb_common::{ allow_err, config::{self, Config, LocalConfig, PeerConfig}, - directories_next, log, sleep, - tokio::{self, sync::mpsc, time}, + directories_next, log, tokio, +}; +#[cfg(not(any(target_os = "android", target_os = "ios")))] +use hbb_common::{ + sleep, + tokio::{sync::mpsc, time}, }; use hbb_common::{ @@ -339,8 +343,8 @@ pub fn get_socks() -> Vec { } #[inline] +#[cfg(not(any(target_os = "android", target_os = "ios")))] pub fn set_socks(proxy: String, username: String, password: String) { - #[cfg(not(any(target_os = "android", target_os = "ios")))] ipc::set_socks(config::Socks5Server { proxy, username, @@ -349,6 +353,9 @@ pub fn set_socks(proxy: String, username: String, password: String) { .ok(); } +#[cfg(any(target_os = "android", target_os = "ios"))] +pub fn set_socks(_: String, _: String, _: String) {} + #[cfg(not(any(target_os = "android", target_os = "ios")))] #[inline] pub fn is_installed() -> bool { @@ -791,14 +798,15 @@ pub fn check_zombie(children: Children) { } } +// Make sure `SENDER` is inited here. +#[inline] +#[cfg(not(any(target_os = "android", target_os = "ios")))] pub fn start_option_status_sync() { - #[cfg(not(any(target_os = "android", target_os = "ios")))] - { - let _sender = SENDER.lock().unwrap(); - } + let _sender = SENDER.lock().unwrap(); } // not call directly +#[cfg(not(any(target_os = "android", target_os = "ios")))] fn check_connect_status(reconnect: bool) -> mpsc::UnboundedSender { let (tx, rx) = mpsc::unbounded_channel::(); std::thread::spawn(move || check_connect_status_(reconnect, rx)); @@ -834,6 +842,7 @@ pub fn get_user_default_option(key: String) -> String { // notice: avoiding create ipc connection repeatedly, // because windows named pipe has serious memory leak issue. +#[cfg(not(any(target_os = "android", target_os = "ios")))] #[tokio::main(flavor = "current_thread")] async fn check_connect_status_(reconnect: bool, rx: mpsc::UnboundedReceiver) { let mut key_confirmed = false; diff --git a/src/ui_session_interface.rs b/src/ui_session_interface.rs index 824f8befa..7ee49a3b7 100644 --- a/src/ui_session_interface.rs +++ b/src/ui_session_interface.rs @@ -1053,6 +1053,9 @@ impl Session { #[tokio::main(flavor = "current_thread")] pub async fn io_loop(handler: Session) { + #[cfg(any(target_os = "android", target_os = "ios"))] + let (sender, receiver) = mpsc::unbounded_channel::(); + #[cfg(not(any(target_os = "android", target_os = "ios")))] let (sender, mut receiver) = mpsc::unbounded_channel::(); *handler.sender.write().unwrap() = Some(sender.clone()); let token = LocalConfig::get_option("access_token");