fix android build errors and warnings
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
parent
a9eb285425
commit
6b3c2f3beb
@ -8,7 +8,6 @@ use std::{
|
||||
};
|
||||
|
||||
use anyhow::Result;
|
||||
use directories_next::ProjectDirs;
|
||||
use rand::Rng;
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use sodiumoxide::crypto::sign;
|
||||
@ -375,12 +374,15 @@ impl Config {
|
||||
pub fn get_home() -> PathBuf {
|
||||
#[cfg(any(target_os = "android", target_os = "ios"))]
|
||||
return Self::path(APP_HOME_DIR.read().unwrap().as_str());
|
||||
if let Some(path) = dirs_next::home_dir() {
|
||||
patch(path)
|
||||
} else if let Ok(path) = std::env::current_dir() {
|
||||
path
|
||||
} else {
|
||||
std::env::temp_dir()
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
{
|
||||
if let Some(path) = dirs_next::home_dir() {
|
||||
patch(path)
|
||||
} else if let Ok(path) = std::env::current_dir() {
|
||||
path
|
||||
} else {
|
||||
std::env::temp_dir()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -391,17 +393,20 @@ impl Config {
|
||||
path.push(p);
|
||||
return path;
|
||||
}
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
let org = "";
|
||||
#[cfg(target_os = "macos")]
|
||||
let org = ORG.read().unwrap().clone();
|
||||
// /var/root for root
|
||||
if let Some(project) = ProjectDirs::from("", &org, &*APP_NAME.read().unwrap()) {
|
||||
let mut path = patch(project.config_dir().to_path_buf());
|
||||
path.push(p);
|
||||
return path;
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
{
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
let org = "";
|
||||
#[cfg(target_os = "macos")]
|
||||
let org = ORG.read().unwrap().clone();
|
||||
// /var/root for root
|
||||
if let Some(project) = directories_next::ProjectDirs::from("", &org, &*APP_NAME.read().unwrap()) {
|
||||
let mut path = patch(project.config_dir().to_path_buf());
|
||||
path.push(p);
|
||||
return path;
|
||||
}
|
||||
return "".into();
|
||||
}
|
||||
return "".into();
|
||||
}
|
||||
|
||||
#[allow(unreachable_code)]
|
||||
@ -580,16 +585,19 @@ impl Config {
|
||||
.to_string(),
|
||||
);
|
||||
}
|
||||
let mut id = 0u32;
|
||||
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
if let Ok(Some(ma)) = mac_address::get_mac_address() {
|
||||
for x in &ma.bytes()[2..] {
|
||||
id = (id << 8) | (*x as u32);
|
||||
{
|
||||
let mut id = 0u32;
|
||||
if let Ok(Some(ma)) = mac_address::get_mac_address() {
|
||||
for x in &ma.bytes()[2..] {
|
||||
id = (id << 8) | (*x as u32);
|
||||
}
|
||||
id = id & 0x1FFFFFFF;
|
||||
Some(id.to_string())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
id = id & 0x1FFFFFFF;
|
||||
Some(id.to_string())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,3 @@
|
||||
pub mod ffi;
|
||||
use std::sync::RwLock;
|
||||
|
||||
pub use ffi::*;
|
||||
|
||||
use lazy_static::lazy_static;
|
||||
|
@ -6,10 +6,12 @@ use std::{
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
pub use arboard::Clipboard as ClipboardContext;
|
||||
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
use hbb_common::compress::decompress;
|
||||
use hbb_common::{
|
||||
allow_err,
|
||||
anyhow::bail,
|
||||
compress::{compress as compress_func, decompress},
|
||||
compress::{compress as compress_func},
|
||||
config::{self, Config, COMPRESS_LEVEL, RENDEZVOUS_TIMEOUT},
|
||||
get_version_number, log,
|
||||
message_proto::*,
|
||||
|
@ -16,8 +16,6 @@ use hbb_common::{
|
||||
// use crate::hbbs_http::account::AuthResult;
|
||||
|
||||
use crate::flutter::{self, SESSIONS};
|
||||
#[cfg(target_os = "android")]
|
||||
use crate::start_server;
|
||||
use crate::ui_interface::{self, *};
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
use crate::ui_session_interface::CUR_SESSION;
|
||||
@ -838,7 +836,12 @@ pub fn main_is_root() -> bool {
|
||||
}
|
||||
|
||||
pub fn get_double_click_time() -> SyncReturn<i32> {
|
||||
SyncReturn(crate::platform::get_double_click_time() as _)
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
{
|
||||
return SyncReturn(crate::platform::get_double_click_time() as _);
|
||||
}
|
||||
#[cfg(any(target_os = "android", target_os = "ios"))]
|
||||
SyncReturn(500i32)
|
||||
}
|
||||
|
||||
pub fn main_start_dbus_server() {
|
||||
@ -1133,7 +1136,7 @@ pub mod server_side {
|
||||
JNIEnv,
|
||||
};
|
||||
|
||||
use hbb_common::{config::Config, log};
|
||||
use hbb_common::log;
|
||||
|
||||
use crate::start_server;
|
||||
|
||||
|
@ -14,6 +14,7 @@ pub mod macos;
|
||||
#[cfg(target_os = "linux")]
|
||||
pub mod linux;
|
||||
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
use hbb_common::{message_proto::CursorData, ResultType};
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
const SERVICE_INTERVAL: u64 = 300;
|
||||
|
@ -5,7 +5,7 @@ use hbb_common::{
|
||||
allow_err,
|
||||
anyhow::{anyhow, Context},
|
||||
bail,
|
||||
config::{Config, Config2, CONNECT_TIMEOUT, RELAY_PORT},
|
||||
config::{Config, CONNECT_TIMEOUT, RELAY_PORT},
|
||||
log,
|
||||
message_proto::*,
|
||||
protobuf::{Enum, Message as _},
|
||||
@ -14,7 +14,11 @@ use hbb_common::{
|
||||
sodiumoxide::crypto::{box_, secretbox, sign},
|
||||
timeout, tokio, ResultType, Stream,
|
||||
};
|
||||
use service::{GenericService, Service, ServiceTmpl, Subscriber};
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
use hbb_common::config::Config2;
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
use service::ServiceTmpl;
|
||||
use service::{GenericService, Service, Subscriber};
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
net::SocketAddr,
|
||||
|
@ -27,10 +27,12 @@ use scrap::android::call_main_service_mouse_input;
|
||||
use serde_json::{json, value::Value};
|
||||
use sha2::{Digest, Sha256};
|
||||
use std::sync::{
|
||||
atomic::{AtomicI64, Ordering},
|
||||
atomic::AtomicI64,
|
||||
mpsc as std_mpsc,
|
||||
};
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
use std::sync::atomic::Ordering;
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
use system_shutdown;
|
||||
|
||||
pub type Sender = mpsc::UnboundedSender<(Instant, Arc<Message>)>;
|
||||
|
@ -530,7 +530,7 @@ fn run(sp: GenericService) -> ResultType<()> {
|
||||
frame_controller.set_send(now, send_conn_ids);
|
||||
}
|
||||
scrap::Frame::RAW(data) => {
|
||||
if (data.len() != 0) {
|
||||
if data.len() != 0 {
|
||||
let send_conn_ids =
|
||||
handle_one_frame(&sp, data, ms, &mut encoder, recorder.clone())?;
|
||||
frame_controller.set_send(now, send_conn_ids);
|
||||
|
@ -15,7 +15,7 @@ use std::iter::FromIterator;
|
||||
use clipboard::{cliprdr::CliprdrClientContext, empty_clipboard, set_conn_enabled, ContextSend};
|
||||
use serde_derive::Serialize;
|
||||
|
||||
use crate::ipc::{self, new_listener, Connection, Data};
|
||||
use crate::ipc::{self, Connection, Data};
|
||||
#[cfg(windows)]
|
||||
use hbb_common::tokio::sync::Mutex as TokioMutex;
|
||||
use hbb_common::{
|
||||
@ -434,7 +434,7 @@ pub async fn start_ipc<T: InvokeUiCM>(cm: ConnectionManager<T>) {
|
||||
allow_err!(crate::ui::win_privacy::start());
|
||||
});
|
||||
|
||||
match new_listener("_cm").await {
|
||||
match ipc::new_listener("_cm").await {
|
||||
Ok(mut incoming) => {
|
||||
while let Some(result) = incoming.next().await {
|
||||
match result {
|
||||
|
@ -26,7 +26,7 @@ use hbb_common::{
|
||||
|
||||
#[cfg(feature = "flutter")]
|
||||
use crate::hbbs_http::account;
|
||||
use crate::{common::SOFTWARE_UPDATE_URL, ipc, platform};
|
||||
use crate::{common::SOFTWARE_UPDATE_URL, ipc};
|
||||
|
||||
#[cfg(any(target_os = "android", target_os = "ios", feature = "flutter"))]
|
||||
type Message = RendezvousMessage;
|
||||
@ -253,6 +253,7 @@ pub fn test_if_valid_server(host: String) -> String {
|
||||
|
||||
#[inline]
|
||||
#[cfg(feature = "flutter")]
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
pub fn get_sound_inputs() -> Vec<String> {
|
||||
let mut a = Vec::new();
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
@ -782,7 +783,7 @@ pub fn default_video_save_directory() -> String {
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
if let Some(home) = platform::get_active_user_home() {
|
||||
if let Some(home) = crate::platform::get_active_user_home() {
|
||||
let name = if cfg!(target_os = "macos") {
|
||||
"Movies"
|
||||
} else {
|
||||
|
@ -1,10 +1,10 @@
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
use crate::client::get_key_state;
|
||||
use crate::client::{get_key_state, SERVER_KEYBOARD_ENABLED};
|
||||
use crate::client::io_loop::Remote;
|
||||
use crate::client::{
|
||||
check_if_retry, handle_hash, handle_login_from_ui, handle_test_delay, input_os_password,
|
||||
load_config, send_mouse, start_video_audio_threads, FileManager, Key, LoginConfigHandler,
|
||||
QualityStatus, KEY_MAP, SERVER_KEYBOARD_ENABLED,
|
||||
QualityStatus, KEY_MAP,
|
||||
};
|
||||
#[cfg(target_os = "linux")]
|
||||
use crate::common::IS_X11;
|
||||
@ -16,8 +16,8 @@ use hbb_common::tokio::{self, sync::mpsc};
|
||||
use hbb_common::{allow_err, message_proto::*};
|
||||
use hbb_common::{fs, get_version_number, log, Stream};
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
use rdev::Keyboard as RdevKeyboard;
|
||||
use rdev::{Event, EventType, EventType::*, Key as RdevKey, KeyboardState};
|
||||
use rdev::{Keyboard as RdevKeyboard, KeyboardState};
|
||||
use rdev::{Event, EventType, EventType::*, Key as RdevKey};
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::ops::{Deref, DerefMut};
|
||||
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
|
||||
@ -30,6 +30,7 @@ pub static HOTKEY_HOOKED: AtomicBool = AtomicBool::new(false);
|
||||
#[cfg(windows)]
|
||||
static mut IS_ALT_GR: bool = false;
|
||||
#[cfg(feature = "flutter")]
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
use crate::flutter::FlutterHandler;
|
||||
|
||||
lazy_static::lazy_static! {
|
||||
@ -1570,6 +1571,7 @@ fn get_all_hotkey_state(
|
||||
}
|
||||
|
||||
#[cfg(feature = "flutter")]
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
pub fn send_key_event_to_session(event: rdev::Event) {
|
||||
if let Some(handler) = CUR_SESSION.lock().unwrap().as_ref() {
|
||||
handler.handle_hotkey_event(event);
|
||||
|
Loading…
Reference in New Issue
Block a user