octoshrimpy / quik

The most beautiful SMS messenger for Android - Revived
GNU General Public License v3.0
563 stars 26 forks source link

:lady_beetle: [BUG] Per-contact notifications don't work #96

Open 1472583610 opened 5 months ago

1472583610 commented 5 months ago

Describe the bug Setting custom notification sound for a contact changes the sound for all contacts, even the default notification sound.

To Reproduce Change the notification sound of a specific contact. Tap a contact to show their messages, three dots -> Notifications -> Notifications -> Sound -> choose a custom sound.

OR

Android Settings -> Notifications & Control center -> App Notifications -> QUIK -> scroll down to Notification Categories -> choose a contact -> Sound -> choose a custom sound.

Expected behavior Notification sound is changed for that contact only.

Smartphone (please complete the following information):

Additional context Notification sound is changed for all notification channels, including Default.

1472583610 commented 5 months ago

As this is a fairly important feature to me, I poked around a little bit and found the following:

When dumping notification info from ADB, the lines for Quik read similar to this:

NotificationChannel{mId='notifications_153', mName=And..., mDescription=, mImportance=4, mBypassDnd=false, mLockscreenVisibility=-1000, mSound=content://settings/system/sms_received_sound, mLights=true, mLightColor=-1, mVibration=[0, 200, 0, 200], mUserLockedFields=24, mFgServiceShown=false, mVibrationEnabled=true, mShowBadge=true, mDeleted=false, mDeletedTimeMs=-1, mGroup='null', mAudioAttributes=AudioAttributes: usage=USAGE_NOTIFICATION content=CONTENT_TYPE_SPEECH flags=0x800 tags= bundle=null, mBlockableSystem=false, mAllowBubbles=-1, mImportanceLockedDefaultApp=false, mOriginalImp=4, mParent=null, mConversationId=null, mDemoted=false, mImportantConvo=false}

Interesting is to note the mSound parameter. When I set a custom sound for another app, the mSound is modified with the path to the sound selected. When I change the notification channel sound in Quik, it is changed (for that channel and all others), but the mSound parameter remains exactly as listed above.

It feels like changing the notification channel sound changes the default "sms_received_sound" instead of the particular channel's sound. I wanted to confirm this by sounding the same kind of notification in another app, but in all of the ADB dump, I only found a single app that has the mSound parameter set to sms_received_sound - com.android.mms.

All other apps with their default notifications list mSound as content://settings/system/notification_sound.

Could this be the issue?

EDIT: Confirmed, according to "adb shell settings list system", when I change a notification for a contact, it changes the value of the "sms_received_sound" setting. It may not be the only issue, but it would appear that the Quik notification builder should use the "notification_sound" setting as the source of the default sound for a channel instead of "sms_received_sound".

1472583610 commented 4 months ago

A quick (no pun intended) update:

I just tried Fossify Messages (a fork of the former Simple SMS Messenger) and it has the exact same issue as Quik. Even ADB dump has the same mSound parameter. I can also confirm that the notification system of Tasks.org works as expected.

1472583610 commented 4 months ago

After some more fiddling around, running Quik through Android Studio and loading it onto my phone, I found the following:

What I tried: Create a notification channel for a specific contact via code and manually set the path to the notification sound.

What was the result: The notification channel was created successfully, with the notification sound set via the SetSound method showing. Dumpsys from ADB shows the mSound parameter as "file:///storage/emulated/0/Download/simply_best_beep_033212.mp3. When the notification is to be used, it plays the correct sound. Success, then.

What remains: If I try to change the notification sound from the Android UI, the mSound gets set back to sms_received_sound for that particular notification channel. Other channels are unaffected, until I try to change their sound as well. When I do, their mSound is set to sms_received_sound as well and then any change of sound of either of these channels sets the sound for the other. This is consistent with the fact that the sound change changes the sms_received_sound as well.

Why this happens, though, I have no idea. I'd blame Android, or the Xiaomi.eu version of it, but for some reason notification channels work as expected for Tasks.org. So I can still blame Android, but at the very least it would appear that there is a way to make it work properly.