jvde-github / AIS-catcher-for-Android

Android AIS receiver for RTL SDR dongles, Airspy R2, Airspy Mini, Airspy HF+ and TCP (RTL-TCP and SpyServer). Output is send via UDP and visualized on the built-in map
GNU General Public License v3.0
96 stars 7 forks source link

AIS-catcher Android does not shut down when closed #16

Closed g7ruh closed 1 year ago

g7ruh commented 1 year ago

Jasper,

Before the most recent version (with the TCP bug), when using AIS-catcher and accessing the web client, ending the web client would close the web page and the AIS-catcher icon would have an orange dot on it, indicating it was still running in the background.

In the current version, there is no orange dot on closing the web client.

AIS-catcher still runs in the background and processes data and when icon pressed screen comes back with correct display.

If stop feed, the program still runs in the background, the Running Time counter increments, even though there is no feed (tested using rtl_tcp).

I think that the previous version did end, but I might be wrong.

A force stop for the app ends the program and on startup the Running Time counter is reset.

I would expect the following to happen:

Assume AIS-catcher is running with the web client displaying a page:

End web client, should end it (it does) and leaves AIS-catcher still running (it does). It should indicate that the app is running in the background (orange dot), it does not do that.

Select AIS-catcher icon and it displays current data (it was running in background): expected result.

Stop processing by pressing Stop: AIS-catcher disconnects from feed (expected). Running Time increments (if it is 'app running time', that is correct).

Press the square symbol in middle bottom of screen, AIS-catcher appears to close. It still has the Running Timer running. I would expect the app to end and stop completely if not processing data. On restart app, it should be a new session with Running Time reset.

If 'force stop' app, it does end and reset Running Time counter on restart.

Is the current behaviour intended?

Roger

jvde-github commented 1 year ago

Hi Roger, now that you are missing the orange dot/badge, I assume you also do not see in the notification bar a message that the program is running in the background? The badge likely shows that there is a notification associated with the program.

One cause might be that Google forced me to upgrade my target SDK to Android 13 otherwise I could not publish in the Play Store. In Android 13, you have to include code to ask the user permission to show notifications. I need to figure out how to do this. It might be once this is back (and you granted permission) the badge is back.

What version of Android are you running (can have a look in the About dialog in the App)?

The timer shows the time the app has been running or when the last reset was pressed. If you close the program without decoding running, Android might or might not kill the program (depending on resource requirements). If it is killed and restarted the timer will reset. So the timer is not linked to decoding time. I might change that at some point if it is useful.

Think the badge and notifications are a slightly higher priority.

Thanks, Jasper

g7ruh commented 1 year ago

Jasper, is this what you need?

image

Yes, no notification of background running message.

"Google forced me ..." : Don't you just hate it when things that worked before stop working because the vendor changes stuff.... Big Sigh! Sounds like the nice folks at Google have given you extra homework!!

" I might change that at some point if it is useful." ....

I think that the app should stop running if there is no active AIS running, i.e. Stop selected, whatever source: end AIS-catcher. Otherwise it may run in background and use more battery power. Better to stop it running rather than get "blamed" for using valuable battery resource!

