Call recorder not working in android 10 (Q)
Asked Answered
S

3

6

Call recorder is recording blank for the duration in Android 10 (Pixel 3A). It was working fine for all phones till Android 8 and in Android 9 most phones were recording only one side voice (however it was working fine in pixel 3A)

Is there any way to record calls in Android 10?

The below code doesn't seem to be working anymore.

    int audioSource = MediaRecorder.AudioSource.VOICE_CALL;
    mediaRecorder.setAudioSource(audioSource);
    mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
    mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
    mediaRecorder.setAudioEncodingBitRate(32);
    mediaRecorder.setAudioSamplingRate(44100);
    mediaRecorder.setOutputFile(MediaUri);
    mediaRecorder.prepare();
    mediaRecorder.start();

If SDK 28 or below is used call recording happens for the whole duration but without any voice. If SDK 29 is used call recording fails at the beginning saying check available audio from callback.

I hope its a bug in Google Android 10 and some patch will fix it.

Sander answered 4/10, 2019 at 4:59 Comment(4)
it's not a bug, google restricted call recording feature to the only system appsEverywhere
There is a new API in Android Q(AudioPlaybackCapture API) to record internal audio: android-developers.googleblog.com/2019/07/… developer.android.com/guide/topics/media/playback-capturePictorial
@lcz does this work? Have you tried? I havnt seen any app using this. The only working apps are using accessibility feature.Sander
I have not tried it, but I have seen a third-party app that does: androidpolice.com/2019/09/18/…Pictorial
S
5

It's possible using Accessibility Service.

Remote call recorder and BoldBeast both record perfectly both side voice in Android 10 (Pixel 3A) without having to root or being a system app. Both of them use Accessibility service.

Detailed info here in this link.

Sander answered 24/10, 2019 at 15:54 Comment(17)
Plug in a headset and check if the other side is recordedMarciamarciano
With headset it obviously will not record as the microphone will not be receiving any audio.Sander
@ZAB, What is misleading? There is a way to record calls and Cube call recorder is doing it, is what I meant. How is the cube call recorder recording it if it's completely disabled?Sander
You aren't recording calls. You are recording background using mic. Call recording feature was removed from Android. Stop advertising this app please, there are plenty of other apps doing the same.Marciamarciano
@ZAB, What is call recording? Its recording mic using audio service when you get broadcast of incoming or outgoing calls. Even in earlier version of android calls using earphones were not getting recorded. My question was what is the workaround to record in android 10 and I was looking answer from people who have implemented it and not negative answers that the old approach is not working. Cube call recorder has shown that it's possible. If you dont know, let others who know reply.Sander
In android 8 it was a separate sound device MediaRecorder.AudioSource.VOICE_CALL mirroring the line and it was possible to record clear sound directly from the line. This feature was later removed. Recording the surrounding through the MIC hoping to catch some noisy sound from the speaker is nowhere close.Marciamarciano
I am using both Cube and Pixel with Android 10, it's just saving recording without any sound.Leonialeonid
@jahangir, you need to give accesbility permission for it to work. It's working perfectly fine in my pixel 3a. Even boldbeast works fine.Sander
I've managed to deploy an Accessibility Service + MediaRecorder + Accessibility Overlay. MediaRecorder's audio source MUST be configured as VoiceRecognition. The transparent/non-interactive overlay serves as a priorization proxy, as Android Reference says "If the service's UI is on top, both the service and the app receive audio input. This behavior offers functionality like controlling a voice call or video capture with voice commands.". Actually it also works without the overlay, I was able to finally capture outgoing WhatsApp voice messages.Marla
@Marla Where can I find an example about call recording from an Accessibility Service? Do you use onAccessibilityEvent for starting the recording and ending the recording(for example when the user pushes call and end call)? Do you listen for the default call app package?Historicism
@Srihari Karanth, Acr can record calls for my Pixel 3a with Android 10. But do you have a working example of recording a call from the Accessibility Service?Historicism
@AndreiCiuca My app doesn't have any activity, so I used Accessibility Service so I can turn it on/off on demand in Phone Settings. While turned on, as soon as phone boots, the service is started. I override onServiceConnected() to initialize everything: - Broadcast Receivers: screen on/off, charger plugged in/out, airplane mode on/off, etc; - Audio recorder class: as soon as the service is initialized I setup my MediaRecorder and call start(), so the target phone records everything 24/7. - I also call stop() when service is disconnected or device shuts down, so I don't end up corrupted.Marla
@AndreiCiuca as for listening phone calls, I used to implement a broadcast receiver for checking phone state changes. It worked well, but then I realized I would just need to catch them (and every other item) as notifications, so I removed the receivers and setup the accessibility service info to listen for notifications as well, then I just needed to filter per app package name.Marla
@AndreiCiuca Accessibility Service combined with broadcast receivers gives you access to everything going on the phone. If you want to stalk, you don't need admin, foreground service or dedicated notifications listener. You have all in one, just explore it. You don't even need a visual activity at all. My app works 100% as a service, there is not even an icon launcher after installing. Please, PM me and I'll send you some pieces of code that might help you.Marla
Oh! and if anyone here disagrees on me stalking people: This person once broke my confidence on him, and in order to prove I could recover it, he agreed with me installing an app like this on his phone. I never released this thing to anyone else. :)Marla
@LuckyScooby, Thank you for your reply. It seems that call recording works just if the accessibility service is running. For Pixel 3a you don't need to start the call recorder from the accessibility service. Since the Pixel phone has the most limitations regarding call recording, I hope that it should work on other phones. I have not tested this on other phones. Did you test VoiceRecognition on more than just the Pixel phone? On the Pixel phone VoiceCall and Microphone seem not to work.Historicism
@Marla can you please share with me a sample code?Bleary
M
2

