Skip to content

Won't record in background #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Aleena1217 opened this issue Aug 20, 2020 · 9 comments
Open

Won't record in background #14

Aleena1217 opened this issue Aug 20, 2020 · 9 comments

Comments

@Aleena1217
Copy link

Hello. I don't know if the app just needs updated or what. I'm on a one plus 7 pro using Android version 10. I have 170gb of free space.
I have given the app all permissions, have made sure that it is not restricted under wifi or mobile data, have made sure it is not restricted by battery optimization settings, and have made sure the app is allowed to run and show notifications in the background after a soft close.
I still cannot get the app to record in the background.
I have the notification in my notification bar that the app is running.
But when I try to open the app I get a screen that says 0 seconds have been recorded and memory is limited to 0 seconds. I have to force close the app completely and reopen it then leave it running without closing it at all to get it to record anything.
I have tried to change the setting to allow more or less data usage and higher or lower quality with no difference. I can't find any other app remotely like this one so I would greatly appreciate any ideas to make it work. Thank you

@Suphax
Copy link
Contributor

Suphax commented Jan 21, 2021

Just an FYI, the main screen takes a while to update the times sometimes, so it will display 0 seconds for a while until it updates, and when it does you can then tap a time to save.

@Aleena1217
Copy link
Author

Aleena1217 commented Jan 21, 2021 via email

@Dreomite
Copy link

Dreomite commented Feb 2, 2021

Just an FYI, the main screen takes a while to update the times sometimes, so it will display 0 seconds for a while until it updates, and when it does you can then tap a time to save.

It does indeed get stuck at 0 seconds, if it attempts to autostart on boot. The only way to unglitch the application is to force-stop, and restart it.

I wanted Echo to autostart, and by looking at BroadcastReceiver.java, I figured, adding

<boolean name="skip_tutorial" value="true" />

to data/user/0/eu.mrogalski.saidit/shared_prefs/eu.mrogalski.saidit.xml would do the trick.

After adding the string, rebooting the device, and unlocking the screen, I saw "Echo is running" notification, also

Echo
1 process and 1 service

in Running services.

But the OS (Android 11) didn't show the microphone icon in the notification bar, meaning Echo has not been recording anything.

When I open the application, I see:

Screenshot_20210202-182243_Echo Screenshot_20210202-182253_Echo

The first screenshot is what you would usually see when opening the application, however, it's also 0 seconds on the 2nd one, which would show the actual time normally. Notice the unset System memory in use. Setting it fixes Memory is limited at... on both screens, but Echo itself is still nonfunctional. Echo can only be fixed by either completely restarting the app, or by clicking on any time-codes which will crash the app.

After analyzing logcat logs, I don't see any Echo errors/messages during system start up.
Here's the output of logcat on crash:

