mobile build
This commit is contained in:
parent
7eeb0f7335
commit
bd733bc108
@ -22,9 +22,9 @@ pub trait FileManager: Interface {
|
|||||||
|
|
||||||
#[cfg(any(target_os = "android", target_os = "ios", feature = "cli"))]
|
#[cfg(any(target_os = "android", target_os = "ios", feature = "cli"))]
|
||||||
fn read_dir(&self, path: &str, include_hidden: bool) -> String {
|
fn read_dir(&self, path: &str, include_hidden: bool) -> String {
|
||||||
use crate::common::make_fd_to_json;
|
use crate::flutter::make_fd_to_json;
|
||||||
match fs::read_dir(&fs::get_path(path), include_hidden) {
|
match fs::read_dir(&fs::get_path(path), include_hidden) {
|
||||||
Ok(fd) => make_fd_to_json(fd),
|
Ok(fd) => make_fd_to_json(fd.id, fd.path, &fd.entries),
|
||||||
Err(_) => "".into(),
|
Err(_) => "".into(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -340,6 +340,7 @@ pub fn session_start_(id: &str, event_stream: StreamSink<EventToUI>) -> ResultTy
|
|||||||
pub mod connection_manager {
|
pub mod connection_manager {
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
use hbb_common::log;
|
||||||
#[cfg(any(target_os = "android"))]
|
#[cfg(any(target_os = "android"))]
|
||||||
use scrap::android::call_main_service_set_by_name;
|
use scrap::android::call_main_service_set_by_name;
|
||||||
|
|
||||||
@ -410,9 +411,18 @@ pub mod connection_manager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
pub fn start_channel(rx: UnboundedReceiver<Data>, tx: UnboundedSender<Data>) {
|
use hbb_common::tokio::sync::mpsc::{UnboundedReceiver,UnboundedSender};
|
||||||
|
|
||||||
|
#[cfg(target_os = "android")]
|
||||||
|
pub fn start_channel(
|
||||||
|
rx: UnboundedReceiver<crate::ipc::Data>,
|
||||||
|
tx: UnboundedSender<crate::ipc::Data>,
|
||||||
|
) {
|
||||||
use crate::ui_cm_interface::start_listen;
|
use crate::ui_cm_interface::start_listen;
|
||||||
std::thread::spawn(move || start_listen(rx, tx));
|
let cm = crate::ui_cm_interface::ConnectionManager {
|
||||||
|
ui_handler: FlutterHandler {},
|
||||||
|
};
|
||||||
|
std::thread::spawn(move || start_listen(cm, rx, tx));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -754,7 +754,7 @@ pub fn main_set_home_dir(home: String) {
|
|||||||
pub fn main_stop_service() {
|
pub fn main_stop_service() {
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
{
|
{
|
||||||
Config::set_option("stop-service".into(), "Y".into());
|
config::Config::set_option("stop-service".into(), "Y".into());
|
||||||
crate::rendezvous_mediator::RendezvousMediator::restart();
|
crate::rendezvous_mediator::RendezvousMediator::restart();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -762,7 +762,7 @@ pub fn main_stop_service() {
|
|||||||
pub fn main_start_service() {
|
pub fn main_start_service() {
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
{
|
{
|
||||||
Config::set_option("stop-service".into(), "".into());
|
config::Config::set_option("stop-service".into(), "".into());
|
||||||
crate::rendezvous_mediator::RendezvousMediator::restart();
|
crate::rendezvous_mediator::RendezvousMediator::restart();
|
||||||
}
|
}
|
||||||
#[cfg(not(target_os = "android"))]
|
#[cfg(not(target_os = "android"))]
|
||||||
|
@ -114,13 +114,17 @@ impl<T: InvokeUiCM> ConnectionManager<T> {
|
|||||||
CLIENTS.write().unwrap().remove(&id);
|
CLIENTS.write().unwrap().remove(&id);
|
||||||
|
|
||||||
#[cfg(any(target_os = "android"))]
|
#[cfg(any(target_os = "android"))]
|
||||||
if clients
|
if CLIENTS
|
||||||
|
.read()
|
||||||
|
.unwrap()
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|(_k, v)| !v.is_file_transfer)
|
.filter(|(_k, v)| !v.is_file_transfer)
|
||||||
.next()
|
.next()
|
||||||
.is_none()
|
.is_none()
|
||||||
{
|
{
|
||||||
if let Err(e) = call_main_service_set_by_name("stop_capture", None, None) {
|
if let Err(e) =
|
||||||
|
scrap::android::call_main_service_set_by_name("stop_capture", None, None)
|
||||||
|
{
|
||||||
log::debug!("stop_capture err:{}", e);
|
log::debug!("stop_capture err:{}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -312,7 +316,7 @@ pub async fn start_ipc<T: InvokeUiCM>(cm: ConnectionManager<T>) {
|
|||||||
|
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
#[tokio::main(flavor = "current_thread")]
|
#[tokio::main(flavor = "current_thread")]
|
||||||
pub async fn start_listen(mut rx: UnboundedReceiver<Data>, tx: UnboundedSender<Data>) {
|
pub async fn start_listen<T: InvokeUiCM>(cm: ConnectionManager<T>, mut rx: mpsc::UnboundedReceiver<Data>, tx: mpsc::UnboundedSender<Data>) {
|
||||||
let mut current_id = 0;
|
let mut current_id = 0;
|
||||||
let mut write_jobs: Vec<fs::TransferJob> = Vec::new();
|
let mut write_jobs: Vec<fs::TransferJob> = Vec::new();
|
||||||
loop {
|
loop {
|
||||||
@ -332,7 +336,7 @@ pub async fn start_listen(mut rx: UnboundedReceiver<Data>, tx: UnboundedSender<D
|
|||||||
..
|
..
|
||||||
}) => {
|
}) => {
|
||||||
current_id = id;
|
current_id = id;
|
||||||
on_login(
|
cm.add_connection(
|
||||||
id,
|
id,
|
||||||
is_file_transfer,
|
is_file_transfer,
|
||||||
port_forward,
|
port_forward,
|
||||||
@ -348,7 +352,7 @@ pub async fn start_listen(mut rx: UnboundedReceiver<Data>, tx: UnboundedSender<D
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
Some(Data::ChatMessage { text }) => {
|
Some(Data::ChatMessage { text }) => {
|
||||||
cm.new_message(conn_id, text);
|
cm.new_message(current_id, text);
|
||||||
}
|
}
|
||||||
Some(Data::FS(fs)) => {
|
Some(Data::FS(fs)) => {
|
||||||
handle_fs(fs, &mut write_jobs, &tx).await;
|
handle_fs(fs, &mut write_jobs, &tx).await;
|
||||||
@ -362,7 +366,7 @@ pub async fn start_listen(mut rx: UnboundedReceiver<Data>, tx: UnboundedSender<D
|
|||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
remove_connection(current_id);
|
cm.remove_connection(current_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn handle_fs(fs: ipc::FS, write_jobs: &mut Vec<fs::TransferJob>, tx: &UnboundedSender<Data>) {
|
async fn handle_fs(fs: ipc::FS, write_jobs: &mut Vec<fs::TransferJob>, tx: &UnboundedSender<Data>) {
|
||||||
|
@ -372,10 +372,11 @@ pub fn get_mouse_time() -> f64 {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
|
||||||
pub fn check_mouse_time() {
|
pub fn check_mouse_time() {
|
||||||
let sender = SENDER.lock().unwrap();
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]{
|
||||||
allow_err!(sender.send(ipc::Data::MouseMoveTime(0)));
|
let sender = SENDER.lock().unwrap();
|
||||||
|
allow_err!(sender.send(ipc::Data::MouseMoveTime(0)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_connect_status() -> Status {
|
pub fn get_connect_status() -> Status {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user