As per Google's new permission policy no other third party apps (Except system apps) can record calls from Android 9 Pie.

This change will not affect previous recordings or call recording in general.

Musk answered 4/10, 2019 at 17:17 Comment(4)
I had Pixel with Android 9 and call recording was working just fine in that.Sander
The link is from Google Play developer policy not from android. The restrictions it mentions there are for apps uploaded on Google Play Store.Sander
See here hereMusk
So it's not blocked entirely. Cube call recorder is already recoding both side voice in android 10 clearly. Will try to figure out and update the answer soon.Sander
B
2

I am using Realme2pro device having version android 10 it is working for me by using Accessibility try this code

To implement Accessibility go through this link

public class Accessibility extends AccessibilityService {

Service mService = null;

@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
    Log.d("MyAccessibilityService", "Shrinidhi: onAccessibilityEvent");
}

@Override
public void onInterrupt() {

}


@Override
protected void onServiceConnected() {
    Log.d("MyAccessibilityService", "Shrinidhi: onServiceConnected");
}

@Override
public void onCreate() {
    this.mService = this;
    Log.d("MyAccessibilityService", "Shrinidhi: onCreate");
 }
}

and add AudioSource to recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_RECOGNITION);

 recorder = new MediaRecorder();
    recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_RECOGNITION);
    recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
    recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
    recorder.setOutputFile(file.getAbsolutePath());

Hope it work :)

Byington answered 22/9, 2020 at 14:40 Comment(5)
What is your "Service mService = null;" ? Is it the call recording service? I have an example for the Call Recording on this link: github.com/tntkhang/call-recording-master Could you please take a look on it, it worked on android below 10, but with android 10 it got silent.Jhelum
Which device you are using?Byington
Can you please try without this lines recorder.setAudioSamplingRate(44100); recorder.setAudioEncodingBitRate(96000);Byington
@prototype86 did you found solution for your issue. i am also facing the same errorUjiji
You answer is not clear, please clear how to attach Accessibility class to Recording service.Scarbrough

© 2022 - 2024 — McMap. All rights reserved.