02-02 19:19:21.922   852  3437 D audio_hw_primary: start_output_stream: enter: stream(0xf15021a0)usecase(12: audio-ull-playback) devices(0x2) is_haptic_usecase(0)
02-02 19:19:21.923   852  3437 D audio_hw_primary: select_devices for use case (audio-ull-playback)
02-02 19:19:21.923   852  3437 I msm8974_platform: platform_check_and_set_codec_backend_cfg:becf: afe: bitwidth 16, samplerate 48000 channels 2, backend_idx 4 usecase = 12 device (speaker)
02-02 19:19:21.923   852  3437 D msm8974_platform: platform_split_snd_device: snd_device(2) num devices(1) new_snd_devices(0)
02-02 19:19:21.923   852  3437 I msm8974_platform: platform_check_and_set_codec_backend_cfg: new_snd_devices[0] is 2
02-02 19:19:21.923   852  3437 I msm8974_platform: platform_check_codec_backend_cfg:becf: afe: bitwidth 16, samplerate 48000 channels 2, backend_idx 4 usecase = 12 device (speaker)
02-02 19:19:21.923   852  3437 D msm8974_platform: platform_check_codec_backend_cfg:becf: afe: playback on codec device not supporting native playback set default Sample Rate(48k)
02-02 19:19:21.923   852  3437 I msm8974_platform: platform_check_codec_backend_cfg:becf: afe: Codec selected backend: 4 updated bit width: 24 and sample rate: 48000
02-02 19:19:21.923   852  3437 D audio_hw_primary: check_usecases_codec_backend:becf: force routing 0
02-02 19:19:21.923   852  3437 E msm8974_platform: platform_check_backends_match: Invalid snd_device =
02-02 19:19:21.923   852  3437 D audio_hw_primary: check_usecases_codec_backend:becf: (76) check_usecases curr device: speaker, usecase device: backends match 0
02-02 19:19:21.923   852  3437 D audio_hw_primary: check_usecases_codec_backend:becf: check_usecases num.of Usecases to switch 0
02-02 19:19:21.923   852  3437 D msm8974_platform: platform_split_snd_device: snd_device(2) num devices(0) new_snd_devices(0)
02-02 19:19:21.923   852  3437 D hardware_info: hw_info_append_hw_type : device_name = speaker
02-02 19:19:21.923   852  3437 D msm8974_platform: platform_split_snd_device: snd_device(2) num devices(0) new_snd_devices(0)
02-02 19:19:21.923   852  3437 D audio_hw_primary: enable_snd_device: snd_device(2: speaker)
02-02 19:19:21.923   852  3437 I soundtrigger: audio_extn_sound_trigger_update_device_status: device 0x2 of type 0 for Event 1, with Raise=0
02-02 19:19:21.923   852  3437 D audio_route: Apply path: speaker
02-02 19:19:21.923   852  3437 I audio_hw_utils: audio_extn_utils_update_stream_output_app_type_cfg Allowing 24 and above bits playback on speaker ONLY at default sampling rate
02-02 19:19:21.923   852  3437 E soundtrigger: audio_extn_sound_trigger_update_stream_status: invalid input device 0x0, for event 3
02-02 19:19:21.924   852  3437 D soundtrigger: audio_extn_sound_trigger_update_stream_status: uc_info->id 12 of type 0 device 0x02 for Event 3, with Raise=0
02-02 19:19:21.924   852  3437 W soundtrigger: audio_extn_sound_trigger_update_stream_status: device[0x02]: speaker is NOT used, do NOT transit to adsp.
02-02 19:19:21.924   852  3437 D audio_hw_utils: audio_extn_utils_send_app_type_cfg: usecase->out_snd_device speaker
02-02 19:19:21.924   852  3437 D msm8974_platform: platform_split_snd_device: snd_device(2) num devices(0) new_snd_devices(0)
02-02 19:19:21.924   852  3437 I audio_hw_utils: ULL doesnt need sending app type cfg, returning
02-02 19:19:21.924   852  3437 D msm8974_platform: platform_split_snd_device: snd_device(2) num devices(1) new_snd_devices(0)
02-02 19:19:21.924   852  3437 D audio_hw_utils: audio_extn_btsco_get_sample_rate:Not a BT SCO device, need not update sampling rate
02-02 19:19:21.924   852  3437 D ACDB-LOADER: ACDB -> send_audio_cal, acdb_id = 10011, path = 0, app id = 0x11137, sample rate = 48000
02-02 19:19:21.924   852  3437 D ACDB-LOADER: ACDB -> send_asm_topology
02-02 19:19:21.924   852  3437 D ACDB-LOADER: ACDB -> ACDB_CMD_GET_AUDPROC_STREAM_TOPOLOGY_ID
02-02 19:19:21.924   852  3437 D ACDB-LOADER: ACDB -> send_adm_topology
02-02 19:19:21.924   852  3437 D ACDB-LOADER: ACDB -> ACDB_CMD_GET_AUDPROC_COMMON_TOPOLOGY_ID
02-02 19:19:21.924   852  3437 D ACDB-LOADER: ACDB -> send_audtable
02-02 19:19:21.924   852  3437 D ACDB-LOADER: ACDB -> ACDB_CMD_GET_AUDPROC_COMMON_TABLE_SIZE
02-02 19:19:21.924   852  3437 D ACDB-LOADER: ACDB -> ACDB_CMD_GET_AUDPROC_COMMON_TABLE
02-02 19:19:21.924   852  3437 D ACDB-LOADER: ACDB -> AUDIO_SET_AUDPROC_CAL
02-02 19:19:21.924   852  3437 D ACDB-LOADER: ACDB -> send_audvoltable
02-02 19:19:21.924   852  3437 D ACDB-LOADER: ACDB -> ACDB_CMD_GET_AUDPROC_VOL_STEP_TABLE_SIZE
02-02 19:19:21.924   852  3437 D ACDB-LOADER: ACDB -> ACDB_CMD_GET_AUDPROC_GAIN_DEP_STEP_TABLE, vol index 0
02-02 19:19:21.924   852  3437 D android.hardware.audio.service: Failed to fetch the lookup information of the device 0000271B
02-02 19:19:21.924   852  3437 E ACDB-LOADER: Error: ACDB AudProc vol returned = -19
02-02 19:19:21.924   852  3437 D ACDB-LOADER: ACDB -> AUDIO_SET_VOL_CAL cal type = 12
02-02 19:19:21.924   852  3437 D ACDB-LOADER: ACDB -> ACDB_CMD_GET_AUDPROC_STREAM_TABLE_SIZE
02-02 19:19:21.924   852  3437 D ACDB-LOADER: ACDB -> send_audstrmtable
02-02 19:19:21.924   852  3437 D ACDB-LOADER: ACDB -> ACDB_CMD_GET_AUDPROC_STREAM_TABLE_V2
02-02 19:19:21.924   852  3437 D ACDB-LOADER: ACDB -> audstrm_cal->cal_type.cal_data.cal_size = 16
02-02 19:19:21.924   852  3437 D ACDB-LOADER: ACDB -> send_afe_topology
02-02 19:19:21.924   852  3437 D ACDB-LOADER: ACDB -> ACDB_CMD_GET_AFE_TOPOLOGY_ID
02-02 19:19:21.924   852  3437 D ACDB-LOADER: ACDB -> GET_AFE_TOPOLOGY_ID for adcd_id 10011, Topology Id 112fc
02-02 19:19:21.924   852  3437 D ACDB-LOADER: ACDB -> send_afe_cal
02-02 19:19:21.924   852  3437 D ACDB-LOADER: ACDB -> ACDB_CMD_GET_AFE_COMMON_TABLE_SIZE
02-02 19:19:21.924   852  3437 D android.hardware.audio.service: Failed to fetch the lookup information of the device 0000271B
02-02 19:19:21.924   852  3437 E ACDB-LOADER: Error: ACDB_CMD_GET_AFE_COMMON_TABLE_SIZE Returned = -19
02-02 19:19:21.924   852  3437 D ACDB-LOADER: ACDB -> ACDB_CMD_GET_AFE_COMMON_TABLE
02-02 19:19:21.924   852  3437 D android.hardware.audio.service: Failed to fetch the lookup information of the device 0000271B
02-02 19:19:21.924   852  3437 E ACDB-LOADER: Error: ACDB AFE returned = -19
02-02 19:19:21.924   852  3437 D ACDB-LOADER: ACDB -> AUDIO_SET_AFE_CAL
02-02 19:19:21.924   852  3437 D ACDB-LOADER: ACDB -> send_hw_delay : acdb_id = 10011 path = 0
02-02 19:19:21.924   852  3437 D ACDB-LOADER: ACDB -> ACDB_AVSYNC_INFO: ACDB_CMD_GET_DEVICE_PROPERTY
02-02 19:19:21.924   852  3437 D msm8974_platform: platform_split_snd_device: snd_device(2) num devices(0) new_snd_devices(0)
02-02 19:19:21.924   852  3437 I msm8974_platform: platform_get_custom_mtmx_params: no matching param with id 0 ip_ch 2 op_ch 2 uc_id 12 snd_dev 2
02-02 19:19:21.924   852  3437 D audio_hw_primary: enable_audio_route: apply mixer and update path: audio-ull-playback speaker
02-02 19:19:21.924   852  3437 D audio_route: Apply path: audio-ull-playback speaker
02-02 19:19:21.926   852  3437 D send_data_to_xlog: send_misound_data_to_xlog: enter: usecase(12)
02-02 19:19:21.926   852  3437 D audio_hw_primary: select_devices: done
02-02 19:19:21.926   852  3437 D audio_hw_primary: start_output_stream: Opening PCM device card_id(0) device_id(17) format(0)
02-02 19:19:21.926   852  3437 D msm8974_platform: platform_set_channel_map mixer_ctl_name:Playback Channel Map17
02-02 19:19:21.926   852  3437 D msm8974_platform: platform_set_channel_map: set mapping(1 2 0 0 0 0 0 0) for channel:2
02-02 19:19:21.926   852  3437 E msm8974_platform: platform_set_channel_map: Could not set ctl, error:-22 ch_count:2
02-02 19:19:21.929  6552  6552 D AndroidRuntime: Shutting down VM
--------- beginning of crash
02-02 19:19:21.930  6552  6552 E AndroidRuntime: FATAL EXCEPTION: main
02-02 19:19:21.930  6552  6552 E AndroidRuntime: Process: eu.mrogalski.saidit, PID: 6552
02-02 19:19:21.930  6552  6552 E AndroidRuntime: java.lang.IllegalStateException: Not listening!
02-02 19:19:21.930  6552  6552 E AndroidRuntime: 	at eu.mrogalski.saidit.aa.run(SourceFile:394)
02-02 19:19:21.930  6552  6552 E AndroidRuntime: 	at android.app.Activity.runOnUiThread(Activity.java:7068)
02-02 19:19:21.930  6552  6552 E AndroidRuntime: 	at eu.mrogalski.saidit.z.a(SourceFile:384)
02-02 19:19:21.930  6552  6552 E AndroidRuntime: 	at eu.mrogalski.saidit.an.run(SourceFile:481)
02-02 19:19:21.930  6552  6552 E AndroidRuntime: 	at android.os.Handler.handleCallback(Handler.java:938)
02-02 19:19:21.930  6552  6552 E AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:99)
02-02 19:19:21.930  6552  6552 E AndroidRuntime: 	at android.os.Looper.loop(Looper.java:223)
02-02 19:19:21.930  6552  6552 E AndroidRuntime: 	at android.app.ActivityThread.main(ActivityThread.java:7660)
02-02 19:19:21.930  6552  6552 E AndroidRuntime: 	at java.lang.reflect.Method.invoke(Native Method)
02-02 19:19:21.930  6552  6552 E AndroidRuntime: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
02-02 19:19:21.930  6552  6552 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
02-02 19:19:21.927     0     0 D tas2557 2-004c: tas2557_startup
02-02 19:19:21.929     0     0 I         : snd_pcm_hw_constraint_integer failed
02-02 19:19:21.929     0     0 I msm_pcm_open: P buffer bytes minmax constraint ret 1
02-02 19:19:21.929     0     0 D tas2557 2-004c: tas2557_hw_params
02-02 19:19:21.929     0     0 D tas2557 2-004c: tas2557_setup_clocks: nSamplingRate = 48000 [Hz]
02-02 19:19:21.929     0     0 I tas2557 2-004c: Sampling rate for current configuration matches: 48000
02-02 19:19:21.932     0     0 D tas2557 2-004c: tas2557_set_bias_level: 1
02-02 19:19:21.932     0     0 D tas2557 2-004c: tas2557_set_bias_level: 2
02-02 19:19:21.932     0     0 D tas2557 2-004c: tas2557_set_bias_level: 3
02-02 19:19:21.933     0     0 D tas2557 2-004c: tas2557_prepare
--------- beginning of system
02-02 19:19:21.934  1615  3503 W ActivityTaskManager:   Force finishing activity eu.mrogalski.saidit/.SaidItActivity
02-02 19:19:21.938  1615  8058 I DropBoxManagerService: add tag=data_app_crash isTagEnabled=true flags=0x2
02-02 19:19:21.939     0     0 D tas2557 2-004c: tas2557_mute
02-02 19:19:21.939     0     0 D tas2557 2-004c: Enable: 1
02-02 19:19:21.940     0     0 D tas2557 2-004c: Enable: load startup sequence
02-02 19:19:21.944     0     0 D tas2557 2-004c: Enable: load unmute sequence
02-02 19:19:21.947  6552  6552 I Process : Sending signal. PID: 6552 SIG: 9
02-02 19:19:21.949   852  3437 D audio_hw_primary: start_output_stream: pcm_prepare
02-02 19:19:21.949   852  3437 D audio_hw_primary: start_output_stream: exit
02-02 19:19:21.949   852  3437 D audio_hw_primary: out_write: retry previous failed cal level set
02-02 19:19:21.949   852  3437 D msm8974_platform: platform_split_snd_device: snd_device(2) num devices(1) new_snd_devices(0)
02-02 19:19:21.949   852  3437 D msm8974_platform: platform_split_snd_device: snd_device(2) num devices(0) new_snd_devices(0)
02-02 19:19:21.949   852  3437 I msm8974_platform: platform_get_custom_mtmx_params: no matching param with id 0 ip_ch 2 op_ch 2 uc_id 12 snd_dev 2
02-02 19:19:21.949   852  3437 W qc_adm  : margin check: adm_request_focus_v2_1(p) failed diff -480
02-02 19:19:21.950   852  3437 W qc_adm  : margin check: adm_abandon_focus(p) failed diff -480
02-02 19:19:21.950   852  3437 D qc_adm  : ns 2999792 > expected_ns 2000000 (skipped 0)
02-02 19:19:21.952   852  3437 D qc_adm  : ns 3796354 > expected_ns 3000000 (skipped 0)
02-02 19:19:21.959   852  3437 D qc_adm  : ns 2693438 > expected_ns 2000000 (skipped 0)
02-02 19:19:21.954     0     0 D tas2557 2-004c: IRQ Status: 0x2, 0x0
02-02 19:19:21.954     0     0 D tas2557 2-004c: irq_work_routine: INT1=0x2, INT2=0x0; PowerUpFlag=0xfc
02-02 19:19:21.965   852  3437 D qc_adm  : ns 2559531 > expected_ns 2000000 (skipped 0)
02-02 19:19:21.971  1615  2060 W InputDispatcher: channel 'd6a06a0 eu.mrogalski.saidit/eu.mrogalski.saidit.SaidItActivity (server)' ~ Consumer closed input channel or an error occurred.  events=0x9
02-02 19:19:21.971  1615  2060 E InputDispatcher: channel 'd6a06a0 eu.mrogalski.saidit/eu.mrogalski.saidit.SaidItActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
02-02 19:19:21.971   852  3437 D qc_adm  : ns 2694323 > expected_ns 2000000 (skipped 0)
02-02 19:19:21.972  1615  5519 I ActivityManager: Process eu.mrogalski.saidit (pid 6552) has died: fg  TOP
02-02 19:19:21.972  1615  3503 I WindowManager: WIN DEATH: Window{d6a06a0 u0 eu.mrogalski.saidit/eu.mrogalski.saidit.SaidItActivity}
02-02 19:19:21.972  1615  3503 W InputDispatcher: Attempted to unregister already unregistered input channel 'd6a06a0 eu.mrogalski.saidit/eu.mrogalski.saidit.SaidItActivity (server)'
02-02 19:19:21.972  1615  1764 I libprocessgroup: Successfully killed process cgroup uid 10238 pid 6552 in 0ms
02-02 19:19:21.973   737   737 I Zygote  : Process 6552 exited due to signal 9 (Killed)
02-02 19:19:21.975  1615  2758 W WindowManager: Cannot find window which accessibility connection is added to
02-02 19:19:21.976  1615  5519 W ActivityManager: Scheduling restart of crashed service eu.mrogalski.saidit/.SaidItService in 1000ms for start-requested

