Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VOIP Call Recording

I am working on a project to record VOIP calls in android, I didn't found any solution for that, there are lot of apps which support VOIP recordings on phones. I am unable to find any tutorial and help. Cube Call Recorder is one of the app which is giving this feature but I can't figure out how to do it. I was tested it by starting recording by using android MediaRecorder then initiated whatsapp call, so other person was unable to listen my voice. after call, I checked only my voice were saved in the recording.

As a research I reverse engineered some apks, I found they are using Accessibility permissions in the apk.

<uses-permission android:name="android.permission.BIND_ACCESSIBILITY_SERVICE" />

I don't know what things I need to understand how can I get to know that to VOIP call is coming and going just like a BroadcastReceiver.

Then, I will understand how can I record the calls.

like image 495
Naveed Ahmad Avatar asked Nov 07 '22 11:11

Naveed Ahmad


1 Answers

I have found the answer for this

First grant accessiblity permission and have this class

import android.accessibilityservice.AccessibilityService;
import android.accessibilityservice.AccessibilityServiceInfo;
import android.content.Intent;
import android.util.Log;
import android.view.accessibility.AccessibilityEvent;

public class AccessAudio extends AccessibilityService {
    @Override
    public void onAccessibilityEvent(AccessibilityEvent event) {
Log.d("","gf");
    }

    @Override
    protected void onServiceConnected() {
        super.onServiceConnected();

        AccessibilityServiceInfo accessibilityServiceInfo = new AccessibilityServiceInfo();
        accessibilityServiceInfo.flags = 1;
        accessibilityServiceInfo.eventTypes = -1;
        accessibilityServiceInfo.feedbackType = 16;
        setServiceInfo(accessibilityServiceInfo);
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        return super.onStartCommand(intent, flags, startId);
    }

    @Override
    public void onInterrupt() {

    }
}

After that you can use

mediaRecorder = new MediaRecorder();
        mediaRecorder.setAudioSource(MediaRecorder.AudioSource.VOICE_RECOGNITION);
        mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
        mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
        mediaRecorder.setOutputFile(AudioSavePathInDevice.getPath());
        mediaRecorder.prepare();
        mediaRecorder.start();
like image 115
akkmastr Avatar answered Nov 15 '22 09:11

akkmastr