Call recording - make it work with Nexus 5X (rooting or user ROM is possible)

I am trying to use AudioRecord with AudioSource.VOICE_DOWNLINK on a Nexus 5X, Android 7.1 (my own build from AOSP).

I already went through the resolution stage - I moved my APK to privileged applications, making adjustments to AudioRecord in the Android source to stop throwing an exception from this source.

Now I get empty recording buffers during a phone call.

I know that there are many applications for recording calls, and they work on other devices. I also saw some applications that can perform some hacking at the root of the N5 and make it work.

I want to achieve the same in Nexus 5X - everything is fine for me, including changing the version of Android, changing Qualcomm drivers, device configuration files, etc. - basically everything that can be achieved in a custom ROM.

I tried to communicate with the platform code - hardware / qcom / audio / hal / voice.c, especially with the voice_check_and_set_incall_rec_usecase function, but still could not understand.

Also, the device / lge / bullhead / mixer _paths.xml was checked, the section related to the call record was found there:

 <!-- Incall Recording --> <ctl name="MultiMedia1 Mixer VOC_REC_UL" value="0" /> <ctl name="MultiMedia1 Mixer VOC_REC_DL" value="0" /> <ctl name="MultiMedia8 Mixer VOC_REC_UL" value="0" /> <ctl name="MultiMedia8 Mixer VOC_REC_DL" value="0" /> <!-- Incall Recording End --> 

But I also could not understand how this can be done.

+24
android android-mediarecorder alsa android-audiorecord
May 6 '17 at 9:15 a.m.
source share
1 answer

Not sure if this is a problem with Nexus 5, but usually the class used to record calls is MediaRecorder . Have you tried replacing AudioRecorder with MediaRecorder ?

Based on this stack overflow question, I think you can try the following code based on Ben's Blog Post :

 import android.media.MediaRecorder; import android.os.Environment; import java.io.File; import java.io.IOException; public class CallRecorder { final MediaRecorder recorder = new MediaRecorder(); final String path; /** * Creates a new audio recording at the given path (relative to root of SD card). */ public CallRecorder(String path) { this.path = sanitizePath(path); } private String sanitizePath(String path) { if (!path.startsWith("/")) { path = "/" + path; } if (!path.contains(".")) { path += ".3gp"; } return Environment.getExternalStorageDirectory().getAbsolutePath() + path; } /** * Starts a new recording. */ public void start() throws IOException { String state = android.os.Environment.getExternalStorageState(); if(!state.equals(android.os.Environment.MEDIA_MOUNTED)) { throw new IOException("SD Card is not mounted. It is " + state + "."); } // make sure the directory we plan to store the recording in exists File directory = new File(path).getParentFile(); if (!directory.exists() && !directory.mkdirs()) { throw new IOException("Path to file could not be created."); } recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_CALL); recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); recorder.setOutputFile(path); recorder.prepare(); recorder.start(); } /** * Stops a recording that has been previously started. */ public void stop() throws IOException { recorder.stop(); recorder.release(); } } 

In this example, I used MediaRecorder.AudioSource.VOICE_CALL , but you can check other parameters, such as MediaRecorder.AudioSource.VOICE_COMMUNICATION , as well as the microphone, to see if there are any hardware problems on your phone.

0
May 24 '17 at 15:50
source share



All Articles