I'm not an Android dev, so I cannot make use of it, but maybe there's something obvious.


I should probably mention that I use pure AOSP (LinageOS) with battery optimizations disabled.

@Suphax
Copy link
Contributor

Suphax commented Feb 2, 2021

Would it be possible for you to get logs from a debug build? As I'm 99% sure debug would give more specific info than that, though that exception java.lang.IllegalStateException: Not listening! is thrown only in one place as far as I know it might give a more detailed stacktrace and help clarify why it's being thrown.

Have you tested this on anything other than LineageOS? Might not be an issue but helps to cover more ground. Not asking you to as I know that's quite a task to do so no need to, just curious.

I've used this app on my phone running Android 10 and it more or less works fine so it could be an issue with 11 specifically as I know they've put a focus on security 11 in terms of file storage etc.

@Dreomite
Copy link

Dreomite commented Feb 3, 2021

You were right! It is a security restriction of Android 11. So, it is no longer possible to automatically start Echo in the background, unless you make it a privileged system application.

To make it work, you have to do 3 things.

Update AndroidManifest.xml

This new permission is required:

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

Make Echo a privileged app

I used TWRP for this. For some reason, if I use termux + Magisk root, all the modifications performed in /system are gone after I reboot the device.

  1. Mount /system as read-write.
  2. Create new /system/priv-app/SaidIt* folder + chmod 755.
  3. Move SaidIt.apk* to this folder + chmod 644
  4. Create and move permissions_eu.mrogalski.saidit.xml* to /system/etc/permissions + chmod 644
    <?xml version="1.0" encoding="utf-8"?>
      <permissions>
          <privapp-permissions package="eu.mrogalski.saidit">
            <permission name="android.permission.START_ACTIVITIES_FROM_BACKGROUND" />
          </privapp-permissions>
      </permissions>

