我正在尝试使用AudioRecord
with AudioSource.VOICE_DOWNLINK
在 Nexus 5X、Android 7.1(我自己的 AOSP 版本)上。
我已经过了权限阶段 - 将我的 APK 移至特权应用程序,并进行了调整AudioRecord
在 Android 源中停止抛出有关此源的异常。
现在我在打电话时录音缓冲区是空的。
我知道有很多通话录音应用程序,并且它们可以在其他设备上运行。
我还看到某些应用程序可以对已 root 的 N5 进行一些破解并使其正常工作。
我希望在 Nexus 5X 上实现同样的目标 - 任何调整对我来说都可以,包括更改 Android 版本、修改高通驱动程序、设备配置文件等 - 基本上任何可以在自定义 ROM 中实现的内容。
我尝试过弄乱平台代码 - hardware/qcom/audio/hal/voice.c,尤其是函数voice_check_and_set_incall_rec_usecase
,但到目前为止还无法理解它。
还检查了device/lge/bullhead/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
。您是否尝试过更换AudioRecorder
by a MediaRecorder
?
基于this https://stackoverflow.com/questions/6688444/android-recording-incoming-and-outgoing-calls堆栈溢出问题,我想你可以尝试以下基于的代码本博客文章 http://www.benmccann.com/android-audio-recording-tutorial/:
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
还有麦克风,只是为了检查手机上是否存在任何硬件问题。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)