fix(mac): open settings for microphone permission
This commit is contained in:
@@ -67,12 +67,27 @@ enum PermissionManager {
|
|||||||
results[cap] = ScreenRecordingProbe.isAuthorized()
|
results[cap] = ScreenRecordingProbe.isAuthorized()
|
||||||
|
|
||||||
case .microphone:
|
case .microphone:
|
||||||
let granted = AVCaptureDevice.authorizationStatus(for: .audio) == .authorized
|
let status = AVCaptureDevice.authorizationStatus(for: .audio)
|
||||||
if interactive, !granted {
|
switch status {
|
||||||
let ok = await AVCaptureDevice.requestAccess(for: .audio)
|
case .authorized:
|
||||||
results[cap] = ok
|
results[cap] = true
|
||||||
} else {
|
|
||||||
results[cap] = granted
|
case .notDetermined:
|
||||||
|
if interactive {
|
||||||
|
let ok = await AVCaptureDevice.requestAccess(for: .audio)
|
||||||
|
results[cap] = ok
|
||||||
|
} else {
|
||||||
|
results[cap] = false
|
||||||
|
}
|
||||||
|
|
||||||
|
case .denied, .restricted:
|
||||||
|
results[cap] = false
|
||||||
|
if interactive {
|
||||||
|
MicrophonePermissionHelper.openSettings()
|
||||||
|
}
|
||||||
|
|
||||||
|
@unknown default:
|
||||||
|
results[cap] = false
|
||||||
}
|
}
|
||||||
|
|
||||||
case .speechRecognition:
|
case .speechRecognition:
|
||||||
@@ -150,6 +165,21 @@ enum NotificationPermissionHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum MicrophonePermissionHelper {
|
||||||
|
static func openSettings() {
|
||||||
|
let candidates = [
|
||||||
|
"x-apple.systempreferences:com.apple.preference.security?Privacy_Microphone",
|
||||||
|
"x-apple.systempreferences:com.apple.preference.security",
|
||||||
|
]
|
||||||
|
|
||||||
|
for candidate in candidates {
|
||||||
|
if let url = URL(string: candidate), NSWorkspace.shared.open(url) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
enum AppleScriptPermission {
|
enum AppleScriptPermission {
|
||||||
private static let logger = Logger(subsystem: "com.steipete.clawdis", category: "AppleScriptPermission")
|
private static let logger = Logger(subsystem: "com.steipete.clawdis", category: "AppleScriptPermission")
|
||||||
|
|
||||||
|
|||||||
@@ -53,6 +53,8 @@ cat > "$ENT_TMP_BASE" <<'PLIST'
|
|||||||
<dict>
|
<dict>
|
||||||
<key>com.apple.security.automation.apple-events</key>
|
<key>com.apple.security.automation.apple-events</key>
|
||||||
<true/>
|
<true/>
|
||||||
|
<key>com.apple.security.device.audio-input</key>
|
||||||
|
<true/>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
PLIST
|
PLIST
|
||||||
@@ -64,6 +66,8 @@ cat > "$ENT_TMP_APP_BASE" <<'PLIST'
|
|||||||
<dict>
|
<dict>
|
||||||
<key>com.apple.security.automation.apple-events</key>
|
<key>com.apple.security.automation.apple-events</key>
|
||||||
<true/>
|
<true/>
|
||||||
|
<key>com.apple.security.device.audio-input</key>
|
||||||
|
<true/>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
PLIST
|
PLIST
|
||||||
@@ -77,6 +81,8 @@ cat > "$ENT_TMP_APP" <<'PLIST'
|
|||||||
<true/>
|
<true/>
|
||||||
<key>com.apple.security.automation.apple-events</key>
|
<key>com.apple.security.automation.apple-events</key>
|
||||||
<true/>
|
<true/>
|
||||||
|
<key>com.apple.security.device.audio-input</key>
|
||||||
|
<true/>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
PLIST
|
PLIST
|
||||||
|
|||||||
Reference in New Issue
Block a user