通话录音-使它可以在Nexus 5X上运行(可以生根或自定义ROM) [英] Call recording - make it work on Nexus 5X (rooting or custom ROM possible)
问题描述
我试图在Nexus 5X,Android 7.1(我自己的版本)上将 AudioRecord
与 AudioSource.VOICE_DOWNLINK
一起使用(来自AOSP)。
I'm attempting to use AudioRecord
with AudioSource.VOICE_DOWNLINK
on Nexus 5X, Android 7.1 (my own build from AOSP).
我已经超出了权限阶段-将我的APK移至特权应用程序,并对 AudioRecord $ c进行了调整Android中的$ c>停止对此源引发异常。
I'm already past the permissions stage - moved my APK to privileged apps, made an adjustment to AudioRecord
in Android source to stop throwing an exception about this source.
现在,我在通话中获取的录音缓冲区为空。
Now I'm getting empty recording buffers during a phone call.
我知道有很多通话记录应用程序,它们可以在其他设备上使用。
我也看到过某些可以对扎根的N5进行破解并使其正常工作的应用。
I know that there are a lot of call recording apps, and they work on other devices. I've also seen certain apps that can perform some hack on a rooted N5 and make it work.
我希望在Nexus 5X上实现相同的效果-对我来说,任何调整都是可以的,包括更改Android版本,修改Qualcomm驱动程序,设备配置文件等-基本上可以在自定义ROM中完成的任何事情。
I wish to achieve the same on Nexus 5X - ANY adjustment is OK for me, including changing Android version, modifying Qualcomm drivers, device configuration files, etc. - basically anything that can be achieved in a custom ROM.
I曾经尝试弄乱平台代码-hardware / qcom / audio / hal / voice.c,尤其是功能 voice_check_and_set_incall_rec_usecase
,但到目前为止还没有道理。
I've tried messing around with platform code - hardware/qcom/audio/hal/voice.c, especially the function voice_check_and_set_incall_rec_usecase
, but could not make sense out of it so far.
还检查了device / lge / bullhead / mixer_paths.xml,发现有一个与呼叫记录相关的部分:
Also checked device/lge/bullhead/mixer_paths.xml, found there's a section related to call recording:
<!-- 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 couldn't make sense out of it or how it can be helped.
推荐答案
不确定是不是Nexus 5特定问题,但通常用于记录呼叫的类是 MediaRecorder
。您是否尝试过将 AudioRecorder
替换为 MediaRecorder
?
Not sure if it is a Nexus 5 specific issue but usually the class used to record calls is MediaRecorder
. Have you tried to replace AudioRecorder
by a MediaRecorder
?
基于此堆栈溢出问题,我认为您可以尝试以下方法基于 Ben博客帖子:
Based on this stack-overflow question, I think you could try the following code based on Ben 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();
}
}
在此示例中,使用了 MediaRecorder.AudioSource.VOICE_CALL
,但是您可以测试其他选项,例如 MediaRecorder.AudioSource.VOICE_COMMUNICATION
以及仅用于查看手机上是否有硬件问题。
In this sample, I've used MediaRecorder.AudioSource.VOICE_CALL
but you can test other options like MediaRecorder.AudioSource.VOICE_COMMUNICATION
and also the microphone just to see if there are any hardware issues on your phone.
这篇关于通话录音-使它可以在Nexus 5X上运行(可以生根或自定义ROM)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!