Google Maps Notifications #1827

Open
opened 2 years ago by gfwilliams · 11 comments

Before reporting a bug, please confirm the following:

  • I have read the wiki, and I didn't find a solution to my problem / an answer to my question.
  • I have searched the issues, and I didn't find a solution to my problem / an answer to my question.
  • If you upload an image or other content, please make sure you have read and understood the github policies and terms of services

I got Gadgetbridge from:

  • F-Droid
  • I built it myself from source code (specify tag / commit)

If you got it from Google Play, please note that version is unofficial and not supported here; it's also often quite outdated. Please switch to one of the above versions if you can.

Your issue is:

I'd like to be able to get Google Maps notifications forwarded to my watch (in the notifications display they have helpful info like the distance to the next turning). It seems like Gadgetbridge is picking them up and deciding they are not important enough to show because the 'local only' flag is set (in NotificationListener.shouldIgnoreNotification).

I included a log, but the relevant part seems to be:

nodomain.freeyourgadget.gadgetbridge.externalevents.NotificationListener: Notification posted: com.google.android.apps.maps: navigation
nodomain.freeyourgadget.gadgetbridge.externalevents.NotificationListener: local only
nodomain.freeyourgadget.gadgetbridge.externalevents.NotificationListener: Ignoring notification

If I tick the checkbox in the 'Blacklist' menu I get a log message saying it was Blacklisted, so Gadgetbridge is definitely finding it. Would it be possible to add another checkbox in 'Blacklist' or elsewhere that said 'allow local only'? I see there are already hard-coded exceptions for Wechat/outlook/skype

Your wearable device is:

Bangle.js

Your android version is:

9

Your Gadgetbridge version is:

Git master as of today

New issues about already solved/documented topics could be closed without further comments. Same for too generic or incomplete reports.

#### Before reporting a bug, please confirm the following: - [x] I have read the [wiki](https://github.com/Freeyourgadget/Gadgetbridge/wiki), and I didn't find a solution to my problem / an answer to my question. - [x] I have searched the [issues](https://github.com/Freeyourgadget/Gadgetbridge/issues), and I didn't find a solution to my problem / an answer to my question. - [x] If you upload an image or other content, please make sure you have read and understood the [github policies and terms of services](https://help.github.com/articles/github-terms-of-service/#1-responsibility-for-user-generated-content) ### I got Gadgetbridge from: * [ ] F-Droid * [x] I built it myself from source code (specify tag / commit) If you got it from Google Play, please note [that version](https://github.com/TaaviE/Gadgetbridge) is unofficial and not supported here; it's also often quite outdated. Please switch to one of the above versions if you can. #### Your issue is: I'd like to be able to get Google Maps notifications forwarded to my watch (in the notifications display they have helpful info like the distance to the next turning). It seems like Gadgetbridge is picking them up and deciding they are not important enough to show because the 'local only' flag is set (in NotificationListener.shouldIgnoreNotification). I included a log, but the relevant part seems to be: ``` nodomain.freeyourgadget.gadgetbridge.externalevents.NotificationListener: Notification posted: com.google.android.apps.maps: navigation nodomain.freeyourgadget.gadgetbridge.externalevents.NotificationListener: local only nodomain.freeyourgadget.gadgetbridge.externalevents.NotificationListener: Ignoring notification ``` If I tick the checkbox in the 'Blacklist' menu I get a log message saying it was Blacklisted, so Gadgetbridge is definitely finding it. Would it be possible to add another checkbox in 'Blacklist' or elsewhere that said 'allow local only'? I see there are already hard-coded exceptions for Wechat/outlook/skype #### Your wearable device is: Bangle.js #### Your android version is: 9 #### Your Gadgetbridge version is: Git master as of today *New issues about already solved/documented topics could be closed without further comments. Same for too generic or incomplete reports.*
Owner

@gfwilliams

Not, currently this is hardcoded, if google maps notification make sense the way they are, then we could also whitelist them.

Can you test that?
I do not have the google apps on my android devices.

@gfwilliams Not, currently this is hardcoded, if google maps notification make sense the way they are, then we could also whitelist them. Can you test that? I do not have the google apps on my android devices.
Poster

