chenxiaolong / BCR

A Basic Call Recorder for rooted Android devices
GNU General Public License v3.0
1.49k stars 98 forks source link

Application crash #562

Open xigxmmbc opened 3 days ago

xigxmmbc commented 3 days ago

What's going on and how to solve it?

Generated by AppErrorsTracking 1.3(6) Project URL: https://github.com/KitsunePie/AppErrorsTracking

[Device Model]: MI 9 SE

[Stack Trace]: java.lang.ExceptionInInitializerError at com.chiller3.bcr.settings.SettingsFragment.refreshOutputFormat(Unknown Source:0) at com.chiller3.bcr.settings.SettingsFragment.onCreatePreferences(Unknown Source:108) at androidx.preference.PreferenceFragmentCompat.onCreate(Unknown Source:67) at androidx.fragment.app.FragmentStateManager.create(Unknown Source:70) at androidx.fragment.app.FragmentStateManager.moveToExpectedState(Unknown Source:151) at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(Unknown Source:1156) at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(Unknown Source:81) at androidx.fragment.app.FragmentManagerImpl.execPendingActions(Unknown Source:77) at androidx.fragment.app.FragmentManagerImpl.dispatchStateChange(Unknown Source:66) at androidx.appcompat.app.AppCompatActivity.onStart$androidx$fragment$app$FragmentActivity(Unknown Source:33) at androidx.appcompat.app.AppCompatActivity.onStart(Unknown Source:0) at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1392) at android.app.Activity.performStart(Activity.java:7252) at android.app.ActivityThread.handleStartActivity(ActivityThread.java:2971) at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:180) at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:165) at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:142) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:70) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1832) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:201) at android.app.ActivityThread.main(ActivityThread.java:6826) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873) Caused by: java.lang.NullPointerException: Attempt to get length of null array at android.media.MediaCodecInfo$AudioCapabilities.getSupportedSampleRates(MediaCodecInfo.java:973) at androidx.tracing.Trace.fromCodec-Qn1smSk(Unknown Source:55) at com.chiller3.bcr.format.FlacFormat.(Unknown Source:31) at com.chiller3.bcr.format.Format$Companion$all$2$3.invoke(Unknown Source:2) at com.chiller3.bcr.format.Format$Companion$all$2.invoke(Unknown Source:50) at kotlin.SynchronizedLazyImpl.getValue(Unknown Source:20) at com.chiller3.bcr.format.Format.(Unknown Source:8) ... 25 more

xigxmmbc commented 3 days ago

After making the following modifications, I can now open it // val rates = audioCapabilities.supportedSampleRates // if (rates != null && rates.isNotEmpty()) {

// val ratesUnsigned = rates.toUIntArray() // val default = DiscreteSampleRateInfo.toNearest(ratesUnsigned, tryDefault)!! // // return DiscreteSampleRateInfo(ratesUnsigned, default)

@SuppressLint("SoonBlockedPrivateApi") val SAMPLE_RATE_HZ_MIN_COMPAT: Int = 4000

@SuppressLint("SoonBlockedPrivateApi") val SAMPLE_RATE_HZ_MAX_COMPAT: Int = 48000

Where are the codes to start and end recording? I want to use it to record WeChat calls. Is this feasible?

chenxiaolong commented 2 days ago
Caused by: java.lang.NullPointerException: Attempt to get length of null array
at android.media.MediaCodecInfo$AudioCapabilities.getSupportedSampleRates(MediaCodecInfo.java:973)

That's unfortunate. Seems like a bug in MIUI if it's crashing within the Android framework.

Where are the codes to start and end recording? I want to use it to record WeChat calls. Is this feasible?

The recording process for a single call is handled by RecorderThread. When the thread starts, the recording starts. When the thread is cancelled, the recording stops.

The thread is created from RecorderInCallService. It registers a callback with Android's telephony framework so that it is notified when the call state changes (onCallAdded()/onCallRemoved()/onStateChanged()/onDetailsChanged()).

If you want to modify the code to record third party apps, it'll likely take a significant amount of work. At the very least, RecorderInCallService would have to be replaced with custom call detection logic because Android doesn't really have an API to detect VOIP calls in third party apps. I'm guessing you'd probably need to use the accessibility API to determine when WeChat's calls begin and end.

RecorderThread would probably also need to be updated to point to whichever audio stream WeChat uses (phone calls use MediaRecorder.AudioSource.VOICE_CALL, but third party VOIP calls likely use something different).