Hacker News new | ask | show | jobs
by gitua 2104 days ago
I'm really curious how Push Notification, App LifeCycle, Localisation Services, Background App/Services, etc. are going to be implemented on Linux phones.

Is each app going to be killed when not in foreground ? Or are they all going to keep running ?

Is there going to be special API for background download manager, notification listening, music playing, etc. or is each app going to keep running in background and do its own stuff like on Desktop ?

For Google & Apple things are super easy : they do what they want.

But For Linux Phones, people from KDE, Gnome, Wayland, Purism, etc. will have to agree on services & APIs which might take lots of time

2 comments

Here’s how I have mine set up:

The phone is suspended when the power button is pressed. Reciving network traffic (ex responses to IDLE on an open IMAP connection) wakes it up and there’s a service that suspends it again fairly quickly if the power button hasn’t been pressed. Another service manages an RTC alarm so that programs expecting pushed data can reestablish sockets if they die (since that won’t necessarily wake the phone.) The only disadvantage to this scheme is that there are more keepalive messages sent (so you should limit the number of services expecting push messages to just a few.)

Mine runs a normal X11 DE (fluxbox) so the apps run in the background just like they do on my laptop. If something wakes the phone up too often just kill it.

I’m still working out the kinks but it seems to get decent battery life this way. No need for some special API.

Interesting , thanks for your answer.

How can you listen to network events while being suspended ? I thought that on linux suspend = all user processes stopped. Does it somehow wake up every nth second to check if there a new message from the network ?

It might work to generally limit CPU and network resources usable by processes not actively foregrounded in the GUI. Linux cgroups is good for this sort of thing.

A bit like some browsers do to timers in non-foreground tabs.

It would simplify development quite a bit if this solution ends up being sufficient for battery life. No need to think about onCreate, onResume, onPause, onStop, onRestart , etc. like on Android.

But RAM might also be a problem if the phone keeps everything in background & isn't allowed to kill any app when it needs to