chenxiaolong / BCR

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

App Crashes on Call #533

Closed nutzboi closed 2 months ago

nutzboi commented 2 months ago

App crashes when call starts. Crash log says:

msg: java.io.IOException: Failed to create file ERROR_20240421_123211.501+0200_in_sim2_<phone number(s)>_<contact name(s)>.log in file:///storage/emulated/0/Android/data/com.chiller3.bcr/files
stacktrace: java.io.IOException: Failed to create file ERROR_20240421_123211.501+0200_in_sim2_<phone number(s)>_<contact name(s)>.log in file:///storage/emulated/0/Android/data/com.chiller3.bcr/files
    at com.chiller3.bcr.output.OutputDirUtils.createFile(Unknown Source:124)
    at com.chiller3.bcr.output.OutputDirUtils.createFileInDefaultDir(Unknown Source:53)
    at com.chiller3.bcr.RecorderThread.run(Unknown Source:34)

Also, my recordings directory was not the default one, although changing it back to the default one yields the same crash log.

MatLog also displays the errors:

04-21 13:09:51.289 W/ResourcesManager(5044): failed to preload asset path '/system/priv-app/com.chiller3.bcr/app-release.apk'
04-21 13:09:51.289 W/ResourcesManager(5044): java.io.IOException: Failed to load asset path /system/priv-app/com.chiller3.bcr/app-release.apk
04-21 13:09:51.289 W/ziparchive(5044): Unable to open '/system/priv-app/com.chiller3.bcr/app-release.apk': No such file or directory
04-21 13:09:51.289 E/gs.intelligence(5044): Failed to open APK '/system/priv-app/com.chiller3.bcr/app-release.apk': I/O error
04-21 13:09:51.289 E/ResourcesManager(5044): failed to add asset path '/system/priv-app/com.chiller3.bcr/app-release.apk'
04-21 13:09:51.289 E/ResourcesManager(5044): java.io.IOException: Failed to load asset path /system/priv-app/com.chiller3.bcr/app-release.apk
04-21 13:09:51.289 W/PackageManager(5044): Failure retrieving resources for com.chiller3.bcr
04-21 13:09:55.495 D/ActivityManager(1757): freezing 12708 com.chiller3.bcr

crDroid 10.4 with Kitsune. BCR is on the SuList and has all permissions except Read Call Log.

chenxiaolong commented 2 months ago

Hmm, the I/O error in:

04-21 13:09:51.289 E/gs.intelligence(5044): Failed to open APK '/system/priv-app/com.chiller3.bcr/app-release.apk': I/O error

is concerning. That was reported before in https://github.com/chenxiaolong/BCR/issues/251 too. Are you able to try with official Magisk? (I don't know that it would fix the problem, but a lot of people have reported bugs with how Kitsune mounts the module directories in the past.)

Also, my recordings directory was not the default one, although changing it back to the default one yields the same crash log.

BCR always records to the default directory first and then moves it to the output directory after the call ends. This is likely why you see the crash no matter what directory is selected.

This is unfortunately necessary because some ROMs have a really slow implementation of Android's storage access framework. On these devices, writing directly to the output directory is slow enough to lose ~20 seconds of the beginning of the recording and have constant audio drops throughout the recording.

nutzboi commented 2 months ago

Same error with official Magisk 27.0 TwT.

chenxiaolong commented 2 months ago

Hmm, sorry, I don't really have any other suggestions. I don't know why certain Android components would be hitting the I/O error when accessing BCR's APK.

Just in case the permission issue has a different root cause than the I/O error, can you try removing BCR and manually deleting /data/media/0/Android/data/com.chiller3.bcr with a root file manager before installing it again?

nutzboi commented 2 months ago

can you try removing BCR and manually deleting /data/media/0/Android/data/com.chiller3.bcr with a root file manager before installing it again?

Worked. πŸ’€πŸ₯³ Thank you. πŸ™

I think this means the app lost access to its own data folder (like here too) after upgrading android and reinstalling the app? If you believe that's true, do you know a quick fix for that issue (like chmodding the folder perhaps)? Thanks again, and sorry for the trouble as well. πŸ˜“

chenxiaolong commented 2 months ago

Great! Yeah, it's possible to manually fix the permissions. Assuming you're familiar with running commands as root in adb shell, this is how you would do it:

  1. Get the app's user ID and SELinux MLS by running:

    ps -efZ | grep com.chiller3.bcr

    The output will look something like this:

    u:r:priv_app:s0:c512,c768      u0_a156      23463   970 5 09:51:54 ?     00:00:00 com.chiller3.bcr
                    ^^^^^^^^^      ^^^^^^^
                       MLS         User ID
  2. Set the permissions (replacing <User ID> with the actual value):

    chown -R <User ID>:ext_data_rw /data/media/0/Android/data/com.chiller3.bcr
  3. Set the SELinux labels (replacing <MLS> with the actual value):

    For the main directory:

    chcon u:object_r:media_rw_data_file:s0 /data/media/0/Android/data/com.chiller3.bcr

    and then for the files inside of it:

    chcon -R u:object_r:media_rw_data_file:s0:<MLS> /data/media/0/Android/data/com.chiller3.bcr/*

(If you run into this with other apps, the same procedure should work for them too. Just replace com.chiller3.bcr with the proper app ID.)

nutzboi commented 2 months ago

Thank you sooooo much! you're a lifesaver ❀️