phyphox/phyphox-android

Background mode (wakelock?) in the app

Opened this issue · 10 comments

Please add the optional feature of continuation of the experiment in the background mode.

When making a long-time measurement it can happen that the device is locked (or the screen turned off, or you switch to another app, whatever), and app pauses the experiment. Sometimes it is a trouble to gather the data in such a case.

// BTW, congratulations with F-Droid release, phyphox is great to appear here

Thanks, this is on our todo list, but only as a long-term goal without a specific time at which we plan to start on this task.
The problem here is that the app needs to be split into the user interface part and the data acquisition and analysis part, so the former can run as an activity (Android terminology for a process with visible user interface) and the latter as a service (a process running in the background, typically showing an icon in the notification bar). At the moment, phyphox is an activity (technically speaking it consists of multiple activities) and activities are stopped by the OS as soon as they stop being visible and there is no way around that. Splitting however should be possible (not sure what is actually allowed for a process and what not), but it requires some major restructuring of the app, which is why we have not tackled it yet.

Also be careful about services.
In the latest Android versions (Oreo and Pie) background services are restricted in the execution time, so it is needed to create a "persistent notification" during the measurement to ensure the service will not stop.

nakic commented

I was about to use phyphox to collect pavement smoothness data while cycling around collecting street view imagery. I need to have a map on screen to do something like that, which unfortunately kills phyphox, so I have to do without it or find something else that can get it done. Just my 2c.

Please, let us know if you find something. Would be encouraging to see what is actually possible in the background.

nakic commented

I created a feature request to record accellerometer data in OSMAnd: it seemed a much easier task there than it is here, given the apps' architectures. We'll see what happens.

OSMAnd is the map app in question and you asked them to log sensor data? Seems indeed like the easiest solution if they do that, but it's not the reference case I would have hoped for as their app would be in the foreground. Still, for your case a simple solution, indeed.

nakic commented

Yup, just trying to be pragmatic. FWIW, there are action cameras (e.g Garmin Virb) which have location and acceleration sensors and produce GPX output with accelerometer data out of the box, so I'd imagine there's already a need for something like that (as marginal as it might be).

It's a drop in the ocean in terms of the kinds of sensing phyphox supports, of course, but given that no progress on background execution was made in 3 years, it seemed reasonable to try the other way. If it's not a priority, it's not a priority: that's fine, but I'm doing what I can to find a solution to the immediate problem.

Not sure if limited to tablets,but this android one allows two up in split screen mode, or more with freeform (but one media player can play...).

For reference, the OsmAnd issue is still open and labeled as 'nice-to-have' with no further activity since. osmandapp/OsmAnd#12227

Background data collection in phyphox is also something I would love!

As you bring this to my attention:

The latest version of phyphox has an option to lock the screen when the proximity sensor is triggered.
This is not exactly the same as the request in this issue, but it might help in many situations that would ask for a background mode like recording on a roller coaster with the phone in your pocket. It simply turns off the screen and no longer accepts touch input while still running the app as long as something is close to the proximity sensor (typically next to the speaker of the phone), which would be the case in an pocket.

The nice thing about this is that this is a system feature that is usually used by phone apps, so you do not dial anything with your cheek. Therefore it should work quite reliably on almost all phones without any need for special permissions.