How do some apps overcome phone recording restrictions?
Asked Answered
H

2

47

Background

Phone recording is not really supported on Android, yet some devices support it to some extend.

This made various call recording apps gather as much possible information about devices and what should be done to them, and decide upon this what to do.

Some even offer root solutions.

One such example is boldbeast Call Recorder app, which offers a lot of various configurations to change:

enter image description here

  • "record mode" . Shows 14 modes for non-rooted devices, and up to 34 for rooted. Also shows "Alsa mode" as an option for it, for rooted devices.

  • Has "Tune Audio Effect ("auto tune a groupd of parameters") .

  • Has "Tune Audio Route", with the possible values of "Disabled", "Group1", "Group2", "Group3"

  • For rooted devices:

  • "change audio controls" ("auto change audio controls")

  • "change audio driver" (change audio drive settings to enable record mode 21,22,23,24,31,32,33,34")

  • For rooted devices: "start input stream"

The problem

If I'm in need to create a call recording app, there is no other way than to find the various workarounds for various devices, but as it seems other apps use terms that don't appear in the API.

I can't find any of those of the app I've mentioned, for example.

What I've found

Other than tons of questions of how to record calls on Android, showing that it doesn't work on all devices, I could find some interesting things. Here are my tries and insights so far:

  • There are some Audio recording sources we can use while preparing the recording (docs here) , but sadly in each device it might be different. For some, VOICE_CALL works, and for some, others. But at least we can try...

  • On OnePlus 2 with Android 6.0.1, incoming calls can be recorded using VOICE_CALL, but I can't make outgoing calls be recorded there, unless I use MIC as audio source together with speaker turned on. Somehow, the app I've mentioned succeeds recording it without any issues. I'm sure I will see other issues with other Android devices, as I've tried to address this whole topic in the past. Update: I've found this sample project (also here), which for some reason sleeps for 2 seconds on the UI thread between prepare and start calls of the mediaRecorder. It works fine, and when I did something similar (wait using Handler.postDelayed for 1 second), it worked fine too. The comment that was written there is "Sometimes prepare takes some time to complete".

  • On Galaxy S7 with Android 8, I've failed to get sound of the other side for outgoing calls AND incoming calls (even with MIC and speaker), no matter what I did, yet the app I've mentioned worked fine.

  • To let you try my POC of call recording, I've published an open source github repository here, having a sample that will record a single call, and let you listen to the most recent one, if all works well.

  • This "ViktorDegtyarev - CallRecLib" SDK , which doesn't seem to work at all, and crashes on various Android versions

  • These 2 old sample projects : rvoix , esnyder-callrecorder , both fail to actually record. The second doesn't even seem to work on Android 6.0.1 device, which it's supposed to support.

  • aykuttasil - CallRecorder sample and axet - android-call-recorder sample - both, just like on my POC, don't have any tweaking except for AudioSource, and because of this they fails to record on some cases, such as OnePlus 2 output-audio of outgoing calls.

  • Most third party apps only offer the AudioSource tweaking, but some (like "boldbeast") do offer more. One example is "Automatic Call Recorder" which has "configuration" (10 values to choose from, first is "default") and "method" (5 vales to choose from, first is "default"). Those apps probably do not want others to understand what those configurations mean, so they put general names. Or, it's just too complicated for everyone (especially for users), so they generalize the names.

  • There is an API of "setMode" here, but it doesn't seem to change upon calling it. I was thinking of maybe change the "channel" of where the call is being used, this way, but it doesn't work. It stays on the value of "2" during call, which is MODE_IN_CALL.

  • There are customized parameters that are available for various devices (each OEM and its own parameters), which can be set here and maybe even via JNI (here and here) , but I don't get where to get this information from (meaning which pairs of key-value are available). I've searched in a lot of places, but couldn't find any website that talks about which possible parameters are available, and for which devices.

  • I was thinking of using AudioRecord instead of MediaRecorder class for recording, thinking that it's a bit low level, so it could give me more power and access to customized capabilities, but it seems to be very similar to MediaRecorder, and even use the same audio sources (example here).

  • Another try I had with low level API, was even further, of using JNI (OpenSL ES for Android). For this, I couldn't find much information (except here and here), and only found the 2 samples of Google here (called "audio echo" and "native audio"), which are not about recording sound, or at least I don't see them occur.

  • Android P might have official way to record calls (read here and here). Testing on my Android P DP3 device (Pixel 2), I could record both sides fine in both incoming and outgoing calls, using "DEFAULT" as audio source, so maybe the API will finally be official and work on all Android versions. I wrote about it here and here.

  • I was thinking that maybe the Visualizer class could be a workaround of recording, but according to some StackOverflow post (here), the quality it extremely low, so I decided that maybe I shouldn't try it. Plus I couldn't find a sample of how to record from it.

  • I've found some parameters that might be available on some devices, here (found from here), all start with "AUDIO_PARAMETER_", but testing on Galaxy S7, all returned empty string. I've also found this website, that gave me the idea of using audioManager.setParameters("noise_suppression=off") together with MIC audio source, but this didn't seem to do anything in the case of Galaxy S7.

The questions

As opposed to other similar questions about this topic, I'm not asking how to record calls. I already know it's a very problematic and complex problem. I already know I will have to address various configurations, and that I will probably use a server to store all of them and find there the best match for each one.

What I want to ask is more about the tweaking and workarounds :

  1. Is there a list of configurations for the various devices, Android versions, and what to choose for each?

  2. Besides Audio source, which other configuration is possible to be used?

  3. Which parameters are possible for the various devices and Android versions ? Are there any websites of the OEMs describing them?

  4. What are the various terms in the app I've mentioned? Where can I find information of how to change them?

  5. Which tools are available for rooted devices?

  6. Is it possible to know which device supports call recording and which not, by using the API ?

  7. About the workaround of OnePlus 2, to wait a moment till we start recording, why is it needed? Is it needed on all Android versions? Is it a known issue? Would 1 second be enough?

  8. How come on the Galaxy S7 I've failed to record the other side even when using MIC&speaker?


EDIT: I've found this of accessibility service being able to help with call recording:

https://developer.android.com/guide/topics/media/sharing-audio-input#voice_call_ordinary_app

Not sure how to use it though. It seems "ACR Phone Dialer" uses it. If anyone knows how it can be done, please let me know.

Hamlani answered 21/6, 2018 at 14:24 Comment(24)
Hi,is there any progress about this?I have solve the rejecting calls problem on Samsung 8.0.Maybe we can exchange codesIz
@Iz I already have shared all, including full code on Github. What do you mean that you've solved "rejecting calls" ? This is about recording phone calls... And what is the solution you've found?Hamlani
I have nothing new about recording.I noticed you also study 'rejecting calls' feature. TelecomManager and telphonyManager both failed on Samsung 8.0 and Huwei 8.0.TelecomManager just work well on Android P.Iz
You probably mean the workarounds don't work well, but the official API works well, right ? And how and what did you solve on Samsung 8.0 ? And which device?Hamlani
@androiddeveloper Have you ever tried to reject calls on the Samsung Galaxy S9? I tested even truecaller failed for rejecting calls on this device.The way of aidl just didn't work on many 8.0 devices, for example Samsung and HuaweiIz
@Iz This question is about phone recording. For call rejection, there is an official API only on Android P, sadly. The rest could fail. Here: https://mcmap.net/q/372879/-android-permission-answer_phone_calls-how-i-can-use-for-auto-answerHamlani
A big question here is how phone recording is expected to integrate with AI guided phone callings.Propst
your repo ot worked in motorola devices.. does'nt record caller's sound.Mannish
@NikunjParadva I know. It works well only in some devices and Android versions. The whole question is what could also be done.Hamlani
Yes.. exactly.... But. Just let me know.. witch audio source is working well in other phones... Can you suggest me..?Mannish
@NikunjParadva Sometimes VOICE_CALL works, sometimes DEFAULT, and sometimes MIC. I don't think I saw the others work. I think it's best to have a server to manage all recommended configurations. There was a time that Android P preview worked great with DEFAULT, but when it became a final version, it didn't work well at all.Hamlani
developer.android.com/ndk/guides/audio/opensl might be an alternative and might not differ too much across vendor-specific Java API; for example: https://mcmap.net/q/372880/-call-recording-with-opensl ...it's even a low-latency driver, alike ASIO is.Socialization
1) About your POC project for call recording, do you have a java version available? Is it possible to record incoming calls using your project?Purkey
@Purkey 1. It's in Kotlin, so an Android developer should be able to read it. Google already chose Kotlin as the default language to use. 2. Yes, but sadly only in much less cases than what third party apps offer. They use various tricks, including JNI and changing audio settings.Hamlani
How can I record incoming calls from this app? Is it posible to read and manipulate the raw audio in an incoming phone call? I was wondering if it is possible to use AudioRecord to read the incoming phone audio instead of MediaRecorderPurkey
@Purkey It does it automatically, but as I wrote it will fail on some devices and Android versions. It also allows you to set the audio-source, which should usually be "VOICE_CALL" or some of the other top ones. For manipulation, that's up to you. You can use AudioRecord instead. Just need to change the code. If you use AudioRecord, please consider contributing to the repository, and make it optional (meaning it's a choice by the user which to use : AudioRecord or MediaRecorder).Hamlani
ok thank you I just tested it a few times and for Galaxy S6 Edge/Android 7, VOICE_CALL causes Error while recording while DEFAULT, MIC and VOICE_COMMUNICATION seem to work, but both my voice through the mic and the incoming sound through the network, both seem to be treated as the same audio source; both are getting recorded. Weird part is I think even when I mute the mic in android's phone receiver app, it seems to keep recording from the mic (I'll have to test this again later)Purkey
thanks for your help I'll keep you updated if I find anything new. Just one quick question, do you think it would be possible to take the incoming phone call audio in an Audiorecord, perform some manipulation on it (multiply by 1 for example), then send the result to Audiotrack, so that my modified version of the incoming audio can be heard instead of the actual incoming audio? Do you think this might be something feasible?Purkey
@Purkey I've never done it myself, but reading on the docs, it seems like it should work. I wonder if it's possible to use MediaRecorder for this. Probably not. This could be a nice enhancement to the Github repository, to enhance the volume. Maybe it could help recording in some cases that the volume level is just too low.Hamlani
@Purkey Another nice functionality that might be possible via AudioRecord is to skip the silence in the beginning of the call. Maybe this could help: https://mcmap.net/q/372881/-android-audio-capture-silence-detectionHamlani
any solution for this?Fassold
@NagendraHariKarthick Maybe root, but even then I have no idea how it works with rooted devices...Hamlani
BoldBeast also doesn't seem to work in pie. Check their forum boldbeast.com/forum/topic1744-android-9-pie-call-recording.htmlFassold
@NagendraHariKarthick I don't see that they say it's always impossible. Just requires root...Hamlani
H
0

