Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macOS: How to request microphone access? #281

Closed
tresf opened this issue Mar 23, 2021 · 3 comments
Closed

macOS: How to request microphone access? #281

tresf opened this issue Mar 23, 2021 · 3 comments
Labels
help wanted Extra attention is needed question Further information is requested stale

Comments

@tresf
Copy link

tresf commented Mar 23, 2021

Question

Why won't Java ask for Microphone access? How does one package a Java application so that will properly ask for permission to use the microphone?

Please see the following unit test: https://github.com/tresf/SoundRecorder.

Test Pass/Fail Details
Terminal ✅ PASS javac SoundRecorder.java && java SoundRecorder, from Terminal, it works.
Reset with: sudo tccutil reset Microphone com.apple.Terminal
IntelliJ ✅ PASS From the Project Explorer, Right Click SoundRecorder.java, Run. It works.
Reset with: sudo tccutil reset Microphone com.jetbrains.intellij.ce
Bundle 🚫 FAIL ./package.sh, double-click SoundRecorer.app. It doesn't work.

Passing criteria:

  • MacOS should prompt for permission to access the microphone, the resulting .wav file should contain audio, not silence.

Some initial observations:

  • Failing tests produce a silent .wav file for the specified duration. No prompt; no Java exceptions thrown.
  • Successful test show the parent app, not Java. e.g. "IntellIJ would like to access the Microphone".
  • You only get one chance to Approve. Dismissing the dialog will assume "No" and the option will need to be manually added using System Preferences, Security & Privacy, Privacy, Microphone.
  • Unlike other macOS privacy settings, there's currently no way to manually add an App to the Microphone area.

Java version tested:

  • AdoptOpenJDK 11.0.10
  • API: AudioSystem.getLine(...).open(...)

Some general questions:

  • Are entitlements required for Microphone access to work?
  • Can entitlements be applied to a non-binary (e.g shell script) executables?

Related questions:

Note: Big Sur can have caching issues between signing steps.

@tresf
Copy link
Author

tresf commented Mar 23, 2021

Some general questions:

  • Are entitlements required for Microphone access to work?

This Unity thread suggests they may be needed:

Quoting:

We discovered that in addition to ensuring NSMicrophoneUsageDescription
was in the plist in the mac app bundle package Contents when built, these entitlements also needed to be set:

com.apple.security.device.audio-input
com.apple.security.device.microphone

Then the signtool must be run (and a cert may be required)

... however signing with these entitlements alone doesn't seem to fix the symptom.

@karianna karianna added help wanted Extra attention is needed question Further information is requested labels Mar 26, 2021
@github-actions
Copy link

github-actions bot commented May 6, 2022

We are marking this issue as stale because it has not been updated for a while. This is just a way to keep the support issues queue manageable.
It will be closed soon unless the stale label is removed by a committer, or a new comment is made.

@github-actions github-actions bot added the stale label May 6, 2022
@karianna
Copy link
Contributor

Fixed in 17.0.2 (but not backported)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed question Further information is requested stale
Projects
None yet
Development

No branches or pull requests

2 participants