Notification of stuff running in background is important, If I am out hiking and using my phone for topographical maps ( https://www.anquet.com/ ) , I may need all the battery power I can get, so any extra apps running without me knowing may deplete the resource. Yes I do carry a whistle and compass and paper map too... "Technology is fine, so long as it works". My map is in a plastic hiking map pocket, so waterproof.

But the maps on the phone are just there and location is there too via phone GPS , rather than stand alone GPS and paper map. Much easier .... until the battery (and standby power box) are flat!

Hope that helps,

Roger

jvde-github commented 1 year ago

Thanks. It looks like you are running Android 13 and it is related to the first bullet here: https://developer.android.com/about/versions/13/behavior-changes-13 Need to figure out what is required.

AIS-catcher does not run in the background by default, only when you are decoding it runs a background service. Agree for this reason the notification is useful so that the user is visually aware.

The program itself cannot really terminate, the OS will manage that automatically. So, we have no control over that. Only thing that can be done is closing the app as a user (guess it is usually swiping up or pressing X).

Thanks for feedback, will have a look at the notification permissions.

g7ruh commented 1 year ago

Thanks for reply, let me know when you need a test of a potential fix. Roger

jvde-github commented 1 year ago

Hi Roger,

Many thanks. I have added some additional code that will ask from the user on Android 13 permission to post notifications. If granted you will see a notification when the app is decoding in the background and this will also be marked by a colored dot on the app icon.

Will let you know once published. As always, many thanks! Jasper

image image

jvde-github commented 1 year ago

Hi Roger, according to Google, the new version is published. For Android 13 the app will ask for permission to show notifications. Thanks for your support.

g7ruh commented 1 year ago

Jasper,

thanks for the notification, I had to press "Open" twice in the Play Store before it said there is an update, maybe that is why I did not see it before. Installed OK. Started AIS-catcher, started web client: all displays working ok on AIS-catcher and on web client. So far so good....

End web client and find AIS-catcher icon has orange disc with a 1 in it: just like it did before the nice folks at Google 'changed the rules'

.... so far so good, looks like you completed your Google Homework assignment with flying colours :)

Start the app (no web client), start the link to rtl_tcp, all OK, app display pages updated as expected. Leave AIS-catcher running and press the square at bottom centre. App screen closes and the icon now has a disc with a 1 in centre. So far very good... so the app is still running in background as it did before the recent Google change in developer rules, and showing the fact.

Let phone close screen and go to standby state, open phone and press AIS-catcher icon, it picks up as before, processing data.

Press stop in app, Counters stop incrementing, except the time as in Running Time. OK so far.... press square icon at bottom centre of screen, app closes and no orange disk showing, so it has shut down (even if not ended app) and shows that it is not processing in background.

EDIT:

Restart app and leave it running and close using square icon at bottom of screen, while it is still running, Orange disc on icon as expected.

END EDIT for clarity / sense

Open phone and select app, still running (expected): Orange disc on icon. Leave map display open... phone does not go into standby state, display remains on and displaying map. I assume this is intended behaviour. Good if it is, because the user can close the app to let the phone shut down. When I was taking pictures for the app at the beach it kept on closing the screen while I was framing the shot... a pain, this is much better.

Many thanks for restoring previous ('normal') operation. I will keep testing. I will close this issue as fixed and open another if I find any issues

I am still waiting for a time when a Container Ship may offer a good background for a Android AIS-catcher at the beach updated photo. So far they have all been when the weather is bad (quite a lot, recently) or at night, many more. Still on the case.

Thank you and from your above post 'Thanks for your support. ': glad to help you make a great app even better.

Roger

jvde-github commented 1 year ago

Perfect, glad to hear! I ask in the app permission not to go to standby state as it might stop the decoding activity on some variants of Android. I think that is what happened with Taxom's phone in this issue: https://github.com/jvde-github/AIS-catcher/issues/153. The screen went off, the OS did not give CPU cycles to the background process and this then derailed the remote AIS-catcher instance. Android is not really build for these type of apps but it is fun to take a decoder when traveling!

g7ruh commented 1 year ago

"Android is not really build for these type of apps but it is fun to take a decoder when traveling!"

Jasper,

I agree, after all it is a hobby and it should be fun, having a portable set-up is great. Even if it is not "perfect", it is more than good enough, and is nice to be able to show folks at the beach an active display and show them vessel names etc.

Roger

jvde-github commented 1 year ago

Fully agree!

Btw, it should now also run offline as the necessary web libraries are embedded in the app itself, so no internet connection is needed. Except for map tiles that are not in cache.

g7ruh commented 1 year ago

Jasper,

I will give off line "mode" a test when the weather gets better... at the weekend, for a change!

Another thing, I think I recall you mentioning somewhere a setting for UDP broadcast, in the main app, I cannot seem to find the reference to it, was I dreaming?

Roger

jvde-github commented 1 year ago

Hi, it was here: https://github.com/jvde-github/AIS-catcher/discussions/136.

EDIT: Added it now to the main documentation.

g7ruh commented 1 year ago

Jasper, Thanks for the pointer. I searched the documentation and could not find it.

Using it here and works fine

Roger