According to my tests, one way to improve this is to have an AccessibilityService being active (no need to write there anything at all) while choosing voice-recognition as the audio source. Also it's recommended to have the speaker turned on because this will record the audio from the microphone.

This seems to exist in some call-recording apps.

Weird thing is that Google has written this as a rule on the Play Store:

The Accessibility API is not designed and cannot be requested for remote call audio recording.

https://support.google.com/googleplay/android-developer/answer/11899428

No idea what the "remote" means here.

Anyway, I've updated the Github repository to include these additions.

Hamlani answered 11/4, 2022 at 12:49 Comment(0)
C
4

I spent many weeks working on a Voicecall Recording App so I faced all your issues/questions/problems. Moreover: my project had a low-priority so I didn't spent much time every day on it, so I worked on this App for many months while Android was changing under the hood (minor an major releases).

I was developing always on the same Galaxy Note 5 using its stock ROM (without Root) but I discovered that on the same device the behaviour was changing from one Android release to another without any explanation. For example from Nougat 7.0 to 7.1.2 I was unable to record a voicecall using the same code as before.

Google has enforced_or_changed restrictions about voicecall recording many times. At the beginning it was sufficient to use use VOICE_CALL AudioSource. Then manufactures has started to interprete this Value as they wanted, and the result was that one implementation was working well but another was not. Then Reflection was needed to run undocumented/hidden methods to start voicecall recording. Then Google has added a Runtime check, so calling them directly was not more possible even using Reflection. However this method lack of stability because it was not guarantee that a method was using the same name on all devices.

