通话记录 - 使其在Nexus 5X上工作(生根或自定义ROM可能)
我试图在Nexus 5X,Android 7.1(我自己的AOSP版本)上使用AudioRecord
和AudioSource.VOICE_DOWNLINK
。通话记录 - 使其在Nexus 5X上工作(生根或自定义ROM可能)
我已经过了权限阶段 - 将我的APK移至特权应用,并对Android源代码中的AudioRecord
进行了调整,以停止引发此源的异常。
现在我在通话期间收到空的录音缓冲区。
我知道有很多通话录音应用程序,他们在其他设备上工作。 我也看到了某些应用程序可以在根N5上执行一些破解并使其正常工作。
我希望在Nexus 5X上实现同样的效果 - 任何调整对我来说都是可以的,包括更改Android版本,修改Qualcomm驱动程序,设备配置文件等等 - 基本上可以在自定义ROM中实现的任何操作。
我已经尝试了平台代码 - 硬件/ qcom/audio/hal/voice.c,特别是函数voice_check_and_set_incall_rec_usecase
,但是到目前为止它还是没有意义。
还检查设备/ LGE /大头/ mixer_paths.xml,发现有来电记录相关的一个部分:
<!-- 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 -->
但我也不能弄明白它或它如何能够得到帮助。
不确定它是否是Nexus 5特定问题,但通常用于记录调用的类是MediaRecorder
。你有没有试过用MediaRecorder
代替AudioRecorder
?
基于this堆栈溢出的问题,我想你可以尝试基于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
,也是其他选项麦克风只是为了看看你的手机是否有硬件问题。
我需要使用AudioRecord进行实时录制。 – SirKnigget
**现在,我正在打电话时获得空的录音缓冲区** - 是否因为AudioRecorder和呼叫使用相同的频道?你有没有尝试收听一些不同的信息来源,比如打电话给扬声器,然后尝试 – Debu
我不想把电话打到扬声器上,我需要从AudioSource.VOICE_CALL正确记录这个呼叫。 – SirKnigget
你有什么期待吗? –
尝试将audioRecoder.record()放在try catch中并检查。 也发布您的录音代码。 –
没有碰撞,所以在试穿时没有意义。 – SirKnigget