try to fix issue #3261 with new api, but not sure if it works
This commit is contained in:
parent
4e19777ba0
commit
a96eb236c1
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -5146,7 +5146,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustdesk"
|
name = "rustdesk"
|
||||||
version = "1.2.0"
|
version = "1.2.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"android_logger",
|
"android_logger",
|
||||||
"arboard",
|
"arboard",
|
||||||
|
@ -4,6 +4,27 @@
|
|||||||
#include <Security/Authorization.h>
|
#include <Security/Authorization.h>
|
||||||
#include <Security/AuthorizationTags.h>
|
#include <Security/AuthorizationTags.h>
|
||||||
|
|
||||||
|
extern "C" bool CanUseNewApiForScreenCaptureCheck() {
|
||||||
|
#ifdef NO_InputMonitoringAuthStatus
|
||||||
|
return false;
|
||||||
|
#else
|
||||||
|
NSOperatingSystemVersion version = [[NSProcessInfo processInfo] operatingSystemVersion];
|
||||||
|
return version.majorVersion >= 11;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" bool IsCanScreenRecording(bool prompt) {
|
||||||
|
#ifdef NO_InputMonitoringAuthStatus
|
||||||
|
return false;
|
||||||
|
#else
|
||||||
|
bool res = CGPreflightScreenCaptureAccess();
|
||||||
|
if (!res && prompt) {
|
||||||
|
CGRequestScreenCaptureAccess();
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// https://github.com/codebytere/node-mac-permissions/blob/main/permissions.mm
|
// https://github.com/codebytere/node-mac-permissions/blob/main/permissions.mm
|
||||||
|
|
||||||
|
@ -34,6 +34,8 @@ extern "C" {
|
|||||||
static kAXTrustedCheckOptionPrompt: CFStringRef;
|
static kAXTrustedCheckOptionPrompt: CFStringRef;
|
||||||
fn AXIsProcessTrustedWithOptions(options: CFDictionaryRef) -> BOOL;
|
fn AXIsProcessTrustedWithOptions(options: CFDictionaryRef) -> BOOL;
|
||||||
fn InputMonitoringAuthStatus(_: BOOL) -> BOOL;
|
fn InputMonitoringAuthStatus(_: BOOL) -> BOOL;
|
||||||
|
fn IsCanScreenRecording(_: BOOL) -> BOOL;
|
||||||
|
fn CanUseNewApiForScreenCaptureCheck() -> BOOL;
|
||||||
fn MacCheckAdminAuthorization() -> BOOL;
|
fn MacCheckAdminAuthorization() -> BOOL;
|
||||||
fn MacGetModeNum(display: u32, numModes: *mut u32) -> BOOL;
|
fn MacGetModeNum(display: u32, numModes: *mut u32) -> BOOL;
|
||||||
fn MacGetModes(
|
fn MacGetModes(
|
||||||
@ -71,6 +73,14 @@ pub fn is_can_input_monitoring(prompt: bool) -> bool {
|
|||||||
// https://stackoverflow.com/questions/56597221/detecting-screen-recording-settings-on-macos-catalina/
|
// https://stackoverflow.com/questions/56597221/detecting-screen-recording-settings-on-macos-catalina/
|
||||||
// remove just one app from all the permissions: tccutil reset All com.carriez.rustdesk
|
// remove just one app from all the permissions: tccutil reset All com.carriez.rustdesk
|
||||||
pub fn is_can_screen_recording(prompt: bool) -> bool {
|
pub fn is_can_screen_recording(prompt: bool) -> bool {
|
||||||
|
// we got some report that we show no permission even after set it, so we try to use new api for screen recording check
|
||||||
|
// the new api is only available on macOS >= 10.15, but on stackoverflow, some people said it works on >= 10.16 (crash on 10.15),
|
||||||
|
// but also some said it has bug on 10.16, so we just use it on 11.0.
|
||||||
|
unsafe {
|
||||||
|
if CanUseNewApiForScreenCaptureCheck() == YES {
|
||||||
|
return IsCanScreenRecording(if prompt { YES } else { NO }) == YES;
|
||||||
|
}
|
||||||
|
}
|
||||||
let mut can_record_screen: bool = false;
|
let mut can_record_screen: bool = false;
|
||||||
unsafe {
|
unsafe {
|
||||||
let our_pid: i32 = std::process::id() as _;
|
let our_pid: i32 = std::process::id() as _;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user