Android Call Recording Incoming voice not getting recorded
Asked Answered
H

6

27

I'm working auto call recorder app, I'm able to record voice call on below android 6 using MediaRecorder.AudioSource.VOICE_CALL, From android 6 not able to record voice call using VOICE_CALL. I managed to record using MediaRecorder.AudioSource.MIC but here incoming voice not getting recorded and I want to record voice call in normal mode not in speaker on mode. Please help me on this. (I had tried on Xiomi Redmi 4a(android 6),not working).

 myRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
 myRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
 myRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
 myRecorder.setMaxDuration(60 * 60 * 1000);
 AudioManager audiomanager =
 (AudioManager)getSystemService(AUDIO_SERVICE);
 audiomanager.setMode(2);

Edit : There is no issue with permissions.

Update : Anyone knows how to forcing another stream to MIC audio source. This requires native android code. Please help me on this Refer this question for more details on routing audio

Hinz answered 21/7, 2017 at 7:8 Comment(17)
How are you requesting permissions?Milo
@GiacomoLai Run time only!Hinz
HI all i faced same issue( Not getting other side voice ) with Samsung S7 and S8 other wise my prog is run very well on rest of phones Any idea about ??Hearsay
@BharathKumar what is your status now? Did you get success ?Hearsay
@BhanuSharma not got any result, I was also tried with native method and there also same issue. Link : #45593565Hinz
@BharathKumar i am facing same issue with same device(Xiomi Redmi 4a). I have downloaded an app named as cube call recorder form google play store. The app is using voice call(software) to record calls .Consumable
@BharathKumar have you found out some workaroundConsumable
@Consumable Not found a solution.Hinz
@BharathKumar have you seen CUBE CALL RECORDER. This app is perfectly working even on Xiomi Redmi 4aConsumable
@BharathKumar Have you got any solution? If yes.. plz let me know... I'm facing exactly same issue. Thank you.Periostitis
Hi! how did you fix the problem Bharat Kumar please do let me know.Sash
Hi, I am also facing same problem.I cannot able to record call once other person lifts the call(Outgoing call).It is only recording upto the other person accept the call.After accepting I cannot able to record. I am stuck. I dont know how to use NDK.please help me on thisPentyl
@Pentyl I didn't had the right path to explore recordings using NDK, So I contacted a guy named NLL, who created NLL Call recording app for the license.Hinz
Can you please help me regarding this Call recording.It would be very very help ful.Pentyl
@BharathKumar, Email to connect with NLL please.It would be very help ful.Thanks in advancePentyl
@BharathKumar, how the app working now after using NLL call recording library ?Pentyl
@Pentyl ping me t.me/ithebk , Can't tell here.Hinz
P
11

You need to use ndk. Here are examples of the functions that need to be done.

Load libmedia.so and libutils.so

int load(JNIEnv *env, jobject thiz) {
    void *handleLibMedia;
    void *handleLibUtils;
    int result = -1;
    lspr func = NULL;

    pthread_t newthread = (pthread_t) thiz;

    handleLibMedia = dlopen("libmedia.so", RTLD_NOW | RTLD_GLOBAL);
    if (handleLibMedia != NULL) {
        func = dlsym(handleLibMedia, "_ZN7android11AudioSystem13setParametersEiRKNS_7String8E");
        if (func != NULL) {
            result = 0;
        }
        audioSetParameters = (lasp) func;
    } else {
        result = -1;
    }

    handleLibUtils = dlopen("libutils.so", RTLD_NOW | RTLD_GLOBAL);
    if (handleLibUtils != NULL) {
        fstr = dlsym(handleLibUtils, "_ZN7android7String8C2EPKc");
        if (fstr == NULL) {
            result = -1;
        }
    } else {
        result = -1;
    }

    cmd = CM_D;

    int resultTh = pthread_create(&newthread, NULL, taskAudioSetParam, NULL);

    return result;}

Function setParameters

int setParam(jint i, jint as) {
pthread_mutex_lock(&mt);

audioSession = (int) (as + 1);

kvp = "input_source=4";
kvps = toString8(kvp);

cmd = (int) i;

pthread_cond_signal(&cnd);
pthread_mutex_unlock(&mt);

return 0;}

Task AudioSetParameters

void *taskAudioSetParam(void *threadid) {
    while (1) {
        pthread_mutex_lock(&mt);
        if (cmd == CM_D) {
            pthread_cond_wait(&cnd, &mt);
        } else if (audioSetParameters != NULL) {
             audioSetParameters(audioSession, kvps);
        }
        pthread_mutex_unlock(&mt);
    }
}

There is a library and an example of use https://github.com/ViktorDegtyarev/CallRecLib