Then I started to reverse-engineer currently working Apps that were working on newer Android version and I discovered that them were using a complete different and more secure approach. This takes me many weeks because all these Apps uses JNI Libraries trying to hide this method between Assembler code. When I succesfully create a Test App which was recording well I tried the SAME code in many different devices and ROMs/Versions and surprisely it was working well. This means that all those different methods you can see in these App Settings (I'm 98% sure about it) are just "fake" or just refers to OLD methods not more used.

A small different metion should be done for Rooted devices: these devices could change AudioRoutes so a different approach can be used in this case.

[1] There isn't any list or website listing all supported devices or best method to do a successfully voicecall record

[6] It's not possibile to know which device supports Voicecall Recording just using an API call. You have to try and catch Excepions...

[8] Recording by MIC+speaker suffers of many issues: (1) the caller will hear all your ambient sound so the privacy-bug is a big issue (2) the echo is a big problem (3) the recording volume is very low as the quality of recordered voice

Coincidence answered 10/12, 2018 at 16:59 Comment(2)
Can you please share the code of each of the ways you've found? Meaning: the reflection, the code you saw on JNI, and the ways for rooted devices? The app "boldbeast " just seem to have a lot of modes and configurations that it seems that they did come up with many ways...Hamlani
Hi,can you share how to change AudioRoutes? I have looked into this for a long time but got nothing.Iz
H
0

According to my tests, one way to improve this is to have an AccessibilityService being active (no need to write there anything at all) while choosing voice-recognition as the audio source. Also it's recommended to have the speaker turned on because this will record the audio from the microphone.

This seems to exist in some call-recording apps.

Weird thing is that Google has written this as a rule on the Play Store:

The Accessibility API is not designed and cannot be requested for remote call audio recording.

https://support.google.com/googleplay/android-developer/answer/11899428

No idea what the "remote" means here.

Anyway, I've updated the Github repository to include these additions.

Hamlani answered 11/4, 2022 at 12:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.