Wednesday, April 13, 2016

$1000 bounty! Android 6 call recording issues, help needed

I need some help from people with experience with Android audio system and I wonder if anyone would be able to help with the following:
Main phones I am trying to get sorted are Sony Xperia devices with Android 6. But, issue seems to be peresent CM13 too.

I have a call recording app called ACR . Some phones support(ed) call recording with VOICE_CALL audio source some didn't. That is until Android 6.
Unfortunately with Android 6, 3rd party apps are no longer able to open VOICE_CALL audio source with AudioRecord or MediaRecorder APIs. I have manged to trace the issue and found out that opening VOICE_CALL or VOICE_DOWNLINK now requires android.permission.CAPTURE_AUDIO_OUTPUT because when I try to use VOICE_CALL audio source I can see following in the logs

Code:

[ 04-12 12:47:34.564 648: 2765 E/ ] Request requires android.permission.CAPTURE_AUDIO_OUTPUT
04-12 12:47:34.570 648-17124/? D/audio_hw_primary: in_standby: enter: stream (0xab7e5fa8) usecase(40: afe-proxy-record)

But, even though this is a system permission and cannot be used by 3rd party apps; 3 other call recording apps are able to record fine on a non rooted phone and without requesting android.permission.CAPTURE_AUDIO_OUTPUT permission. Boldbeast, KillerMobile's call recorder and Call recorder from Skvalex. They seem to be doing something to get system to route/mix VOICE_CALL with MIC audio source. It looked like they are using Android AudioManager to setParameters on the Modem (or so I guessed) because once they start recording. I have discovered

You first see they open MIC (1)
Code:

03-27 22:23:56.125 644-31424/? D/audio_hw_primary: in_set_parameters: enter: kvpairs=input_source=1;routing=-2147483644
Then see they open VOICE_CALL (4)
Code:

03-27 22:23:56.136 644-31424/? D/audio_hw_primary: in_set_parameters: enter: kvpairs=input_source=4;routing=-2147483584;format=1
As soon as after above log, I can see modem starts mixing to with following log
Code:

03-27 22:23:56.136 644-31424/? D/audio_hw_primary: start_input_stream: enter: stream(0xac1286e0)usecase(18: audio-record)
03-27 22:23:56.137 644-31424/? D/audio_hw_extn: audio_extn_get_anc_enabled: anc_enabled:0
03-27 22:23:56.137 644-31424/? D/audio_hw_primary: select_devices: out_snd_device(0: ) in_snd_device(283: voice-dmic-ef)
03-27 22:23:56.137 644-31424/? D/hardware_info: hw_info_append_hw_type : device_name = voice-dmic-ef
03-27 22:23:56.137 644-31424/? D/soundtrigger: audio_extn_sound_trigger_update_stream_status: uc_id 31 of type 1 for Event 3, with Raise=0
03-27 22:23:56.137 644-31424/? D/voice: voice_get_incall_rec_snd_device: in_snd_device(283: voice-dmic-ef) incall_record_device(283: voice-dmic-ef)
03-27 22:23:56.137 644-31424/? D/ACDB-LOADER: ACDB -> send_audio_cal, acdb_id = 6, path = 1
03-27 22:23:56.137 644-31424/? D/ACDB-LOADER: ACDB -> send_asm_topology 03-27 2

I though to my self, AHA! I found it. Unfortunately calling the following just before starting to record in my app did nothing
Code:

AudioManager am =( AudioManager) context.getSystemService(Context.AUDIO_SERVICE);am.setParameters("input_source=1;routing=-2147483644")
;am.setParameters("input_source=4;routing=-2147483584;format=1");

Then, I started to suspect that other apps might be using some native code to achieve call recording . For example one app calls the method "ASOP call recording", the other asks users to set "Tune audio route to Group 3". But I was unable to see anything in the logs

Moving to "Tune audio route to Group 3" and assuming it meant AudioManager setMode, I have tried to use below without SOME luck
Code:

AudioManager am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
am.setMode(AudioManager.MODE_IN_COMMUNICATION);

Above code does increase the volume some how but it is not as good as real voice_call audio source.

Another thing I have noticed that on all 3 apps is that they use MODIFY_AUDIO_SETTINGS permisison just before recordign starts.
I see
Code:

D/PermissionCache: checking android.permission.MODIFY_AUDIO_SETTINGS for uid=
and then instantly see
Code:

audio_hw_primary: in_set_parameters: enter: kvpairs=format=1;input_source=4;routing=-2147483584
meaning that the audio source is changed to 4 (VOICE_CALL) with just MODIFY_AUDIO_SETTINGS permission. They must be using AudioManager or something else to alter an audio setting/route. My app does not get that log when I use AudioManager.setMode . Obviously I am missing something because 3 other 3rd party apps on a non rooted device are able to trigger above log and are able to record fine.

I have spent 4 weeks over this and about to go mad. I am ready to pay the bounty to someone or dived in between couple of people that would help me get call recording working


Thank you in advance.


from xda-developers http://ift.tt/1N8wnIr
via IFTTT

No comments:

Post a Comment