• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Register
  • Login
UBports Robot Logo UBports Forum
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Register
  • Login

GPS tracking in Background - Edge Hack (Not Devel, Stable, RC)

Scheduled Pinned Locked Moved App Development
38 Posts 9 Posters 7.2k Views 3 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • E Offline
      ernest
      last edited by ernest 11 Apr 2019, 06:26 6 Jul 2019, 16:42

      Hello,

      As you know to track your activity there is the application Activity Tracker : https://open-store.io/app/activitytracker.cwayne18
      Unfortunately due to the Utouch security policy, GPS signal is not accessible when the screen is off or app is in background, that why the original developer force the screen to stay on, reducing significantly the battery life with no benefit.
      Issue is tracked there : https://github.com/ubports/ubuntu-touch/issues/1067

      Prior using the script please read : https://github.com/ernesst/Utrack/blob/master/README.md

      Enjoy.

      K 1 Reply Last reply 6 Jul 2019, 16:49 Reply Quote 8
      • K Offline
        kugiigi @ernest
        last edited by 6 Jul 2019, 16:49

        @ernest So you mean this script will run even when the screen is locked and closed?
        If yes, then this is really cool and I would definitely try it.
        It would be cool if it works with some kinda of a UI so you can still check from time to time your location in the map 😉

        E 1 Reply Last reply 6 Jul 2019, 17:42 Reply Quote 0
        • E Offline
          ernest @kugiigi
          last edited by 6 Jul 2019, 17:42

          @kugiigi yes it does, screen off and or terminal in background

          E 1 Reply Last reply 21 Aug 2019, 04:22 Reply Quote 0
          • N Offline
            normandc
            last edited by 21 Aug 2019, 03:54

            Hello ernest,

            I started this reply as I was unable to run your script, but as I was writing and testing at the same time, I finally figured it out. 😄

            I'm leaving in a few hours for a 4-day 250 km bike trip, and I will try to test it.

            For those who may happen on this topic and are new to Ubuntu Touch (like me), a few things I struggled with:

            It requires to be launched from a terminal with it "Prevent app suspension" activated in Tweak app.

            You need to install UT Tweak Tool in the OpenStore, launch it, then tap on the menu icon at the top left and select Apps (not sure how it's worded in English, it's an apps list). Next find the Terminal and tap on its entry. It will open a Details window where you will find the "Prevent app suspension" toggle switch.

            The script will not start and makes an error because of line 29 of the GPS_tracking.py script:

            sys.path.insert(0, "/home/phablet/Project/gpxpy-1.3.5/")
            

            It is looking for a "Project" folder that does not exist. You need to change it to the actual name of the folder where the script and the "gpxpy-1.3.5" folder resides, which when downloaded from Gitlab and extracted is by default gps-utouch-tracker-master . For that I edited it in UT's terminal:

            cd gps-utouch-tracker-master
            nano GPS_tracking.py
            

            Another thing that's necessary to make the script run is to make it executable.

            chmod +x GPS_tracking.py
            

            A word of warning: if you forget to activate the terminal's "prevent app suspension" button, once the script is launched, there is no stopping it!!! The CTRL+C button at the bottom will not stop the script. The terminal prompt returns, but GPS points continue to be added. You will have no choice but to quit the terminal and of course no file will be saved.

            The gpx files are saved in the gps-utouch-tracker-master folder, or whatever name you gave it (might be a good idea to rename it 😁 ).

            It would be cool if it works with some kinda of a UI

            Or at least, a minimal GUI to launch, if possible avoid having to enter our password, then a button to stop it... I was thinking of creating a desktop launcher, but I'm out of time, I need to pack and get a few hours of sleep!

            Ernest, thanks for your work on Activity Tracker, and for this script! ☺

            E 1 Reply Last reply 27 Aug 2019, 17:16 Reply Quote 0
            • E Offline
              ernest @ernest
              last edited by ernest 21 Aug 2019, 04:22

              Thanks for the feedback,

              I've removed the hardcoded folder location for the python lib, no need to change name now.

              sys.path.insert(0, "./gpxpy-1.3.5/")
              

              I'm not sure why you need to perform a chmod, the file should already be executable :

              -rwxr-xr-x 1 phablet phablet 3248 Aug 20 23:12 GPS_tracking.py
              drwxrwxr-x 5 phablet phablet 4096 Aug 20 23:12 gpxpy-1.3.5
              -rw-rw-r-- 1 phablet phablet   22 Aug 20 23:12 README.md
              
              

              To simplify the start of the script, create an alias into ~/.bashrc something like

              alias GPS="cd /home/phablet/Project/ && sudo ./GPS_tracking.py"
              

              To acknowlegde the modification you need to close the terminal

              N 1 Reply Last reply 25 Aug 2019, 15:01 Reply Quote 0
              • N Offline
                normandc @ernest
                last edited by 25 Aug 2019, 15:01

                @ernest
                Not sure why, I never got a notification of your reply. Thanks!

                The relative path is of course much cleaner, I didn't think of it. Shows how much of a perpetual newbie I am at scripting.

                Initially the script would not launch until I chmod it, I don't know why. Thanks for the alias trick, I will try it.

                I only tested the script once during my trip. It seems that if the phone needs to be unlocked with a number, it prevents updating of FPS points when the screen is off. To be honest I didn't spend much time on this, I had destinations to get to. Absolutely not your fault, but I still have an insanely hard time dealing with the terminal UI. Trying to scroll through it and use the side scrollbar is a near impossible task.

                E 2 Replies Last reply 27 Aug 2019, 02:35 Reply Quote 0
                • E Offline
                  ernest @normandc
                  last edited by ernest 27 Aug 2019, 02:35

                  @normandc said in GPS tracking in Background - Trick:

                  @ernest
                  I only tested the script once during my trip. It seems that if the phone needs to be unlocked with a number, it prevents updating of FPS points when the screen is off.

                  To have the recording screen off, you have to enable with Tweak tool the option "Prevent suspend" for the terminal app.
                  06e71def-d411-43aa-8d32-4cf59187dbeb-image.png

                  To be honest I didn't spend much time on this, I had destinations to get to. Absolutely not your fault, but I still have an insanely hard time dealing with the terminal UI. Trying to scroll through it and use the side scrollbar is a near impossible task.

                  Check the new version, uploaded today, no more long list the screen is refreshed after each datapoint.
                  I've also add a sum-up calculation at the end :

                  GPX file Created : 1566872659557.gpx
                  
                      Length 2D: 0.004km
                      Length 3D: 0.016km
                      Moving time: 00:00:11
                      Stopped time: 00:14:34
                      Max speed: None
                      Avg speed: 0m/s = 1km/h
                      Total uphill: 3.3m
                      Total downhill: 4.3m
                  
                  N 1 Reply Last reply 27 Aug 2019, 03:27 Reply Quote 1
                  • E Offline
                    ernest @normandc
                    last edited by 27 Aug 2019, 02:41

                    @normandc said in GPS tracking in Background - Trick:

                    Initially the script would not launch until I chmod it, I don't know why. Thanks for the alias trick, I will try it.

                    Yes, trying the last version, i'm facing this issue... my bad.

                    1 Reply Last reply Reply Quote 0
                    • N Offline
                      normandc @ernest
                      last edited by 27 Aug 2019, 03:27

                      @ernest said in GPS tracking in Background - Trick:

                      @normandc said in GPS tracking in Background - Trick:
                      To have the recording screen off, you have to enable with Tweak tool the option "Prevent suspend" for the terminal app.

                      As I wrote, I already enabled this setting.

                      One thing I didn't mention is that I don't have a SIM card in yet, my Android phone is still my main phone until I migrate everything to the OPO. I didn't have any Internet access. I since read that GPS localization seems to be more problematic without a SIM card.

                      Check the new version, uploaded today, no more long list the screen is refreshed after each datapoint.
                      I've also add a sum-up calculation at the end :

                      GPX file Created : 1566872659557.gpx
                      
                          Length 2D: 0.004km
                          Length 3D: 0.016km
                          Moving time: 00:00:11
                          Stopped time: 00:14:34
                          Max speed: None
                          Avg speed: 0m/s = 1km/h
                          Total uphill: 3.3m
                          Total downhill: 4.3m
                      

                      That sounds great, I'm back home and with still a week vacation left, I'm hoping to test this further. Thanks!

                      I wonder, can we install Git on UT? It would make updating your script easier. I think I'll try and see.

                      1 Reply Last reply Reply Quote 0
                      • E Offline
                        ernest @normandc
                        last edited by 27 Aug 2019, 17:16

                        @normandc said in GPS tracking in Background - Trick:

                        A word of warning: if you forget to activate the terminal's "prevent app suspension" button, once the script is launched, there is no stopping it!!! The CTRL+C button at the bottom will not stop the script.

                        I meet the bug, doesn't appear on Edge but on Devel Yes.

                        I'll look at it.

                        1 Reply Last reply Reply Quote 0
                        • N Offline
                          normandc
                          last edited by 27 Aug 2019, 22:10

                          Sorry, I guess I should have mentioned I'm on 16.04/rc.

                          BTW I tried to install git on UT, the package isn't available. I guess I could always git pull from my PC then copy to the phone, but I'm not seeing the gps-utouch-tracker folder from the PC, only the folders Documents, Music, Images and Videos...

                          E 1 Reply Last reply 28 Aug 2019, 00:18 Reply Quote 0
                          • E Offline
                            ernest @normandc
                            last edited by ernest 28 Aug 2019, 00:18

                            @normandc
                            From the phone terminal,

                            wget https://framagit.org/ernesst/gps-utouch-tracker/-/archive/master/gps-utouch-tracker-master.zip && unzip gps-utouch-tracker-master.zip
                            
                            N 1 Reply Last reply 28 Aug 2019, 14:21 Reply Quote 0
                            • N Offline
                              normandc @ernest
                              last edited by 28 Aug 2019, 14:21

                              @ernest thanks, I guess keeping the original folder name (with -master) will make updating easier in the future.

                              E 1 Reply Last reply 31 Oct 2019, 05:11 Reply Quote 0
                              • E Offline
                                ernest @normandc
                                last edited by 31 Oct 2019, 05:11

                                All, i'm looking for good soul to test the last version, please contact me on Telegram : @Ernes_t

                                I've updated the script to : Consume less battery, import automatically the run to Activity Tracker when finished, upload the position in real-time to Phonetrack (Nextcloud) and distributed into a click.

                                I found recently thanks to iperspace, apparmor hack, the script should be able to run under all version.

                                1 Reply Last reply Reply Quote 1
                                • Pulsar33P Offline
                                  Pulsar33
                                  last edited by 31 Oct 2019, 08:49

                                  Thank you all for this subject !
                                  Is there a description (or source code) of the test_gps command somewhere, please ?
                                  BR
                                  Pulsar33

                                  Aquaris BQ E5 HD UBports OTA-25 (currently testing features)
                                  Aquaris BQ E5 HD Ubuntu Edition Canonical OTA-15 (last Canonical version, daily use)
                                  Raspberry Pi 4 B - 4 GB & 8 GB with various OS and Desktops (UBports not OK)

                                  D 1 Reply Last reply 31 Oct 2019, 09:35 Reply Quote 0
                                  • D Offline
                                    doniks @Pulsar33
                                    last edited by 31 Oct 2019, 09:35

                                    @Pulsar33 https://github.com/libhybris/libhybris/blob/master/hybris/tests/test_gps.c

                                    1 Reply Last reply Reply Quote 1
                                    • Pulsar33P Offline
                                      Pulsar33
                                      last edited by 31 Oct 2019, 23:03

                                      Excellent ! Thank you very much @doniks
                                      Best regards
                                      Pulsar33

                                      Aquaris BQ E5 HD UBports OTA-25 (currently testing features)
                                      Aquaris BQ E5 HD Ubuntu Edition Canonical OTA-15 (last Canonical version, daily use)
                                      Raspberry Pi 4 B - 4 GB & 8 GB with various OS and Desktops (UBports not OK)

                                      1 Reply Last reply Reply Quote 0
                                      • E Offline
                                        ernest
                                        last edited by 5 Nov 2019, 04:40

                                        Latest version has been uploaded to openstore.

                                        Please read prior use : https://github.com/ernesst/Utrack/blob/master/README.md

                                        1 Reply Last reply Reply Quote 0
                                        • A Offline
                                          aimar
                                          last edited by 31 Dec 2019, 19:14

                                          Hi all,
                                          I think this app is very useful.
                                          However, I can’t make it work.
                                          I use an Aquaris E4.5 with ubuntu 16.04 (OTA11).
                                          I used the previous script and now the recent updated script with no luck.
                                          I have no issues with the installation, but when I launch the script, it gets stuck with “Waiting for satellites ...”.
                                          When I close the app (Ctrl+C), it creates an empty gpx file.
                                          The rest of apps (ActivityTracker, OSMScout) fetch the data and show my position, so I am sure that GPS is working properly.
                                          What could be the cause?
                                          Thank you for your suggestions.
                                          aimar

                                          E 1 Reply Last reply 1 Jan 2020, 19:21 Reply Quote 0
                                          • E Offline
                                            ernest @aimar
                                            last edited by 1 Jan 2020, 19:21

                                            @aimar
                                            i noticed that the script is neither working with OP3 device. I had to modify it to make it works.
                                            Are you on telegram, if so please contact me @ern_st

                                            1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post