android – Issue Call Recording using mediaRecorder audioSource VOICE_CALL-ThrowExceptions

Exception or error:

As the VOICE_CALL permission is only for system app as stated in docs ‘This permission is reserved for use by system components and is not available to third-party applications.

  1. I tried installing the application as system app by rooting my phone and then placing the apk in
    ‘/system/app/’ and was successful.

[ i.e. after rebooting phone my app was preinstalled as any other system app ]

  1. manifest.xml
    <uses-permission android:name="android.permission.READ_CALL_LOG"/>
    <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="Manifest.permission.MANAGE_OWN_CALLS"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
    <uses-permission android:name="android.permission.CAPTURE_AUDIO_OUTPUT" tools:ignore="ProtectedPermissions"/>
  1. Recording Code in Kotlin
recorder = MediaRecorder()

  1. Start Recording

ISSUE – App crashes as soon as start recording is called and as the app needs to be system app i am not aware of way to debug the issue.

Purpose of the app is to be able to record user calls (both sides i.e., caller & callee) in best possible quality.
I have tried AudioSource as VOICE_COMMUNICATION & MIC but in those recording’s, voice of callee weren’t audible or quality was poor.

How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *