Merge pull request #6361 from fufesou/fix/check_update_broker_on_privacy_start
fix, run check_update_broker_process on privacy mode start
This commit is contained in:
commit
7a6e483171
@ -857,8 +857,18 @@ pub fn check_update_broker_process() -> ResultType<()> {
|
|||||||
};
|
};
|
||||||
let cur_exe = cur_dir.join(process_exe);
|
let cur_exe = cur_dir.join(process_exe);
|
||||||
|
|
||||||
|
// Force update broker exe if failed to check modified time.
|
||||||
|
let cmds = format!(
|
||||||
|
"
|
||||||
|
chcp 65001
|
||||||
|
taskkill /F /IM {process_exe}
|
||||||
|
copy /Y \"{origin_process_exe}\" \"{cur_exe}\"
|
||||||
|
",
|
||||||
|
cur_exe = cur_exe.to_string_lossy(),
|
||||||
|
);
|
||||||
|
|
||||||
if !std::path::Path::new(&cur_exe).exists() {
|
if !std::path::Path::new(&cur_exe).exists() {
|
||||||
std::fs::copy(origin_process_exe, cur_exe)?;
|
run_cmds(cmds, false, "update_broker")?;
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -877,15 +887,6 @@ pub fn check_update_broker_process() -> ResultType<()> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Force update broker exe if failed to check modified time.
|
|
||||||
let cmds = format!(
|
|
||||||
"
|
|
||||||
chcp 65001
|
|
||||||
taskkill /F /IM {process_exe}
|
|
||||||
copy /Y \"{origin_process_exe}\" \"{cur_exe}\"
|
|
||||||
",
|
|
||||||
cur_exe = cur_exe.to_string_lossy(),
|
|
||||||
);
|
|
||||||
run_cmds(cmds, false, "update_broker")?;
|
run_cmds(cmds, false, "update_broker")?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -83,6 +83,14 @@ impl WindowHandlers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn turn_on_privacy(conn_id: i32) -> ResultType<bool> {
|
pub fn turn_on_privacy(conn_id: i32) -> ResultType<bool> {
|
||||||
|
let pre_conn_id = *CONN_ID.lock().unwrap();
|
||||||
|
if pre_conn_id == conn_id {
|
||||||
|
return Ok(true);
|
||||||
|
}
|
||||||
|
if pre_conn_id != 0 {
|
||||||
|
bail!("Privacy occupied by another one");
|
||||||
|
}
|
||||||
|
|
||||||
let exe_file = std::env::current_exe()?;
|
let exe_file = std::env::current_exe()?;
|
||||||
if let Some(cur_dir) = exe_file.parent() {
|
if let Some(cur_dir) = exe_file.parent() {
|
||||||
if !cur_dir.join("WindowInjection.dll").exists() {
|
if !cur_dir.join("WindowInjection.dll").exists() {
|
||||||
@ -101,14 +109,6 @@ pub fn turn_on_privacy(conn_id: i32) -> ResultType<bool> {
|
|||||||
std::thread::sleep(std::time::Duration::from_millis(1_000));
|
std::thread::sleep(std::time::Duration::from_millis(1_000));
|
||||||
}
|
}
|
||||||
|
|
||||||
let pre_conn_id = *CONN_ID.lock().unwrap();
|
|
||||||
if pre_conn_id == conn_id {
|
|
||||||
return Ok(true);
|
|
||||||
}
|
|
||||||
if pre_conn_id != 0 {
|
|
||||||
bail!("Privacy occupied by another one");
|
|
||||||
}
|
|
||||||
|
|
||||||
let hwnd = wait_find_privacy_hwnd(0)?;
|
let hwnd = wait_find_privacy_hwnd(0)?;
|
||||||
if hwnd.is_null() {
|
if hwnd.is_null() {
|
||||||
bail!("No privacy window created");
|
bail!("No privacy window created");
|
||||||
@ -152,6 +152,14 @@ pub fn start() -> ResultType<()> {
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log::info!("Start privacy mode window broker, check_update_broker_process");
|
||||||
|
if let Err(e) = crate::platform::windows::check_update_broker_process() {
|
||||||
|
log::warn!(
|
||||||
|
"Failed to check update broker process. Privacy mode may not work properly. {}",
|
||||||
|
e
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
let exe_file = std::env::current_exe()?;
|
let exe_file = std::env::current_exe()?;
|
||||||
let Some(cur_dir) = exe_file
|
let Some(cur_dir) = exe_file
|
||||||
.parent() else {
|
.parent() else {
|
||||||
|
@ -567,17 +567,6 @@ impl<T: InvokeUiCM> IpcTaskRunner<T> {
|
|||||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
#[tokio::main(flavor = "current_thread")]
|
#[tokio::main(flavor = "current_thread")]
|
||||||
pub async fn start_ipc<T: InvokeUiCM>(cm: ConnectionManager<T>) {
|
pub async fn start_ipc<T: InvokeUiCM>(cm: ConnectionManager<T>) {
|
||||||
#[cfg(windows)]
|
|
||||||
std::thread::spawn(move || {
|
|
||||||
log::info!("try create privacy mode window");
|
|
||||||
if let Err(e) = crate::platform::windows::check_update_broker_process() {
|
|
||||||
log::warn!(
|
|
||||||
"Failed to check update broker process. Privacy mode may not work properly. {}",
|
|
||||||
e
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
#[cfg(any(
|
#[cfg(any(
|
||||||
target_os = "windows",
|
target_os = "windows",
|
||||||
all(
|
all(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user