freshollie / UsbGps4Droid

USB GPS Provider for android :artificial_satellite:. A maintained fork of hvb/USBGps4Droid
GNU General Public License v3.0
82 stars 34 forks source link

Auto Start collecting GPS data on boot up #19

Open Traxtar928 opened 4 years ago

Traxtar928 commented 4 years ago

When android boots up, auto-start the app and begin collecting GPS data for seamless start of maps application, or other applications that require GPS data to function properly.

Currently, I have to manually go into the app and start the GPS collection every boot up.

Implementing this feature will be very useful for those that use an android device as a GPS/navigation system and the device constantly powers on/off with a vehicle/boat/etc.

freshollie commented 4 years ago

Hi.

From the README:

The application's background service can be set to start when the device turns on. Currently the service does not automatically start when the GPS device is plugged into the Android device due to more unwanted usb popups.

For now the background service can be manually started with a start service intent.

Intent intent = new Intent();
intent.setComponent(
  new Component(
      "org.broeuschmeul.android.gps.usb.provider",
      "org.broeuschmeul.android.gps.usb.provider.driver.USBGpsProviderService"
  )
)
intent.setAction("org.broeuschmeul.android.gps.usb.provider.action.START_GPS_PROVIDER")

Or via a shell command as root.

am startservice -a org.broeuschmeul.android.gps.usb.provider.action.START_GPS_PROVIDER -n org.broeuschmeul.android.gps.usb.provider/.driver.USBGpsProviderService

The background service will automatically close itself when the USB device is disconnected for too long.

I also recommend checking out my other app: headunit-controller which can do this for you, though is not as customisable as Tasker

Traxtar928 commented 4 years ago

I have 'start service on boot' selected, but I still have to manually turn on the 'Start/Stop GPS' toggle every time the android box powers on. Will the shell command you referenced from the readme address this?

freshollie commented 4 years ago

The start service on boot should do what you desire. If it's not working, I guess it might be because the USB device is not ready? The shell command will work, but I would imagine you just need to use a tasker delay in order to make it work.

Traxtar928 commented 4 years ago

Great. I'll try it and report back. So far, 'start service on boot' is not working. If it works fine for you, using the GlobalSat BU-353-S4, maybe I should switch to that from the ND-105C. The BeeLink GT King android box I'm using has a pretty quick startup time, and the ND-105C dongle always stays plugged in with a start time of ~35 seconds max (averages about 15 seconds).

I've also tried it on a Samsung S7, just to ensure that it's not the android device causing the startup issue, and I have to manually toggle 'Start/Stop GPS' on that device as well, even with the 'start service on boot' checkbox enabled.

freshollie commented 4 years ago

Btw. For your screen brightness control I recommend autobright and headunit-controller will start this on startup too.

Yeah, not sure exactly if the start service on boot does work for my setup, I made it a long time ago as a feature request and I didn't need to use it on my setup. Does your box do a full system start when you start your car? I might be able to add a delay to the boot start which might fix the issue.

Traxtar928 commented 4 years ago

The box does do a full system start... I have it wired to accessories, so the power is cut when the vehicle is off.

If it helps, right after it boots into android I am able to IMMEDIATELY go into the app and toggle 'Start/Stop GPS' and it will start getting satellite data right away, so it doesn't seem to be a delay issue or timing issue. Whatever happens in the software when that 'Start/stop GPS' is toggled just needs to have an option to be turned on immediately when the app starts.

I can then automate the UsbGps4Droid app to turn on after the OS startup process in your headunit-contoller app.

In my mind, should be an easy implement... not sure about in practice, though. Great job, either way.

Traxtar928 commented 4 years ago

Did you happen to confirm that the app can auto starts collecting GPS data on boot? I want to confirm it's not my device that's causing the problems.

I also tried headunit-controller, but it caused my device to lag terribly. I posted the issue on that app's github page.

freshollie commented 4 years ago

Hi @Traxtar928. I have not been able to confirm this. Circumstance currently means that the car I developed this system with is not used by me anymore, and I do not have access to it. Did you manage to solve these issues?

Traxtar928 commented 4 years ago

Oliver,

I have not been able to resolve it... really discouraging. I am rooted, with TWRP, but I can't 'grant SU permission' to the app. In Xplore, I have even moved the apk to /system/app/ and enabled all r/w/e permissions and the owner/group is root. Still nothing.

I am honestly willing to pay you for your time to get this resolved. End goal is to have GPS auto enabled and communicating with satellites on startup, without any requirements for me to perform special tasks or enable buttons.

Let me know your thoughts.

Kind regards,

Matt

On Tue, Oct 8, 2019 at 8:07 AM Oliver Bell notifications@github.com wrote:

Hi @Traxtar928 https://github.com/Traxtar928. I have not been able to confirm this. Circumstance currently means that the car I developed this system with is not used by me anymore, and I do not have access to it. Did you manage to solve these issues?

β€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/freshollie/UsbGps4Droid/issues/19?email_source=notifications&email_token=ALGGE5QMWO4D2CTD77RX3XDQNSAXXA5CNFSM4ITHX6Y2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEAUC4PQ#issuecomment-539504190, or mute the thread https://github.com/notifications/unsubscribe-auth/ALGGE5R3A3EE5BFUAAF657TQNSAXXANCNFSM4ITHX6YQ .

Traxtar928 commented 4 years ago

The shell command in tasker returns a 255 error. I read somewhere that android pie won't let you invoke startservice, but I'm not sure if that's true or not.

-Matt

On Tue, Nov 12, 2019, 10:34 PM Matthew Kielar matt.kielar@gmail.com wrote:

Oliver,

I have not been able to resolve it... really discouraging. I am rooted, with TWRP, but I can't 'grant SU permission' to the app. In Xplore, I have even moved the apk to /system/app/ and enabled all r/w/e permissions and the owner/group is root. Still nothing.

I am honestly willing to pay you for your time to get this resolved. End goal is to have GPS auto enabled and communicating with satellites on startup, without any requirements for me to perform special tasks or enable buttons.

Let me know your thoughts.

Kind regards,

Matt

On Tue, Oct 8, 2019 at 8:07 AM Oliver Bell notifications@github.com wrote:

Hi @Traxtar928 https://github.com/Traxtar928. I have not been able to confirm this. Circumstance currently means that the car I developed this system with is not used by me anymore, and I do not have access to it. Did you manage to solve these issues?

β€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/freshollie/UsbGps4Droid/issues/19?email_source=notifications&email_token=ALGGE5QMWO4D2CTD77RX3XDQNSAXXA5CNFSM4ITHX6Y2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEAUC4PQ#issuecomment-539504190, or mute the thread https://github.com/notifications/unsubscribe-auth/ALGGE5R3A3EE5BFUAAF657TQNSAXXANCNFSM4ITHX6YQ .

freshollie commented 4 years ago

Ok. Firstly can you try this?

am start-foreground-service -a org.broeuschmeul.android.gps.usb.provider.action.START_GPS_PROVIDER org.broeuschmeul.android.gps.usb.provider/.driver.USBGpsProviderService

Instead of what I recommended.

If you want the app to automatically restart itself on reboot instead, can you look into downgrading the app? https://github.com/freshollie/UsbGps4Droid/releases/tag/v2.1.3

I think this might be because on API 26+ you can't start a service in the background on boot, and v2.1.3 is on API 25.

If so, I will either look into updating the latest app to work on API 26+ or downgrade the whole app to 25 again.

Traxtar928 commented 4 years ago

Well, if tasker is the one executing the shell command, will that matter?

I'll report back once I've tried it. Thanks very much for the continued assistance.

On Wed, Nov 13, 2019 at 10:20 AM Oliver Bell notifications@github.com wrote:

Ok. Firstly can you try this? adb shell am start-foreground-service com.some.package.name/.YourServiceSubClassName Instead of what I recommended.

Also, can you look into downgrading the app? https://github.com/freshollie/UsbGps4Droid/releases/tag/v2.1.3

I think this might be because on API 26+ you can't start a service in the background on boot, and v2.1.3 is on API 25.

β€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/freshollie/UsbGps4Droid/issues/19?email_source=notifications&email_token=ALGGE5UNKZRVCDYI2WOQDLDQTQSNTA5CNFSM4ITHX6Y2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOED6WFVI#issuecomment-553476821, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALGGE5WPTRPDTLMPSIJDSUDQTQSNTANCNFSM4ITHX6YQ .

JanRSmit commented 4 years ago

I am curious to know if there is there any result?

freshollie commented 4 years ago

@JanRSmit yeah, this is definitely a bug since upgrading the SDK to API 26. I will get some time over christmas (hopefully) to test fixing the latest release to work with restarts.

Traxtar928 commented 4 years ago

I simply haven't had the time to implement the most recent suggestions of version rollback and new string command.

I will report results when I do that.

On Tue, Dec 3, 2019, 6:08 AM Oliver Bell notifications@github.com wrote:

@JanRSmit https://github.com/JanRSmit yeah, this is definitely a bug since upgrading the SDK to API 26. I will get some time over christmas (hopefully) to test fixing the latest release to work with restarts.

β€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/freshollie/UsbGps4Droid/issues/19?email_source=notifications&email_token=ALGGE5UYCUOK2JXL7JK5A5TQWZD3TA5CNFSM4ITHX6Y2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEFZE5OA#issuecomment-561139384, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALGGE5T32IBLZARTPSBJEKTQWZD3TANCNFSM4ITHX6YQ .

invisible789 commented 3 years ago

Auto start not working for me too, at reboot it always ask for default permissions for attached usb and service is off, indeed few settings for the app like root permission for system time from gps is lost, else settings remain intact but I've to manually start the service as well I'm scratching my head why it always ask for usb default settings on every boot Please help

freshollie commented 3 years ago

@invisible789 the permission popup is an android issue, it requires authorising USB devices for every reboot, or if the device disconnects. Your only solution is this: https://github.com/freshollie/UsbGps4Droid#usb-permissions-popup

As far as the service not auto starting, I never got a chance to look into the Android 9 issues. Are you running android 9?

invisible789 commented 3 years ago

No, I'm at android 7.1.2 ATV OS, I'm not that learned to Create a new SYSYTEMUI.APK, can I get such help to send you APK and you modify it and share it with so i can replace,, i may be asking too much πŸ₯‡

invisible789 commented 3 years ago

Just for info, such permission is not required in Another app , i'm not quoting its name here, untill you give permission to, its highly unethical , should i share that app name, that app doesn't require any usb permissions again & Again at every reboot , that app source code may be of help to you?

freshollie commented 3 years ago

Yeah, would be helpful for me to have a look, if the app is open source.

invisible789 commented 3 years ago

here's play store link for the app, The app supported other than ppm until version 2.6.0.2 and it never asked usb gps permission except once at first install of the app, it never asks back for usb permissions at all and autostart right away https://play.google.com/store/apps/details?id=de.pilablu.gnsscommander&hl=en it may be of help to community i hope :)

invisible789 commented 3 years ago

here's direct link to version 2.6.0.2 https://mega.nz/file/Kk4iXZYR#1lxtP_wRH907hD498sZ6CpkDuGITrSw7S56-qehwLcw

Traxtar928 commented 3 years ago

After installing GNSS Commander app, it runs and I see my location on the application's built in map, with connected satellite data. It even follows accurately while I drive.

However, my navigation apps don't see my position... I also cannot set the mock location app to GNSS Commander... It says UsbGps (which is the app I've been using, and I've turned off to try this new app). I cannot get GNSS to push my mock location to my android box. The 'set GPS mock location' checkbox is enabled in the app.

I still haven't successfully gotten auto start to work on my vehicle android box. Every time I want to start navigation, I need to manually go into the UsbGps so and start the service.

What am I doing wrong?

On Tue, Sep 29, 2020, 5:43 AM invisible789 notifications@github.com wrote:

here's direct link to version 2.6.0.2 https://mega.nz/file/Kk4iXZYR#1lxtP_wRH907hD498sZ6CpkDuGITrSw7S56-qehwLcw

β€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/freshollie/UsbGps4Droid/issues/19#issuecomment-700620864, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALGGE5TTVCRUKKR3R2LMDULSIG233ANCNFSM4ITHX6YQ .

invisible789 commented 3 years ago

@Traxtar928 Remove usbgps for to work everything properly Than your mock location will be set to this app and auto start will work, that's what happens to me

freshollie commented 3 years ago

I'm a bit confused why you need this app if the other one works @invisible789?

Traxtar928 commented 3 years ago

Indeed. Great question, Oliver. This other app clearly has lots of work invested. If it auto starts and does the same thing UsbGps does, why do you need it to work?

On Wed, Sep 30, 2020, 1:09 PM Oliver Bell notifications@github.com wrote:

I'm a bit confused why you need this app if the other one works @invisible789 https://github.com/invisible789?

β€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/freshollie/UsbGps4Droid/issues/19#issuecomment-701554911, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALGGE5XFTVDYS7F55FZYIHDSINX6VANCNFSM4ITHX6YQ .

invisible789 commented 3 years ago

I'm a bit confused why you need this app if the other one works @invisible789?

Actually your app uses minimum resources on the system , and it's the best part of it, moreover it's accurate & up-to-date, dear apology if i hurt you by sharing other app, looking forward for your super worked app future updates :)

Traxtar928 commented 3 years ago

That's a valid reason. I also prefer UsbGps because it's simple, to the point, programed well, users almost no resources (I have not compared... Have you?), and serves its purpose with no additional frills. If the auto start worked, it would be the perfect app for my needs.

On Wed, Sep 30, 2020, 1:19 PM invisible789 notifications@github.com wrote:

I'm a bit confused why you need this app if the other one works @invisible789 https://github.com/invisible789?

Actually your app uses minimum resources on the system , and it's the best part of it, moreover it's accurate & up-to-date, dear apology if i hurt you by sharing other app, looking forward for your super worked app future updates :)

β€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/freshollie/UsbGps4Droid/issues/19#issuecomment-701559862, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALGGE5TE45UVSTMCCZ3ANA3SINZBLANCNFSM4ITHX6YQ .

invisible789 commented 3 years ago

That's a valid reason. I also prefer UsbGps because it's simple, to the point, programed well, users almost no resources (I have not compared... Have you?), and serves its purpose with no additional frills. If the auto start worked, it would be the perfect app for my needs. … On Wed, Sep 30, 2020, 1:19 PM invisible789 @.***> wrote: I'm a bit confused why you need this app if the other one works @invisible789 https://github.com/invisible789? Actually your app uses minimum resources on the system , and it's the best part of it, moreover it's accurate & up-to-date, dear apology if i hurt you by sharing other app, looking forward for your super worked app future updates :) β€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#19 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALGGE5TE45UVSTMCCZ3ANA3SINZBLANCNFSM4ITHX6YQ .

Exactly ☺️