Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update notifications rules: make a sound for each notification #5796

Merged
merged 5 commits into from
May 5, 2022

Conversation

Claire1817
Copy link
Contributor

Type of change

  • Feature
  • Bugfix
  • Technical
  • Other :

Content

#4632
Align notification experience to web / ios client.
Notify with noise for each notification.

Motivation and context

Screenshots / GIFs

Tests

  • Step 1
  • Step 2
  • Step ...

Tested devices

  • Physical
  • Emulator
  • OS version(s):

Checklist

@Claire1817 Claire1817 marked this pull request as draft April 20, 2022 12:34
@github-actions
Copy link

github-actions bot commented Apr 20, 2022

Unit Test Results

122 files  +  8  122 suites  +8   2m 3s ⏱️ +44s
205 tests +  3  205 ✔️ +  3  0 💤 ±0  0 ±0 
690 runs  +12  690 ✔️ +12  0 💤 ±0  0 ±0 

Results for commit f188eb6. ± Comparison against base commit 7c7822a.

This pull request removes 9 and adds 12 tests. Note that renamed tests count towards both.
org.matrix.android.sdk.api.pushrules.PushRuleActionsTest ‑ test_action_parsing
org.matrix.android.sdk.api.pushrules.PushRulesConditionTest ‑ test_displayName_condition
org.matrix.android.sdk.api.pushrules.PushRulesConditionTest ‑ test_eventmatch_cake_condition
org.matrix.android.sdk.api.pushrules.PushRulesConditionTest ‑ test_eventmatch_cakelie_condition
org.matrix.android.sdk.api.pushrules.PushRulesConditionTest ‑ test_eventmatch_path_condition
org.matrix.android.sdk.api.pushrules.PushRulesConditionTest ‑ test_eventmatch_type_condition
org.matrix.android.sdk.api.pushrules.PushRulesConditionTest ‑ test_eventmatch_words_only_condition
org.matrix.android.sdk.api.pushrules.PushRulesConditionTest ‑ test_notice_condition
org.matrix.android.sdk.api.pushrules.PushRulesConditionTest ‑ test_roommember_condition
im.vector.app.features.crypto.UISIDetectorTest ‑ If event decrypted during grace period should not trigger detection
im.vector.app.features.crypto.UISIDetectorTest ‑ trigger detection after grace period
im.vector.app.features.onboarding.ftueauth.FtueMissingRegistrationStagesComparatorTest ‑ when ordering stages, then prioritizes email
org.matrix.android.sdk.api.session.pushrules.PushRuleActionsTest ‑ test_action_parsing
org.matrix.android.sdk.api.session.pushrules.PushRulesConditionTest ‑ test_displayName_condition
org.matrix.android.sdk.api.session.pushrules.PushRulesConditionTest ‑ test_eventmatch_cake_condition
org.matrix.android.sdk.api.session.pushrules.PushRulesConditionTest ‑ test_eventmatch_cakelie_condition
org.matrix.android.sdk.api.session.pushrules.PushRulesConditionTest ‑ test_eventmatch_path_condition
org.matrix.android.sdk.api.session.pushrules.PushRulesConditionTest ‑ test_eventmatch_type_condition
org.matrix.android.sdk.api.session.pushrules.PushRulesConditionTest ‑ test_eventmatch_words_only_condition
…

♻️ This comment has been updated with latest results.

@ouchadam
Copy link
Contributor

ouchadam commented Apr 20, 2022

some things to look out for when making changes to this area

Hopefully the combination of all fixes in this area might have solved these without setAlertOnce() 🤞

@ouchadam
Copy link
Contributor

for #1673 - tested locally on a mi band 5 and can confirm there's no regression

however #4152 returns, a way to test this locally is to apply a delay to https://github.com/vector-im/element-android/blob/develop/vector/src/gplay/java/im/vector/app/gplay/push/fcm/VectorFirebaseMessagingService.kt#L174

coroutineScope.launch {
    delay(5000)
    session.requireBackgroundSync()
}

to avoid double notifications we'll need to further refine the notifications to dynamically enable alertOnce if the notification is new or an update

@Claire1817
Copy link
Contributor Author

@ouchadam I had tested the #4152 by adding the "delay" and i didn't reproduce the bug.

@Claire1817 Claire1817 marked this pull request as ready for review May 2, 2022 09:52
@Claire1817 Claire1817 requested review from a team and mnaturel and removed request for a team May 2, 2022 09:52
Copy link
Contributor

@mnaturel mnaturel left a comment

Choose a reason for hiding this comment

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

After some tests with an emulator Pixel 3a Android 12, I frequently have 2 notification sounds per message. I don't know how notifications work on the project but it may be worth to check/add logs when notify() is called on the NotificationManager for a single message.

@Claire1817
Copy link
Contributor Author

@mnaturel I didn't reproduce your bug with an emulator.
I had tested with long and short messages, good and bad network.
Can you test it on device ?

@mnaturel
Copy link
Contributor

mnaturel commented May 4, 2022

@mnaturel I didn't reproduce your bug with an emulator. I had tested with long and short messages, good and bad network. Can you test it on device ?

After some tests on real device (Nokia 7.2, Android 11) I could not reproduce the double notification bug. I suspect it may happen sometimes on very high connectivity.

@mnaturel mnaturel self-requested a review May 4, 2022 08:30
@ouchadam
Copy link
Contributor

ouchadam commented May 4, 2022

To clarify the double the notification, the notification UI is correct but two pings will be triggered for each message that goes through the fastlane flow (push from server -> fetch message directly -> notify message -> request sync -> sync finds new messages and notifies again) https://github.com/vector-im/element-android/blob/develop/vector/src/gplay/java/im/vector/app/gplay/push/fcm/VectorFirebaseMessagingService.kt#L174

The double ping will only happen if the sync triggered by the push returns after the getEvent/fastlane , otherwise the event is ignored. The fastlane flow is only entered when on wifi and we're not currently viewing the room the message is part of https://github.com/vector-im/element-android/blob/develop/vector/src/gplay/java/im/vector/app/gplay/push/fcm/VectorFirebaseMessagingService.kt#L187

@Claire1817
Copy link
Contributor Author

Claire1817 commented May 4, 2022

Thanks @ouchadam for your explanation, it's more clear now.
Should we do a verification to activate or not the setOnlyAlertOnce ? to avoid the double ping.
Should we check if we get a notification coming from the sync ? In which case do we have to display notification coming from the sync ?
Should we only display the notifications coming from getEvent/fastlane ?
Is it possible to know if a notification is already shown ?
I don't know what is the best solution :/.

@ouchadam
Copy link
Contributor

ouchadam commented May 4, 2022

ultimately my gut feeling is that we'll need to dynamicly apply the setOnlyAlertOnce based on new content or updates/edits, I'm thinking we could check if the latest room message event is an update, and if so use setOnlyAlertOnce(true) to avoid the double ping

there's a few changes needed to enable this

@ouchadam
Copy link
Contributor

ouchadam commented May 5, 2022

thanks for the update, can confirm it's working for me locally 💯

@@ -0,0 +1 @@
Use the same notification rules than web / iOs client
Copy link
Contributor

Choose a reason for hiding this comment

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

is it worth calling out that the change will mean we will notify for all (new) messages?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes we can, i update the message

@Claire1817 Claire1817 merged commit c9bd1f3 into develop May 5, 2022
@Claire1817 Claire1817 deleted the cgizard/ISSUE-4632 branch May 5, 2022 12:02
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.

3 participants