* - Actual file/folder names don't matter.

Make it survive OTA updates

Unfortunately, during system updates (manual or automatic), the system partition gets completely overwritten. To make Echo survive these update, make use of /system/addon.d (exists only in LineageOS and some custom roms) and put 80-saidit.sh in it.

list_files() {
cat <<EOF
etc/permissions/permissions_eu.mrogalski.saidit.xml
priv-app/SaidIt/SaidIt.apk
EOF
}

case "$1" in
  backup)
    list_files | while read FILE DUMMY; do
      backup_file $S/"$FILE"
    done
  ;;
  restore)
    list_files | while read FILE REPLACEMENT; do
      R=""
      [ -n "$REPLACEMENT" ] && R="$S/$REPLACEMENT"
      [ -f "$C/$S/$FILE" ] && restore_file $S/"$FILE" "$R"
    done
  ;;
  pre-backup)
    # Stub
  ;;
  post-backup)
    # Stub
  ;;
  pre-restore)
    # Stub
  ;;
  post-restore)
    # Stub
  ;;
esac

@G2G2G2G
Copy link

G2G2G2G commented Oct 19, 2021

is this related to how it freezes and doesn't save anything when you close and re-open the app? (which it was in background there) also when turning screen off/on

@infinity0
Copy link

infinity0 commented Dec 4, 2022

I needed this and wrote an alternative here: https://github.com/infinity0/Circular-Recorder/releases/tag/1.0.1.1

Docs here: https://github.com/infinity0/Circular-Recorder#circular-recorder

(Yes, background recording does work on my one.)

@GitAritron
Copy link

It doesn't work for me too - just freezes on 0 when the app is not in focus.

@GitAritron
Copy link

@infinity0 It's good, would be even better if it has auto delete option (just as this one)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants