ubports / ubuntu-touch

Ubuntu Touch's issue inbox is now migrated to GitLab.
https://gitlab.com/ubports/ubuntu-touch
1.29k stars 110 forks source link

GPS in Background #1067

Open ernesst opened 5 years ago

ernesst commented 5 years ago

I wanted to track this request, even if it's far from being a priority.

I'm accustomed to record GPS track, Activity Tracker is fairly nice for that. (it's a reason I'm maintaining it). Keeping the screen on it's overkill for the battery, especially during hiking :)

Feature request : Enabling (small word for a lot of lines) GPS access in background. This could be authorized only for Unconfined app that would require a manual code check.

Just to track and start a discussion on it.

kugiigi commented 5 years ago

Apparently location works even on locked screen on the edge channel. Still doesn't work though when switching apps. And it still doesn't work all the time but it does most of the time. I'm not sure if there was something changed in GPS code in the edge channel or it's just a result of something changed in MIR/Unity 8 which might actually be a bug.

Flohack74 commented 5 years ago

If you allow background activity with the UT Tweak Tool, it wont work even with screen off?

kugiigi commented 5 years ago

If you allow background activity with the UT Tweak Tool, it wont work even with screen off?

No, it still won't work because the location service stops when the app that uses it is not in the foreground. The lock screen I think is getting the focus when locked. Perhaps that was changed in the new Unity 8 so location still works on lock screen.

ernesst commented 5 years ago

I've made a wrapper to track in background : https://forums.ubports.com/topic/2894/gps-tracking-in-background-trick / https://framagit.org/ernesst/gps-utouch-tracker

dobey commented 5 years ago

If you allow background activity with the UT Tweak Tool, it wont work even with screen off?

No, it still won't work because the location service stops when the app that uses it is not in the foreground. The lock screen I think is getting the focus when locked. Perhaps that was changed in the new Unity 8 so location still works on lock screen.

It's not stopped, but there very well could be some bugs here, especially if it's failing to grab wake lock, and the phone goes to deep sleep.

Talkless commented 4 years ago

I too hit on this issue. Wanted to record GPS track to add it to the OpenStreetMap, but to do that I had to disable screen auto-lock, dim the backlight to conserve power, and just keep ActivityTracker in foreground for whole time...

hscheewel commented 4 years ago

I would also like to express my interest in GPS access for applications in the background/when the screen is switched off. This feature would improve navigation apps, enable tracking of bike/hiking trips, enable location tagging of pictures (without waiting 1 minute prior to taking a "snapshot"), etc.

For the moment, the Utrack hack from @ernesst worked fine for me. But it can obviously not cover all the potential functionalities of a true GPS access in the background.

hscheewel commented 3 years ago

Hi @mardy , just asking out of curiosity: Does your PR fix the background location service for apps like the Activity tracker e.g.? That would be amazing! :tada:

mardy commented 3 years ago

Hi @mardy , just asking out of curiosity: Does your PR fix the background location service for apps like the Activity tracker e.g.? That would be amazing! tada

Unfortunately my MR is only a part of the story: by itself, it does not change anything. We also need changes in Lomiri, to read the list of active location clients and periodically wake them up.

Once that is done, then yes, all apps using location will be able to function in the background.

magdesign commented 2 years ago

On OP6 the patch from @mardy worked great and helped me and others to be able to use GPS.

However, with OTA-21 sudo ubports-qa install xenial_-_locationbg ends in stuck on 'unlocked bootloader' warning....

Any hints on how to apply the changes manually to bring back GPS on OP6?

Forum post here

amrmons commented 2 years ago

to keep processes running normal while the screen is off sudo -i echo 'DefaultStateMachine' > /sys/power/wake_lock To revert back echo 'CHG_PLCY_Legacy_WL' > /sys/power/wake_lock

Fuseteam commented 1 year ago

some work to address this has landed now: https://gitlab.com/ubports/development/core/lomiri/-/merge_requests/70