Skip to content

[android] SMS messages dismissed on phone aren't removed #4209

@kidneyhex

Description

@kidneyhex

Affected hardware version

Bangle 2, Bangle 1

Your firmware version

2v29.28

The bug

I'm working on a fix, but if anyone wants to beat me to it, go ahead. I'm not sure when I'll get around to finishing it.

Problem

When an SMS is received on the phone, Gadgetbridge sends it to the watch.
When the user dismisses that SMS on the phone, the watch should remove it, but it doesn't.

Debugging Notes

On the GadgetBridge side

To quote android\lib.js:

// Detect a weird GadgetBridge bug and fix it
// For some reason SMS messages send two GB notifications, with different sets of info

Gadgetbridge has two paths that fire for each incoming SMS:

  1. SMSReceiver: a BroadcastReceiver for SMS_RECEIVED. Fires immediately and sends {t:"notify", id:idA, ...} to the watch. The idA ID is not tracked for removal.

  2. NotificationListener: an Android NotificationListenerService. Fires when the SMS app creates its Android notification. These IDs are tracked for removal via notificationsActive and mNotificationHandleLookup.

A filter shouldIgnoreSource() is called in both onNotificationPosted() and onNotificationRemoved(). For some hardcoded SMS apps (com.android.mms, org.fossify.messages, ...), it returns true, blocking posting/removal in the NotificationListener path.

For SMS apps NOT in the hardcoded list (Google Messages, Samsung Messages), both paths fire, creating two notifications with different IDs. So the watch gets duplicate msgs.

When the user dismisses the SMS on the phone, notify- is sent with the NotificationListener's ID (idB), but the watch usually seems to store the message under SMSReceiver's ID (idA).

On the android\lib.js side

There's a workaround in android/lib.js that tried to merge duplicate SMS notifications. It's checking lastMsg.src == undefined, which no longer matches because BangleJSDeviceSupport overrides src to SMS Message for all GENERIC_SMS types.

Installed apps

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions