-
Notifications
You must be signed in to change notification settings - Fork 318
Fix issues with WorkManager on Android 12 and below #5606
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
Fix issues with WorkManager on Android 12 and below #5606
Conversation
|
@YamatoRyou since I can't reproduce the issue myself, can I ask you to test the debug APK that will be attached to this PR and see if it fixes your issue with workmanager? If it doesn't, please rageshake again and let us know. |
|
📱 Scan the QR code below to install the build (arm64 only) for this PR. |
I just installed the debug APK and tested it. |
|
Sorry @YamatoRyou can I ask you to test again the newly built APK after some changes I made? This should make the 'Fetching notifications...' notification not necessary on your Android OS version, but I want to double check notifications still work as expected after removing it. If you want to test it, you can just tap on the link/scan the QR code again. |
It looks normal. I also tested the incoming call UI and it also works fine. App: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix. Some remarks
...lin/io/element/android/libraries/push/impl/workmanager/SyncNotificationWorkManagerRequest.kt
Outdated
Show resolved
Hide resolved
...c/main/kotlin/io/element/android/libraries/push/impl/workmanager/FetchNotificationsWorker.kt
Outdated
Show resolved
Hide resolved
...io/element/android/libraries/push/impl/workmanager/SyncNotificationWorkManagerRequestTest.kt
Outdated
Show resolved
Hide resolved
...c/main/kotlin/io/element/android/libraries/push/impl/workmanager/FetchNotificationsWorker.kt
Outdated
Show resolved
Hide resolved
…Manager on Android 12 and below This may be a MIUI-only issue as I couldn't reproduce it with several emulators on Android 11, 12 and 13.
6ac271f to
50f2209
Compare
getForegroundInfo implementation to try to fix issues with Work…Instead of using Robolectric with API < 33 (since Pro uses minSdk 33) use a `BuildVersionSdkIntProvider`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, a few thoughts about the added code.
...c/main/kotlin/io/element/android/libraries/push/impl/workmanager/FetchNotificationsWorker.kt
Outdated
Show resolved
Hide resolved
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #5606 +/- ##
========================================
Coverage 81.70% 81.70%
========================================
Files 2390 2390
Lines 64902 64909 +7
Branches 8247 8248 +1
========================================
+ Hits 53025 53033 +8
+ Misses 8821 8820 -1
Partials 3056 3056 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…t it to be dead code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update. I have pushed a cleanup commit. Set to auto merge so we can have it in the next nightly.
| <string name="common_advanced_settings">"Advanced settings"</string> | ||
| <string name="common_an_image">"an image"</string> | ||
| <string name="common_analytics">"Analytics"</string> | ||
| <string name="common_android_notification_sync_notifications_foreground_service_title">"Fetching notifications…"</string> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: I have removed this key from Localazy as the string is not used now.
|





Content
setExpeditedvalue for Android 12 and lower, since it's not needed.getForegroundInfoin case some OS behaves unexpectedly and still forces us to display the foreground service notification to run the worker.Motivation and context
Fix an issue reported in the Element X Android public room, where the WorkManager crashed because the
setExpeditedoption used in the worker request would force the app to display a notification we weren't ready for.Tests
On Android <= 12, enabled the 'sync notifications using workmanager' feature and receive a couple of notifications.
Notifications should arrive normally.
Tested devices
Checklist