Skip to content

Fix #82: Filter blocked contacts from notification query#168

Open
navneetsingh-dev wants to merge 3 commits into
GrapheneOS:mainfrom
navneetsingh-dev:main
Open

Fix #82: Filter blocked contacts from notification query#168
navneetsingh-dev wants to merge 3 commits into
GrapheneOS:mainfrom
navneetsingh-dev:main

Conversation

@navneetsingh-dev

Copy link
Copy Markdown

The getNotificationQuerySql method was previously fetching all unread incoming messages, including those from blocked contacts. This commit injects a ParticipantColumns.BLOCKED = 0 check to ensure blocked messages do not trigger system notifications or audio alerts.

The getNotificationQuerySql method was previously fetching all unread incoming messages, including those from blocked contacts. This commit injects a ParticipantColumns.BLOCKED = 0 check to ensure blocked messages do not trigger system notifications or audio alerts.

@navneetsingh-dev navneetsingh-dev left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all the changes made in the file are functional and had finally resolved

@navneetsingh-dev
navneetsingh-dev marked this pull request as draft June 26, 2026 17:47
@navneetsingh-dev
navneetsingh-dev marked this pull request as ready for review June 26, 2026 17:55
@RankoR
RankoR requested review from RankoR and m4pl and removed request for m4pl June 26, 2026 19:48

@RankoR RankoR left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The normal SMS path already calculates blocked and stores the message with:

seen = read || messageInObservableConversation || blocked

Therefore blocked SMS messages already fail the existing seen = 0 condition. When the query returns no rows, BugleNotifications.createMessageNotification() enters its state == null branch and independently calls playObservableConversationNotificationSound() whenever the conversation is observable.

I reproduced this with the PR installed as the default SMS app:

  • block sender;
  • open the blocked conversation;
  • receive another SMS;
  • database row: seen=1, blocked=1;
  • old and new query predicates both match zero rows;
  • log reports No unseen notifications;
  • there is no active Messaging notification;
  • MediaPlayer / AudioTrack still runs and delivers the notification audio.

The issue also covers secondary profiles, but SmsReceiver.onReceive() directly calls postNewMessageSecondaryUserNotification() before this database query and without checking the sender's blocked state.

Please retain the query filter if desired, but gate the observable-conversation sound and secondary-user notification using the receive-time, per-sender blocked decision. ProcessDownloadedMmsAction should also include blockedSender when setting mms.mSeen.

Regression tests should cover blocked/unblocked SMS while focused and in the background, secondary profiles, manually downloaded MMS, and per-sender blocking in group conversations.

@navneetsingh-dev

Copy link
Copy Markdown
Author

Thanks for the incredibly detailed review and for mapping out the reproduction steps! I clearly see the architectural gap now: while the SQL filter handles the standard notification query, the observable-conversation audio and the secondary-profile broadcast logic are bypassing it.

Here is my plan for the next commit:

1.Retain the current SQL query optimization for standard view consistency.

2.Gate the playObservableConversationNotificationSound in BugleNotifications by checking the sender's blocked status.

3.Gate postNewMessageSecondaryUserNotification in SmsReceiver.onReceive() using the receive-time blocked decision.

4.Update ProcessDownloadedMmsAction so that mms.mSeen accurately includes blockedSender.

I will get to work on these additions and make sure to run the full regression testing matrix (foreground/background, secondary profiles, manual MMS, and group thread blocking) before pushing the updated branch. Thanks again for the guidance!

@navneetsingh-dev

Copy link
Copy Markdown
Author

Thanks for the incredibly detailed review and for mapping out the reproduction steps! I clearly see the architectural gap now: while the SQL filter handles the standard notification query, the observable-conversation audio and the secondary-profile broadcast logic are bypassing it.

I have pushed a new commit that:

1.Retains the current SQL query optimization for standard view consistency.

2,Gates the playObservableConversationNotificationSound in BugleNotifications by checking the sender's blocked status.

3.Gates postNewMessageSecondaryUserNotification in SmsReceiver.onReceive() using the receive-time blocked decision.

4.Updates ProcessDownloadedMmsAction so that mms.mSeen accurately includes blockedSender.

I've run the regression testing on my end and everything is behaving properly. Thanks again for the guidance!

@navneetsingh-dev
navneetsingh-dev requested a review from RankoR July 15, 2026 07:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants