mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-02-17 22:11:30 +08:00
fix: android clipboard permission (#10223)
* fix: android clipboard permission Signed-off-by: fufesou <linlong1266@gmail.com> * refact: Android, clipboard, floating ball Call rust to check if clipboard is enabled. Signed-off-by: fufesou <linlong1266@gmail.com> --------- Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
@@ -463,11 +463,6 @@ impl Connection {
|
||||
conn.on_close("connection manager", true).await;
|
||||
break;
|
||||
}
|
||||
#[cfg(target_os = "android")]
|
||||
ipc::Data::InputControl(v) => {
|
||||
conn.keyboard = v;
|
||||
conn.send_permission(Permission::Keyboard, v).await;
|
||||
}
|
||||
ipc::Data::CmErr(e) => {
|
||||
if e != "expected" {
|
||||
// cm closed before connection
|
||||
@@ -492,6 +487,9 @@ impl Connection {
|
||||
conn.keyboard = enabled;
|
||||
conn.send_permission(Permission::Keyboard, enabled).await;
|
||||
if let Some(s) = conn.server.upgrade() {
|
||||
s.write().unwrap().subscribe(
|
||||
super::clipboard_service::NAME,
|
||||
conn.inner.clone(), conn.can_sub_clipboard_service());
|
||||
s.write().unwrap().subscribe(
|
||||
NAME_CURSOR,
|
||||
conn.inner.clone(), enabled || conn.show_remote_cursor);
|
||||
@@ -502,7 +500,7 @@ impl Connection {
|
||||
if let Some(s) = conn.server.upgrade() {
|
||||
s.write().unwrap().subscribe(
|
||||
super::clipboard_service::NAME,
|
||||
conn.inner.clone(), conn.clipboard_enabled() && conn.peer_keyboard_enabled());
|
||||
conn.inner.clone(), conn.can_sub_clipboard_service());
|
||||
}
|
||||
} else if &name == "audio" {
|
||||
conn.audio = enabled;
|
||||
@@ -1372,16 +1370,7 @@ impl Connection {
|
||||
if !self.follow_remote_window {
|
||||
noperms.push(NAME_WINDOW_FOCUS);
|
||||
}
|
||||
// Do not consider the clipboard and keyboard permissions on Android.
|
||||
// Because syncing the clipboard on Android is manually triggered by the user in the floating ball.
|
||||
#[cfg(target_os = "android")]
|
||||
let keyboard_clip_noperm = self.disable_keyboard || self.disable_clipboard;
|
||||
#[cfg(not(target_os = "android"))]
|
||||
let keyboard_clip_noperm =
|
||||
!self.clipboard_enabled() || !self.peer_keyboard_enabled();
|
||||
if keyboard_clip_noperm
|
||||
|| crate::get_builtin_option(keys::OPTION_ONE_WAY_CLIPBOARD_REDIRECTION) == "Y"
|
||||
{
|
||||
if !self.can_sub_clipboard_service() {
|
||||
noperms.push(super::clipboard_service::NAME);
|
||||
}
|
||||
if !self.audio_enabled() {
|
||||
@@ -1453,6 +1442,13 @@ impl Connection {
|
||||
self.clipboard && !self.disable_clipboard
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn can_sub_clipboard_service(&self) -> bool {
|
||||
self.clipboard_enabled()
|
||||
&& self.peer_keyboard_enabled()
|
||||
&& crate::get_builtin_option(keys::OPTION_ONE_WAY_CLIPBOARD_REDIRECTION) != "Y"
|
||||
}
|
||||
|
||||
fn audio_enabled(&self) -> bool {
|
||||
self.audio && !self.disable_audio
|
||||
}
|
||||
@@ -2930,7 +2926,7 @@ impl Connection {
|
||||
s.write().unwrap().subscribe(
|
||||
super::clipboard_service::NAME,
|
||||
self.inner.clone(),
|
||||
self.clipboard_enabled() && self.peer_keyboard_enabled(),
|
||||
self.can_sub_clipboard_service(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -2942,7 +2938,7 @@ impl Connection {
|
||||
s.write().unwrap().subscribe(
|
||||
super::clipboard_service::NAME,
|
||||
self.inner.clone(),
|
||||
self.clipboard_enabled() && self.peer_keyboard_enabled(),
|
||||
self.can_sub_clipboard_service(),
|
||||
);
|
||||
s.write().unwrap().subscribe(
|
||||
NAME_CURSOR,
|
||||
|
||||
Reference in New Issue
Block a user