Post #2768160
2023-12-12 16:42 UTC
@dalias@hachyderm.io Precisely, the background action is used to keep the socket alive because the app will not be sent to sleep (battery optimized). This is also what Signal does for their websocket connection which is used to listen for push notifications. The thing is that this background notification is not free in terms of battery usage. Using a service like FCM to wake up you app would safe on this background service, thus saving on battery.
Replies (1)
-
@dalias@hachyderm.io 2023-12-12 16:49
@ck@chaos.social It absolutely is free - provided your program is not doing anything idiotic. The Android notion of "sent to sleep" is not needed to *actually* sleep, which is a POSIX notion and a much better design. A task which is blocked on poll() does not use any more battery than one that doesn't exist at all, and it uses *less* than one that Android has "sent to sleep" because there is zero overhead to restart it on the event when it arrives.