elevation prompt && uac warning

Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
21pages
2022-09-27 13:30:49 +08:00
parent e1c2b8de6e
commit 728985e3bf
32 changed files with 156 additions and 16 deletions

View File

@@ -229,6 +229,8 @@ impl Connection {
#[cfg(not(any(target_os = "android", target_os = "ios")))]
std::thread::spawn(move || Self::handle_input(rx_input, tx_cloned));
let mut second_timer = time::interval(Duration::from_secs(1));
let mut uac = false;
loop {
tokio::select! {
@@ -400,6 +402,19 @@ impl Connection {
break;
}
},
_ = second_timer.tick() => {
let is_uac = crate::video_service::IS_UAC_RUNNING.lock().unwrap().clone();
if uac != is_uac {
if !crate::platform::is_installed() && !crate::platform::is_root() {
uac = is_uac;
let mut misc = Misc::new();
misc.set_uac(uac);
let mut msg = Message::new();
msg.set_misc(misc);
conn.inner.send(msg.into());
}
}
}
_ = test_delay_timer.tick() => {
if last_recv_time.elapsed() >= SEC30 {
conn.on_close("Timeout", true).await;

View File

@@ -33,6 +33,7 @@ use std::{
collections::HashSet,
io::ErrorKind::WouldBlock,
ops::{Deref, DerefMut},
sync::Once,
time::{self, Duration, Instant},
};
#[cfg(windows)]
@@ -51,6 +52,7 @@ lazy_static::lazy_static! {
static ref PRIVACY_MODE_CONN_ID: Mutex<i32> = Mutex::new(0);
static ref IS_CAPTURER_MAGNIFIER_SUPPORTED: bool = is_capturer_mag_supported();
pub static ref VIDEO_QOS: Arc<Mutex<VideoQoS>> = Default::default();
pub static ref IS_UAC_RUNNING: Arc<Mutex<bool>> = Default::default();
}
fn is_capturer_mag_supported() -> bool {
@@ -451,6 +453,8 @@ fn run(sp: GenericService) -> ResultType<()> {
};
#[cfg(any(target_os = "android", target_os = "ios"))]
let recorder: Arc<Mutex<Option<Recorder>>> = Default::default();
#[cfg(windows)]
start_uac_check();
while sp.ok() {
#[cfg(windows)]
@@ -832,3 +836,18 @@ pub(super) fn get_current_display_2(mut all: Vec<Display>) -> ResultType<(usize,
fn get_current_display() -> ResultType<(usize, usize, Display)> {
get_current_display_2(try_get_displays()?)
}
#[cfg(windows)]
fn start_uac_check() {
static START: Once = Once::new();
START.call_once(|| {
if !crate::platform::is_installed() && !crate::platform::is_root() {
std::thread::spawn(|| loop {
std::thread::sleep(std::time::Duration::from_secs(1));
if let Ok(uac) = crate::ui::win_privacy::is_process_consent_running() {
*IS_UAC_RUNNING.lock().unwrap() = uac;
}
});
}
});
}