aykuttasil / CallRecorder

Android Phone Call Recorder

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Not working for Android 10

vikash159 opened this issue · comments

commented

audio recorded but no sound

@aykuttasil any update on this issue?

commented

i solved this issue by enabling accessibility service and used VOICE_RECOGNITION. quality is good only on one side. other side its bit low sound. because it using mic

@vikash159 can you please share the working code with us?

commented
 int source = MediaRecorder.AudioSource.VOICE_COMMUNICATION;
        if (Build.VERSION.SDK_INT >= 29) source = MediaRecorder.AudioSource.VOICE_RECOGNITION;
        mCallRecord = new CallRecord.Builder(this)
                .setRecordFileName("Record")
                .setRecordDirName("mobile")
                .setRecordDirPath(Environment.getExternalStorageDirectory().getAbsolutePath())
                .setAudioEncoder(MediaRecorder.AudioEncoder.AMR_WB)
                .setOutputFormat(MediaRecorder.OutputFormat.MPEG_4)
                .setAudioSource(source)
                .setLogEnable(true)
                .setShowSeed(true)
                .setShowPhoneNumber(true)
                .build();
import android.accessibilityservice.AccessibilityService;
public class ServiceAccessibility extends AccessibilityService {


    @Override
    public void onAccessibilityEvent(AccessibilityEvent event) {
    }

    @Override
    public void onInterrupt() {
    }

    @Override
    protected void onServiceConnected() {
        super.onServiceConnected();
    }
}
<service
            android:name=".util.ServiceAccessibility"
            android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">
            <intent-filter android:priority="1000">
                <action android:name="android.accessibilityservice.AccessibilityService" />
            </intent-filter>

            <meta-data
                android:name="android.accessibilityservice"
                android:resource="@xml/accessibility_service_config" />
</service>

res/xml

<?xml version="1.0" encoding="utf-8"?>
<accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"
    android:accessibilityEventTypes="typeAllMask"
    android:accessibilityFeedbackType="feedbackAllMask"
    android:accessibilityFlags="flagRetrieveInteractiveWindows|flagReportViewIds|flagIncludeNotImportantViews"
    android:canRequestFilterKeyEvents="false"
    android:canRetrieveWindowContent="true"
    android:description="@string/accessibility_service_description"
    android:notificationTimeout="100"
    android:packageNames="com.securein" />

permissions

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.READ_CALL_LOG" />
    <uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
    <uses-permission android:name="android.permission.BIND_ACCESSIBILITY_SERVICE" />
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.CALL_PHONE" />

Thanks you @vikash159 for your code and comments, do you have to make any changes on the lib side code as well or its working with the above changes only?

commented

nothing just audio source i have changed. this is not a permanent fix i guess. im still looking for permanent fix because audio captured using mic

Thanks @vikash159 for your comments, I am going to implement and once I will find solution will let you know for sure

@vikash159 Hello,budy. I have a question for the recorder file. I can not find it in the path .
have you got those question?!

@A0shashen00 try to change path to cache data then it will work

commented

@A0shashen00
add this line in manifest application tag if you want to save in storage directory instead of cache directory
android:requestLegacyExternalStorage="true"

@AbdulRehmanNazar Bhai did it work? if yes can you share the code?

@vikash159 @AbdulRehmanNazar Bro have you got any update on this issue? actually i have added this accessibilityService code using this i am able to record calls but in some scenarios only one side voice is audible and in some scenarios both side voice is clearly audible and in some scenarios one side's voice is clear and one side's voice is bit low. so if you have got any fix please let me know.

commented

@erpriyesh it happens with some device or even you use earphone. so no full proof solution i got on this. only samsung device i saw this working properly,

@vikash159 @AbdulRehmanNazar Bro have you got any update on this issue? actually i have added this accessibilityService code using this i am able to record calls but in some scenarios only one side voice is audible and in some scenarios both side voice is clearly audible and in some scenarios one side's voice is clear and one side's voice is bit low. so if you have got any fix please let me know.

@erpriyesh can you please share the piece of code with the class which you had implemented...

i solved this issue by enabling accessibility service and used VOICE_RECOGNITION. quality is good only on one side. other side its bit low sound. because it using mic

@vikash159 Can you please share the working code.

Thanks @vikash159 for your comments, I am going to implement and once I will find solution will let you know for sure

@AbdulRehmanNazar did you got the recorder output file in android 10 I had tried using but I didn't succeed..., it would be great if you share the class file...

@vikash159 hey bro i have tested this in another phone. even after enabling the accessibility service call's voice is silence in recording. and now facing this issue in android 9 also can anyone help me ? @AbdulRehmanNazar

@erpriyesh it works on some device not on all.

@AbdulRehmanNazar have you got any workaround to overcome from this issue ?

@AbdulRehmanNazar @vikash159 hello friends did you find solution for 10 & 11 versions .If you find please let me know thanks

i have tried this code so far to achieve the call recording but voice is too low of the person we are talking too. further more you have to put this code in accessibility service

