keep server device awake if have connection

Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
21pages
2023-06-05 20:24:16 +08:00
parent f1cc42769c
commit 98740dbfd7
6 changed files with 344 additions and 11 deletions

View File

@@ -506,6 +506,8 @@ fn check_get_displays_changed_msg() -> Option<Message> {
}
fn run(sp: GenericService) -> ResultType<()> {
#[cfg(not(any(target_os = "android", target_os = "ios")))]
let _wake_lock = get_wake_lock();
#[cfg(all(windows, feature = "virtual_display_driver"))]
ensure_close_virtual_device()?;
@@ -1058,3 +1060,16 @@ fn start_uac_elevation_check() {
}
});
}
#[cfg(not(any(target_os = "android", target_os = "ios")))]
fn get_wake_lock() -> crate::platform::WakeLock {
let (display, idle, sleep) = if cfg!(windows) {
(true, false, false)
} else if cfg!(linux) {
(false, false, true)
} else {
//macos
(true, false, false)
};
crate::platform::WakeLock::new(display, idle, sleep)
}