fix: avoid restarting alt-tab in some rare scenarios (#825)

This commit is contained in:
Louis Pontoise
2021-02-23 23:41:59 +09:00
committed by lwouis
parent 58025aff52
commit 4003df41e1
+11 -1
View File
@@ -36,10 +36,20 @@ class SystemPermissions {
}
static func observePermissionsPostStartup() {
var counter = 0
timer = Timer(timeInterval: 5, repeats: true, block: { _ in
if !(accessibilityIsGranted() && screenRecordingIsGranted()) {
if !accessibilityIsGranted() {
App.app.restart()
}
if !screenRecordingIsGranted() {
// permission check may yield a false negative during wake-up
// we restart after 2 negative checks
if counter >= 2 {
App.app.restart()
} else {
counter += 1
}
}
})
timer.tolerance = 4.9
CFRunLoopAddTimer(BackgroundWork.systemPermissionsThread.runLoop, timer, .defaultMode)