From e64e0af100733c052dc1d7c21b0ee9cdebf3aed7 Mon Sep 17 00:00:00 2001 From: conath Date: Sat, 25 Dec 2021 12:40:06 +0100 Subject: [PATCH] Add Microphone Permissions prompt to macOS app Requests permission when saving a VM with HDA card. Does not fix the guest mic access issue. --- Platform/UTMData.swift | 9 +++++++++ Platform/macOS/Info.plist | 2 ++ Platform/macOS/macOS-unsigned.entitlements | 2 ++ 3 files changed, 13 insertions(+) diff --git a/Platform/UTMData.swift b/Platform/UTMData.swift index f89247c12..70d1f9185 100644 --- a/Platform/UTMData.swift +++ b/Platform/UTMData.swift @@ -23,6 +23,7 @@ import UIKit #if canImport(AltKit) import AltKit #endif +import AVFoundation @available(iOS 14, macOS 11, *) struct AlertMessage: Identifiable { @@ -179,6 +180,14 @@ class UTMData: ObservableObject { func save(vm: UTMVirtualMachine) throws { do { + #if os(macOS) + if vm.configuration.soundCard?.contains("hda") ?? false { + /// get mic permisison + AVCaptureDevice.requestAccess(for: .audio) { access in + print(access) + } + } + #endif let oldPath = vm.path try vm.saveUTM() let newPath = vm.path diff --git a/Platform/macOS/Info.plist b/Platform/macOS/Info.plist index 2c25e98ec..0087b9bfb 100644 --- a/Platform/macOS/Info.plist +++ b/Platform/macOS/Info.plist @@ -56,6 +56,8 @@ public.app-category.business LSMinimumSystemVersion $(MACOSX_DEPLOYMENT_TARGET) + NSMicrophoneUsageDescription + Allow access to allow VMs to use the Microphone. UTExportedTypeDeclarations diff --git a/Platform/macOS/macOS-unsigned.entitlements b/Platform/macOS/macOS-unsigned.entitlements index 0094d17fa..1e4d72b5f 100644 --- a/Platform/macOS/macOS-unsigned.entitlements +++ b/Platform/macOS/macOS-unsigned.entitlements @@ -12,6 +12,8 @@ com.apple.security.cs.disable-library-validation + com.apple.security.device.audio-input + com.apple.security.files.user-selected.read-write com.apple.security.network.client