JPackage and ask for microphone permissions broken on OSX...

Andy Herrick andy.herrick at oracle.com
Wed Aug 18 12:43:08 UTC 2021


OK - I have reproduced this problem, filed an issue, and found the fix.

You can see the issue in https://bugs.openjdk.java.net/browse/JDK-8272639.

Basically another key is needed in application plist to cause 
application to ask for microphone access.

It is far to late to get any fix into JDK17, but I will fix in JDK18 and 
you can work around this issue in JDK17 (or JDK16) by using the 
--resource-dir option:

/Andy


> 1.) create an empty directory test-resources
> 2.) copy from the openjdk sources the file 
> src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/resources/Info-lite.plist.template 
> to test-resources/Info.plist.
> 3.) edit test-resources/info.plist to include the key:
>    <key>NSMicrophoneUsageDescription</key>
>     <string>The application is requesting access to the 
> microphone.</string>
> 4.) now add "--resource-dir test-resources" option to your jpackage 
> command, and it will use this plist template instead of the default one. 

On 8/16/21 7:41 PM, Filteredaccount1 wrote:
> Hi Core-libs-dev,
>
> I’m trying to report an issue with JPackage on recent versions of OSX.
>
> Problem is, the microphone permissions aren’t granted to applications created by jpackage. The resulting recorded 16 bit PCM line in samples files are the correct duration, but don’t have any sound (samples all set to 0).
>
> System Preferences -> Security & Privacy -> Privacy -> Microphone
> (application never asks for permissions)
>
> Otherwise, the only workaround I can figure out is to have the app launch then bootstrap itself using Runtime and grant applications to the Terminal.app (when it calls itself from `java Application.app/MacOS/Resources/Application`)
>
> There are various reports of this on the Internet - but I’m wondering if the JPackage team is aware of the issue.
>
> https://stackoverflow.com/questions/55727488/application-doesnt-ask-for-permission-to-access-microphone-in-macos-10-14-mojav
>
> This pretty much shows the solution - needs a bit of Objective C though.
>
> Reproducing the problem: JPackage any java sound recording app on latest OSX, run it... will be unable to capture sound. Run the same code from the command line, via classpath or modules... it will record audio after asking the user to grant microphone permissions to Terminal.app.
>
> It would be great if this is fixed in JDK 17.
>
>
> Many Thanks,
>
>
> Ben S


More information about the core-libs-dev mailing list