
Ask HN: Android AudioRecord forcing VOICE_CALL to MIC audio source - NLL_APPS
I have a call recording app that uses VOICE_CALL audio source. Although ASOP does not implement&#x2F;mandate it, most manufacturers have implemented VOICE_CALL and apps that use VOICE_CALL audio source worked fine on many devices. That is until Android 6.<p>Apparently Google changed this behavior with Android 6. Opening VOICE_CALL audio source now requires android.permission.CAPTURE_AUDIO_OUTPUT which is only granted to system applications.<p>Although Android 6 is almost 1 year old, there is no documentation about this. But, according to Eric Laurent &quot;This change was intentional in M.RECORD_AUDIO permission was too easy to acquire considering the privacy risk involved in allowing capture of voice call audio.
Also note that capturing from VOICE_CALL source is not supported consistently across the Android ecosystem and not mandated by the Android CDD. The SDK documentation should be updated accordingly.&quot;<p>This essentially stops call recording, or it should have. Well, it does for mine and 200+ other call recording apps apart from 3 who have found a way to get around this limitation on phones with Qualcomm chip-set such as most Sony Xperias and OnePlus1&#x2F;2<p>I have been trying those apps on many couple of phones with Android 6 and found out certain characteristics in the way they manage to record.<p>They all use Android AudioRecord class and open MIC audio source. I do too; but on my app, I only get audio from MIC, not the other party. What I&#x27;ve found out is telling me that they are issuing some sort of system call just after or before starting recording.<p>Have a look at the following log form one of the apps that successfully record VOICE_CALL, even though it uses MIC to record. It looks like it is some how managing to mix&#x2F;route&#x2F;stream&#x2F;merge VOICE_CALL audio source in to MIC.
======
NLL_APPS
\- D/audio_hw_primary: in_set_parameters: enter:
kvpairs=input_source=1;routing=-2147483644 \- D/PermissionCache: checking
android.permission.MODIFY_AUDIO_SETTINGS for uid=10286 => granted (432 us) \-
D/audio_hw_primary: in_set_parameters: enter:
kvpairs=input_source=4;routing=-2147483584;format=1 \- D/audio_hw_primary:
select_devices: out_snd_device(0: ) in_snd_device(283: voice-dmic-ef) \-
D/hardware_info: hw_info_append_hw_type : device_name = voice-dmic-ef \-
D/voice: voice_get_incall_rec_snd_device: in_snd_device(283: voice-dmic-ef)
incall_record_device(283: voice-dmic-ef)

As you can see in the first line it is starting with MIC audio source
input_source=1;routing=-2147483644.

Then, on the second line it does something and get granted
android.permission.MODIFY_AUDIO_SETTINGS which is normal permission and my app
has it too. This seems to be the most important part and it looks like all 3
are using JNI to do what ever they do to trigger streaming/merging of
VOICE_CALL audio source to MIC and record with standart AudioRecorder API

On the next line you see that audio hardware starting to mixing VOICE_CALL
(input_source=4) even though they have opened MIC(1) audio source.

I have assumed they used something like

AudioManager.setParameters("key=value") and tried many variations such as

AudioManager.setParameters("input_source=4;routing=-2147483584;format=1")
without any luck.

~~~
NLL_APPS
After some more research for the log entries created when call recording is
on, such as "voice_get_incall_rec_snd_device" or "incall_record_device", I
came across [https://github.com/dtsinc/DTS-Eagle-Integration_CAF-
Android-...](https://github.com/dtsinc/DTS-Eagle-Integration_CAF-Android-
hardware-qcom-audio/blob/master/hal/voice.c) It looks like it is Qualcomm
specific because I don't see any reference to
"voice_get_incall_rec_snd_device" on actual ASOP source code
([https://android.googlesource.com/platform/hardware/qcom/audi...](https://android.googlesource.com/platform/hardware/qcom/audio/+/android-6.0.0_r1/hal/voice.c))

I don't have nay C knowledge, heck, I don' t even know Java in order to write
a piece of code without Google's help, but I have spent 4 year on my app and
cannot bare it to bite the dust.

I am trying to collaborate get help from somebody who has insight to Android
audio HAL as well as C and JNI. I am happy to pay for their time and effort
but like the issue finding somebody who has these proven to be very very hard.
I have emailed many maintainers of CM, posted to SO as well as XDA.

Is there anyone here that can help me?

Thanks

