mirror of
https://github.com/VallierDev/uu-remote-linux.git
synced 2026-11-16 08:50:40 +01:00
fix(privacy): accept the Windows viewer's enable=0 encoding (#202)
This commit is contained in:
1 parent
ac9606b872
commit
101123797a
4 files changed
+53
-5
No files matched your search
@@ -81,6 +81,8 @@ is aimed at the virtual output's region. Needs GTK3.
|
||||
Success does not send ReportError; -9 in Mac 4.43.0 reports a system session change, not privacy success.
|
||||
- iOS 控制端选“关闭显示器”发 `enable=0, privacy_type=3`:iOS 的 `enable` 是图片模式开关,关屏意图由 `type=3` 表达;iOS“不启用”发 `enable=0, privacy_type=1`。主机只对 iOS 控制端把 `0/3` 归一化为开屏保关屏(日志 `iOS screen-off encoding normalized`),其他控制端(包括已验收的 Android 4.43.0)保持字段 1 的语义。
|
||||
The iOS viewer sends `enable=0, privacy_type=3` for "turn off the display": its `enable` is the picture-mode switch and `type=3` carries the intent; iOS "off" is `enable=0, privacy_type=1`. The host normalizes `0/3` to screen-off for iOS controllers only (log: `iOS screen-off encoding normalized`); other controllers, including the verified Android 4.43.0, keep the field-1 semantics.
|
||||
- Windows 控制端每个 RPC 7 都带 `enable=0`,意图全在 `type`:`0/0` 关闭、`0/2` 屏保、`0/3` 关屏。其中 `0/0` 和 `0/2` 已在 Windows 客户端上实测;主机只对 `controller_platform=1` 做这层归一化(日志 `Windows encoding normalized`),Android 和 macOS 保持字段 1 的语义。
|
||||
The Windows viewer sends every RPC 7 with `enable=0` and carries the intent in `type`: `0/0` off, `0/2` picture, `0/3` screen off. `0/0` and `0/2` were verified live on the Windows client. The host normalizes this for `controller_platform=1` only (log: `Windows encoding normalized`); Android and macOS keep the field-1 semantics.
|
||||
- RPC 25 `update_screen_saver_req` → RpcResponse 21:开启隐私模式前发送,主机回空成功应答,画面仍用本机壁纸。
|
||||
Sent before picture mode; answered empty (success), the host keeps its own wallpaper.
|
||||
- FeatureFlag 4 `ff_private_screen` = 2 (ENHANCED_PRIVACY);SettingMetric 4 `private_screen`、7 `private_screen_type`
|
||||
|
||||
+5
-2
@@ -81,7 +81,7 @@ fn finger_held(finger: Finger, now: std::time::Instant) -> Option<(i32,i32)> {
|
||||
/// Viewer platform from the connect header `controller_platform` (website enum: 1 windows, 2 android,
|
||||
/// 3 ios, 4 macos, 5 tv).
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
||||
pub enum Controller { #[default] Other, Mac, Mobile, Ios }
|
||||
pub enum Controller { #[default] Other, Windows, Mac, Mobile, Ios }
|
||||
impl Controller {
|
||||
/// Touch semantics cover both mobile platforms; the iOS RPC 7 screen-off encoding is its own quirk.
|
||||
pub fn is_mobile(self) -> bool { matches!(self, Self::Mobile | Self::Ios) }
|
||||
@@ -92,9 +92,11 @@ impl Controller {
|
||||
Some(4) => Self::Mac,
|
||||
Some(3) => Self::Ios,
|
||||
Some(2) => Self::Mobile,
|
||||
Some(1) => Self::Windows,
|
||||
_ if text.as_deref().is_some_and(|s| s.contains("mac") || s.contains("darwin")) => Self::Mac,
|
||||
_ if text.as_deref().is_some_and(|s| s.contains("ios") || s.contains("iphone") || s.contains("ipad")) => Self::Ios,
|
||||
_ if text.as_deref().is_some_and(|s| s.contains("android")) => Self::Mobile,
|
||||
_ if text.as_deref().is_some_and(|s| s.contains("windows")) => Self::Windows,
|
||||
_ => Self::Other,
|
||||
}
|
||||
}
|
||||
@@ -1310,7 +1312,8 @@ mod touch_tests {
|
||||
assert!(!Controller::Mac.is_mobile());
|
||||
assert_eq!(Controller::from_platform(Some(&json!(4))), Controller::Mac);
|
||||
assert_eq!(Controller::from_platform(Some(&json!("MacOS"))), Controller::Mac);
|
||||
assert_eq!(Controller::from_platform(Some(&json!(1))), Controller::Other);
|
||||
assert_eq!(Controller::from_platform(Some(&json!(1))), Controller::Windows);
|
||||
assert_eq!(Controller::from_platform(Some(&json!("Windows"))), Controller::Windows);
|
||||
assert_eq!(Controller::from_platform(None), Controller::Other);
|
||||
}
|
||||
#[test]
|
||||
|
||||
@@ -25,14 +25,17 @@ static POINTER: Mutex<Option<[f64; 4]>> = Mutex::new(None);
|
||||
/// ends. An auto-enable never overrides it, including an RPC that arrives after the connection
|
||||
/// opens but before `session_started` bumps the counter.
|
||||
static VIEWER_OVERRIDE: AtomicBool = AtomicBool::new(false);
|
||||
/// iOS viewers encode "screen off" as `enable=0, type=3`; see
|
||||
/// `protocol::Request::normalize_ios_screen_off`.
|
||||
/// iOS viewers encode "screen off" as `enable=0, type=3`, and Windows viewers carry every request
|
||||
/// in `type` with `enable=0`; see `protocol::Request::normalize_ios_screen_off` and
|
||||
/// `protocol::Request::normalize_windows`.
|
||||
static VIEWER_IOS: AtomicBool = AtomicBool::new(false);
|
||||
static VIEWER_WINDOWS: AtomicBool = AtomicBool::new(false);
|
||||
|
||||
pub fn supported() -> bool { backend::detect().is_some() }
|
||||
/// Record the desktop controller's platform for the iOS RPC 7 encoder quirk.
|
||||
/// Record the desktop controller's platform for the RPC 7 encoder quirks.
|
||||
pub fn set_viewer_controller(controller: crate::input::Controller) {
|
||||
VIEWER_IOS.store(controller == crate::input::Controller::Ios, Ordering::Relaxed);
|
||||
VIEWER_WINDOWS.store(controller == crate::input::Controller::Windows, Ordering::Relaxed);
|
||||
}
|
||||
pub fn active() -> bool { ACTIVE.load(Ordering::Relaxed) }
|
||||
/// The viewer's privacy_type now in effect.
|
||||
@@ -125,6 +128,9 @@ pub fn rpc_accept(rpc: &[crate::protocol::WireField]) -> Option<(Vec<u8>, Option
|
||||
// as an accepted request would.
|
||||
VIEWER_OVERRIDE.store(true, Ordering::Relaxed);
|
||||
log::info!("Privacy request: iOS screen-off encoding normalized (enable=0 type=3)");
|
||||
} else if request.normalize_windows(VIEWER_WINDOWS.load(Ordering::Relaxed)) {
|
||||
VIEWER_OVERRIDE.store(true, Ordering::Relaxed);
|
||||
log::info!("Privacy request: Windows encoding normalized (enable=0 mode={:?})", request.mode);
|
||||
}
|
||||
if let Some(e) = refuse(request.enable, request.mode) {
|
||||
log::warn!("Privacy request refused: enable={} mode={:?}: {e}", request.enable, request.mode);
|
||||
|
||||
@@ -17,6 +17,16 @@ impl Request {
|
||||
}
|
||||
false
|
||||
}
|
||||
/// Windows viewers send every privacy request with `enable=0` and carry the intent in
|
||||
/// `privacy_type`: `0/0` is off, `0/2` picture and `0/3` screen-off (verified live on the
|
||||
/// Windows client). Android 4.43.0 and macOS keep field 1 as the master switch.
|
||||
pub fn normalize_windows(&mut self, windows: bool) -> bool {
|
||||
if windows && !self.enable && self.mode.is_some() {
|
||||
self.enable = true;
|
||||
return true;
|
||||
}
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
pub fn parse(rpc: &[crate::protocol::WireField]) -> Option<(Vec<u8>, Request)> {
|
||||
@@ -106,4 +116,31 @@ mod tests {
|
||||
assert!(!request.normalize_ios_screen_off(true));
|
||||
assert!(request.enable);
|
||||
}
|
||||
#[test]
|
||||
fn normalizes_windows_encoding_only() {
|
||||
// Windows: enable is always 0, the type carries the intent.
|
||||
for (wire, mode) in [(2u8, Mode::Picture), (3u8, Mode::ScreenOff)] {
|
||||
let bytes = [10, 2, 8, 42, 58, 4, 8, 0, 16, wire];
|
||||
let (_, mut request) = parse(&crate::protocol::decode_wire(&bytes).unwrap()).unwrap();
|
||||
assert!(request.normalize_windows(true));
|
||||
assert!(request.enable);
|
||||
assert_eq!(request.mode, Some(mode));
|
||||
}
|
||||
// Off stays off: type 0 (seen when the Windows switch is turned off) and type 1.
|
||||
for wire in [0u8, 1] {
|
||||
let bytes = [10, 2, 8, 42, 58, 4, 8, 0, 16, wire];
|
||||
let (_, mut request) = parse(&crate::protocol::decode_wire(&bytes).unwrap()).unwrap();
|
||||
assert!(!request.normalize_windows(true));
|
||||
assert!(!request.enable);
|
||||
}
|
||||
// Other platforms and explicit enables are untouched.
|
||||
let picture = crate::protocol::decode_wire(&[10, 2, 8, 42, 58, 4, 8, 0, 16, 2]).unwrap();
|
||||
let (_, mut request) = parse(&picture).unwrap();
|
||||
assert!(!request.normalize_windows(false));
|
||||
assert!(!request.enable);
|
||||
let explicit = crate::protocol::decode_wire(&[10, 2, 8, 42, 58, 4, 8, 1, 16, 2]).unwrap();
|
||||
let (_, mut request) = parse(&explicit).unwrap();
|
||||
assert!(!request.normalize_windows(true));
|
||||
assert!(request.enable);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user