简体   繁体   中英

Android Call Recording Downlink muted

I am trying to record both Uplink and Downlink voice using Android. Regardless the law and everything, i am already aware, so please do not put comments related to the law.

The code below works fine, except when i mute the microphone, it wont record the downlink voice.

I am using Android 8.1. I've tried using a third party app called ACR on the same device, and it works fine, while i am muted, it still records the downlink voice.

 val audioManager = applicationContext.getSystemService(Context.AUDIO_SERVICE) as AudioManager

 val maximumVolume = audioManager.getStreamMaxVolume(AudioManager.STREAM_VOICE_CALL)

 audioManager.setStreamVolume(AudioManager.STREAM_VOICE_CALL, maximumVolume, 0)

 val audioSource = MediaRecorder.AudioSource.MIC

 val mediaRecorder = MediaRecorder()

 mediaRecorder.apply {
            setAudioSource(audioSource)
            setOutputFormat(MediaRecorder.OutputFormat.MPEG_4)
            setAudioEncoder(MediaRecorder.AudioEncoder.AAC)
            setAudioChannels(audioChannels)
            setAudioSamplingRate(audioSamplingRate)
            setAudioEncodingBitRate(audioEncodingBitRate)
            setOutputFile(path)
            prepare()
            start()

This is not an issue. You set the MediaRecorder to use MIC as input, so if you MUTE the microphone it's obliviously that the input signat is lost/muted. When you use "downlink" word I expected to see a different input source as VOICECALL or DOWNLINK instead of MIC. Trying to record a voicecall using the MIC it's wrong in my opinion because: (1) you have to set max volume to speaker and redirect the voicecall through it (2) while recording a voicecall from the MIC the caller hears ALL what it happens around your device and all what you're saying to other people (3) this method records much noise and echoes. The right way is to record from VOICECALL but most of new devices (using newer Android version) prevents to record from this source and allows it only at System Apps. ACR uses a workaround by calling hidden API methods, but this method could stop stop work at any time due to Android updates.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM