Search code examples
androidaudio

Audio capture permission for an Android system app


I was able to create a system app to capture the audio of other apps in an Android 10 system using the Android playback capture API. It failed to capture sound of some apps with target SDK of 28 however (it will work once I upgrade those apps to target SDK 29).

It's puzzling because according to the Android official document and also this blog, system app by default should be able to capture the sound of other apps unless it was forbidden by the app intentionally (not in my case).


Solution

  • Thanks to the help from my coworker, my app worked after my

    1. upgrading the system app to a privileged app to have the CAPTURE_MEDIA_OUTPUT permission
    2. setting the private field mAllowPrivilegedPlaybackCapture to "true" in the AudioMixingRule object.

    The #2 above is the key that eluded me during my last failed try.