Skip to content

Commit

Permalink
Add Microphone Permissions prompt to macOS app
Browse files Browse the repository at this point in the history
Requests permission when saving a VM with HDA card.
Does not fix the guest mic access issue.
  • Loading branch information
conath committed Dec 25, 2021
1 parent 6524c73 commit e64e0af
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Platform/UTMData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import UIKit
#if canImport(AltKit)
import AltKit
#endif
import AVFoundation

@available(iOS 14, macOS 11, *)
struct AlertMessage: Identifiable {
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions Platform/macOS/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
<string>public.app-category.business</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSMicrophoneUsageDescription</key>
<string>Allow access to allow VMs to use the Microphone.</string>
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
Expand Down
2 changes: 2 additions & 0 deletions Platform/macOS/macOS-unsigned.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<true/>
<key>com.apple.security.cs.disable-library-validation</key>
<true/>
<key>com.apple.security.device.audio-input</key>
<true/>
<key>com.apple.security.files.user-selected.read-write</key>
<true/>
<key>com.apple.security.network.client</key>
Expand Down

0 comments on commit e64e0af

Please sign in to comment.