` final int BITS_PER_SAMPLE = 8; // 16-bit data
final int NUMBER_CHANNELS = 1; // Mono
final int COMPRESSION_AMOUNT = 8; // Compress the audio at 8:1

    int sampleRate = 8000;
    final int uncompressedBitRate = sampleRate * BITS_PER_SAMPLE * NUMBER_CHANNELS;

    final int encodedBitRate = uncompressedBitRate  / COMPRESSION_AMOUNT;
    Log.d(TAG, "startRecordingB: encoded bit rate : "+ encodedBitRate);
    recorder = new MediaRecorder();
    recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_RECOGNITION);
    recorder.setOutputFormat(MediaRecorder.OutputFormat.AMR_NB);
    recorder.setOutputFile(getFilename());
    recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
    recorder.setAudioChannels(1);
    recorder.setAudioSamplingRate(8000);
    recorder.setAudioEncodingBitRate(encodedBitRate);`

@vikash159 about the accessibilty service
uses-permission android:name="android.permission.BIND_ACCESSIBILITY_SERVICE"
this permission is only allowed for system apps how did you handle that?
and i will appreciate it if you share the complete code
i have difficulties implementing accessibility service for android 10.

commented

@MasterKali06
You can't "start" the AccessibilityService as they are not like other services where you can control their start/stop. Rather here the Android system controls starting and stopping them based on the settings the user has selected.

The best you can do is launch the Accessibility settings page and get the user to enable it for you:

Intent openSettings = new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS);
openSettings.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_HISTORY);
startActivity(openSettings);

@vikash159 @MasterKali06 @hareesh145 @AbdulRehmanNazar @kishorekmr61 @umairdexty can any of you please share your working call recorder app repository here please, because I am searching the internet for 1 week and this is the best lead I got so far. I am badly stuck in the installation process of this package. and I cannot move further in this. I urgently need to build a call recorder app in android.
Thank You

@Vinayak-Bhardwaj
As I know you can't record calls from both side anymore, that is the restriction added for new Android OS

https://nllapps.com/apps/acr/android9.htm

Thanks for the response @developer-- , but the above discussion shows that maybe it is possible on android 10. And on the play store as well there exist applications that record calls from both sides. So can you help me with that, please?

can you confirm that they are recording voice from both side with good quality? I think all apps were affected

yes @developer-- , I have myself tested it. On using earphones while talking we can hear clear voices from both ends. If you want then I can share you the link for the application

@Vinayak-Bhardwaj can you please share your code of call recording if possible please?

 int source = MediaRecorder.AudioSource.VOICE_COMMUNICATION;
        if (Build.VERSION.SDK_INT >= 29) source = MediaRecorder.AudioSource.VOICE_RECOGNITION;
        mCallRecord = new CallRecord.Builder(this)
                .setRecordFileName("Record")
                .setRecordDirName("mobile")
                .setRecordDirPath(Environment.getExternalStorageDirectory().getAbsolutePath())
                .setAudioEncoder(MediaRecorder.AudioEncoder.AMR_WB)
                .setOutputFormat(MediaRecorder.OutputFormat.MPEG_4)
                .setAudioSource(source)
                .setLogEnable(true)
                .setShowSeed(true)
                .setShowPhoneNumber(true)
                .build();
import android.accessibilityservice.AccessibilityService;
public class ServiceAccessibility extends AccessibilityService {


    @Override
    public void onAccessibilityEvent(AccessibilityEvent event) {
    }

    @Override
    public void onInterrupt() {
    }

    @Override
    protected void onServiceConnected() {
        super.onServiceConnected();
    }
}
<service
            android:name=".util.ServiceAccessibility"
            android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">
            <intent-filter android:priority="1000">
                <action android:name="android.accessibilityservice.AccessibilityService" />
            </intent-filter>

            <meta-data
                android:name="android.accessibilityservice"
                android:resource="@xml/accessibility_service_config" />
</service>

res/xml

<?xml version="1.0" encoding="utf-8"?>
<accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"
    android:accessibilityEventTypes="typeAllMask"
    android:accessibilityFeedbackType="feedbackAllMask"
    android:accessibilityFlags="flagRetrieveInteractiveWindows|flagReportViewIds|flagIncludeNotImportantViews"
    android:canRequestFilterKeyEvents="false"
    android:canRetrieveWindowContent="true"
    android:description="@string/accessibility_service_description"
    android:notificationTimeout="100"
    android:packageNames="com.securein" />

permissions

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.READ_CALL_LOG" />
    <uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
    <uses-permission android:name="android.permission.BIND_ACCESSIBILITY_SERVICE" />
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.CALL_PHONE" />

Hi @vikash159
How to connect recorder codes to AccessibilityService codes?
Please send the source code

Any updates on android 10 so far?

is there any hack for this issue yet?, or if there is any other solution other than MediaRecorder() object

How can I create a custom call recorder for Android Q like ACR Phone Helper?