Perennial answered 18/10, 2017 at 7:10 Comment(7)
@ishmaelMakitla Sorry. Edited.Perennial
Hi @Viktor Degtyarev thanks for your answer, It is actually working. If you explain your answer in explanation its more helpful. (Sorry for the late response, actually I was working on the other projects.)Hinz
Hi Viktor will this library work on Samsung S7 and S8 (Noughat Devices) as i am having trouble recording incoming voice during a call. Please helpSash
Hi @BharathKumar please help how did you manage to use above code to record incoming voice also please provide the source code.Sash
@ViktorDegtyarev other user's voice is still recording so much low in mi device. Did you have any solution for this?Anaesthesia
Where and how to add above NDK code ?. I have no knowledge on NDK.please help me on this for recording call.Pentyl
on Android 9 this library not making any difference then just recording audio with android MediaRecorder and audio source MIC, was investigating all possibilities to record incoming call audio, also was researching other apps. Only solution is Volume up a microphone and hope that caller will talk loud. All recording apps on Google Play are based on this logic...Proustite
W
4

Xiaomi devices always have problems with permission request even run-time or install-time.

I have an Xiaomi Redmi 3 pro, and it always force to Deny some permission when I install apps, so I must manually Allow it. If your problem is the same, I found some workaround solution and it worked for me: How to get MIUI Security app auto start permission programmatically?

Wittgenstein answered 6/8, 2017 at 16:8 Comment(3)
Thanks for your answer. But the problem is during call recording other side voice is not getting recording. Only my voice is getting recorded.Hinz
have you got solution of this? i also have the same problem in Samsung Galaxy s7, s8Hearsay
HI all i faced same issue( Not getting other side voice ) with Samsung S7 and S8 other wise my prog is run very well on rest of phones Any idea about ??Hearsay
T
2

First these 3 permissions are needed in Manifest as well as a runtime permission request if the device is above Marshmallow,

<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.CAPTURE_AUDIO_OUTPUT" />
  1. MediaRecorder.AudioSource.VOICE_CALL is not supported on all phones so you need to continue using MediaRecorder.AudioSource.MIC.

I use this and works fine on most of the devices,

      recorder = new MediaRecorder();
      recorder.setAudioSource(audioSource);
      recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
      recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
      recorder.setOutputFile(your_path);
  1. You need to set this to record your calls properly,

    audioManager.setMode(AudioManager.MODE_IN_CALL);

raise volume level when you start recording

audioManager.setStreamVolume(AudioManager.STREAM_VOICE_CALL,audioManager.getStreamMaxVolume(AudioManager.STREAM_VOICE_CALL), 0);

When you stop recording set the mode to normal, audioManager.setMode(AudioManager.MODE_NORMAL); and also set the stream volume to back how it was.

Tallia answered 21/7, 2017 at 7:31 Comment(10)
Thanks for your answer. But the Incoming voice is very very low(Negligible voice coming). (Tested on :Xiomi Redmin 4A android 6)Hinz
Are you properly raising the volume in the audio manager ? I have tested on Redmi Note 3,Samsung Galaxy J2,Coolpad,Samsung Galaxy 2 duos, it is working fine..Tallia
@BharathKumar Let me know if you need more help as I have accomplished this before and know what works and what not..Tallia
Yeah I used audioManager.setStreamVolume(AudioManager.STREAM_VOICE_CALL,audioManager.getStreamMaxVolume(AudioManager.STREAM_VOICE_CALL), 0); to raise volume. Outgoing voice is fine, problem only with incoming voice. Issue is on Redmi 4A. Please help me on this.Hinz
@BharathKumar Can you please create a chat room, lets discuss this over there ?Tallia
HI all i faced same issue( Not getting other side voice ) with Samsung S7 and S8 other wise my prog is run very well on rest of phones Any idea about ??Hearsay
Have you found the solution to this?, if yes could please share itViol
@BhanuSharma Have you found a solution for this? I also tried on Galaxy S7 (Android 8.0) and it doesn't work, yet on this app it works fine: play.google.com/store/apps/… . Wrote about this here: https://mcmap.net/q/362704/-how-do-some-apps-overcome-phone-recording-restrictions/878126Lasandralasater
No i didn't find anything about itHearsay
Outgoing voice is fine, problem only with incoming voice. Issue is on Redmi 4A. Please helpDurban
A
1

This could be a Permission related issue.

With the introduction of Android 6.0 Marshmallow, the app will not be granted any permission at installation time. Instead, the application has to ask the user for a permission one-by-one at run-time.

I hope you have included the code which explicitly asks for permissions on devices with Marshmallow and above.

Arnettaarnette answered 21/7, 2017 at 7:18 Comment(1)
There is no issue with permissions, its recording and creating file in sdcard. Thing is my side voice is getting recorded, other side voice is not coming. And its working fine on oneplus 5 with android 7Hinz
M
1

In automatic call recorder (callU) have a option "SoundFX" If Enable Record Calls Two Side

Link

enter image description here

Munitions answered 29/10, 2017 at 5:32 Comment(4)
What is this doing exactly?Lasandralasater
I don't know bro. but i think Records separate input and output voices .Finally, it mixes together voicesMunitions
It's possible to record from 2 sources at the same time? I never tried it.Lasandralasater
may be. but if with a voice recorder just for records (don't with receiver) incoming and voice recorded .Munitions
L
0

try

 MediaRecorder.AudioSource.VOICE_COMMUNICATION

and see

https://androidforums.com/threads/android-phone-with-call-recording-function.181663/

Limemann answered 10/8, 2017 at 5:35 Comment(1)
Thanks for your answer, But this method is also not working.Hinz

© 2022 - 2024 — McMap. All rights reserved.