Just tried it (I have to ignore 'ongoing notifications' too as it seems otherwise I don't get anything at all), and I get:

"id":1585771232,
"src":"Maps",
"title":"0 yd - High St",
"body":"Abingdon Marina - 21:53 ETA"

So I think it could be useful. The gotcha is that it seems the notification is posted every second, and despite being identical in ID and text the notifications are passed right through.

I'm not sure how other devices work, but do you think things would break if I kept track of the last few notifications (by ID) and only passed new ones through if the content changed?

Just tried it (I have to ignore 'ongoing notifications' too as it seems otherwise I don't get anything at all), and I get: ``` "id":1585771232, "src":"Maps", "title":"0 yd - High St", "body":"Abingdon Marina - 21:53 ETA" ``` So I think it could be useful. The gotcha is that it seems the notification is posted every second, and despite being identical in ID and text the notifications are passed right through. I'm not sure how other devices work, but do you think things would break if I kept track of the last few notifications (by ID) and only passed new ones through if the content changed?
Owner

@gfwilliams

We ignored ongoing notification because

  • They usually update far to often (for a progess bar going from 0 to 100, 101 times)
  • Most device cannot "update" notifications so 101 new would be sent

The idea of only sending them when they change sounds reasonable for Maps, you can send a PR for that if you want, but I would not unlock that feature for ALL apps (beacuse of the progress bars). I an also imagine that it happens with maps when route calculates and there is a progress bar, so please check that also ;)

@gfwilliams We ignored ongoing notification because * They usually update far to often (for a progess bar going from 0 to 100, 101 times) * Most device cannot "update" notifications so 101 new would be sent The idea of only sending them when they change sounds reasonable for Maps, you can send a PR for that if you want, but I would not unlock that feature for ALL apps (beacuse of the progress bars). I an also imagine that it happens with maps when route calculates and there is a progress bar, so please check that also ;)
Poster

Thanks - I'll have to do some tests. It's not like you want a new notification whenever you move 1m nearer your destination!

Is there anything in place to handle notification updates? Obviously there's the ID that wouldn't change, but the assumption is that onNotification is always called with a new ID?

Going forward, would you be ok with me adding a onChangedNotification with an empty default implementation and then adding that to Bangle.js?

Thanks - I'll have to do some tests. It's not like you want a new notification whenever you move 1m nearer your destination! Is there anything in place to handle notification updates? Obviously there's the ID that wouldn't change, but the assumption is that `onNotification` is always called with a new ID? Going forward, would you be ok with me adding a `onChangedNotification` with an empty default implementation and then adding that to Bangle.js?

Most device cannot “update” notifications so 101 new would be sent

Some devices crash even when notifications are updated that fast, not to mention the battery impact.

> Most device cannot “update” notifications so 101 new would be sent Some devices crash even when notifications are updated that fast, not to mention the battery impact.
Owner

Is there anything in place to handle notification updates? Obviously there's the ID that wouldn't change, but the assumption is that onNotification is always called with a new ID?

Going forward, would you be ok with me adding a onChangedNotification with an empty default implementation and then adding that to Bangle.js?

That sounds as if you plan to handle those notifications differently (do you plan any navigation app on the bangle.js itself?)

If so it might be better to do something like "onNavigationInfo" or whatever so that device implentations could also do something special or just turn that into a standard notification if they must.

> Is there anything in place to handle notification updates? Obviously there's the ID that wouldn't change, but the assumption is that `onNotification` is always called with a new ID? > > Going forward, would you be ok with me adding a `onChangedNotification` with an empty default implementation and then adding that to Bangle.js? That sounds as if you plan to handle those notifications differently (do you plan any navigation app on the bangle.js itself?) If so it might be better to do something like "onNavigationInfo" or whatever so that device implentations could also do something special or just turn that into a standard notification if they must.
Owner

The above proposal would imply dissecting the notification further (with eta etc) and I am not sure how feasable that is, assuming translations and differen versions.

Probaby for bigger changes we should use a branch, for something quick and dirty just do it in the notification receiver with some tweak for google maps, without changing the interfaces...

The above proposal would imply dissecting the notification further (with eta etc) and I am not sure how feasable that is, assuming translations and differen versions. Probaby for bigger changes we should use a branch, for something quick and dirty just do it in the notification receiver with some tweak for google maps, without changing the interfaces...
Poster

Ok, thanks! Yeah, the issue with onNavigationInfo would be getting all the data. I imagine I'd have to hook onto something maps-specific which is a bigger undertaking than I had hoped for. Trying to pull it out of the Notification text using what'd basically be a regex sounds like something that'd break very easily.

The idea of a onChangedNotification would be to open up these kinds of events (there must be other apps too) to app developers on Bangle.js - but yes, that's probably a step too far at the moment.

I'm actually finding that right now I'm getting a bit swamped with work, so I'm afraid I'm not going to have a chance to look into this for a few weeks at least. Feel free to close this if that's an issue, and I can reopen it when I have a fix?

Ok, thanks! Yeah, the issue with onNavigationInfo would be getting all the data. I imagine I'd have to hook onto something maps-specific which is a bigger undertaking than I had hoped for. Trying to pull it out of the Notification text using what'd basically be a regex sounds like something that'd break very easily. The idea of a `onChangedNotification` would be to open up these kinds of events (there must be other apps too) to app developers on Bangle.js - but yes, that's probably a step too far at the moment. I'm actually finding that right now I'm getting a bit swamped with work, so I'm afraid I'm not going to have a chance to look into this for a few weeks at least. Feel free to close this if that's an issue, and I can reopen it when I have a fix?

Could it be the reason why I'm not getting notifications from IFTTT on my Mi Band 4?

22:25:21.235 [main] DEBUG n.f.g.e.NotificationListener - Notification posted: com.ifttt.ifttt: null
22:25:21.242 [main] INFO  n.f.g.e.NotificationListener - local only
22:25:21.242 [main] INFO  n.f.g.e.NotificationListener - Ignoring notification
Could it be the reason why I'm not getting notifications from IFTTT on my Mi Band 4? ``` 22:25:21.235 [main] DEBUG n.f.g.e.NotificationListener - Notification posted: com.ifttt.ifttt: null 22:25:21.242 [main] INFO n.f.g.e.NotificationListener - local only 22:25:21.242 [main] INFO n.f.g.e.NotificationListener - Ignoring notification ```
Owner

Could it be the reason why I'm not getting notifications from IFTTT on my Mi Band 4?

22:25:21.235 [main] DEBUG n.f.g.e.NotificationListener - Notification posted: com.ifttt.ifttt: null
22:25:21.242 [main] INFO  n.f.g.e.NotificationListener - local only
22:25:21.242 [main] INFO  n.f.g.e.NotificationListener - Ignoring notification

Seems like yes :)

https://developer.android.com/reference/android/app/Notification.html#FLAG_LOCAL_ONLY

FLAG_LOCAL_ONLY

flags field that should be set if this notification is relevant to the current device only and it is not recommended that it bridge to other devices.

So the app is telling us that we should not forward the notification. This can be overwritten by Gb: #1109

Which is also showing you @m-p-3 what you need to provide (app package name), if it should be changed :)

> Could it be the reason why I'm not getting notifications from IFTTT on my Mi Band 4? > > ``` > 22:25:21.235 [main] DEBUG n.f.g.e.NotificationListener - Notification posted: com.ifttt.ifttt: null > 22:25:21.242 [main] INFO n.f.g.e.NotificationListener - local only > 22:25:21.242 [main] INFO n.f.g.e.NotificationListener - Ignoring notification > ``` Seems like yes :) https://developer.android.com/reference/android/app/Notification.html#FLAG_LOCAL_ONLY FLAG_LOCAL_ONLY flags field that should be set if this notification is relevant to the current device only and it is not recommended that it bridge to other devices. So the app is telling us that we should not forward the notification. This can be overwritten by Gb: https://codeberg.org/Freeyourgadget/Gadgetbridge/issues/1109 Which is also showing you @m-p-3 what you need to provide (app package name), if it should be changed :)
Poster

I feel like having another option in the 'Notification Blacklist' menu would be great here.

So, I finally got my act together and gave it a stab: 1869b5686c

Seems to work great - you go to 'Notification blacklist', your app, preferences (right) then click on 'Show local notifications' and save, then they'll show up.

Could someone have a look over this? It's the first time I've done UI or database stuff in Gadgetbridge so I'm not entirely sure if it's done correctly.

I feel like having another option in the 'Notification Blacklist' menu would be great here. So, I finally got my act together and gave it a stab: https://codeberg.org/gfwilliams/Gadgetbridge/commit/1869b5686cde5bef0a63ffce1477696daaf3ab3e Seems to work great - you go to 'Notification blacklist', your app, preferences (right) then click on 'Show local notifications' and save, then they'll show up. Could someone have a look over this? It's the first time I've done UI *or* database stuff in Gadgetbridge so I'm not entirely sure if it's done correctly.
vanous added the
notifications
label 2 months ago
Sign in to join this conversation.
No Milestone
No Assignees
5 Participants
Notifications
Due Date

No due date set.

Dependencies

This issue currently doesn't have any dependencies.

Loading…
There is no content yet.