Skip to content

Conversation

@jmartinesp
Copy link
Member

@jmartinesp jmartinesp commented Oct 24, 2025

Content

  • Remove setExpedited value for Android 12 and lower, since it's not needed.
  • Add getForegroundInfo in 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 setExpedited option 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

  • Physical
  • Emulator
  • OS version(s): 11, 12, 13.

Checklist

  • Changes have been tested on an Android device or Android emulator with API 24
  • UI change has been tested on both light and dark themes
  • Accessibility has been taken into account. See https://github.com/element-hq/element-x-android/blob/develop/CONTRIBUTING.md#accessibility
  • Pull request is based on the develop branch
  • Pull request title will be used in the release note, it clearly define what will change for the user
  • Pull request includes screenshots or videos if containing UI changes
  • You've made a self review of your PR

@jmartinesp
Copy link
Member Author

@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.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 24, 2025

📱 Scan the QR code below to install the build (arm64 only) for this PR.
QR code
If you can't scan the QR code you can install the build via this link: https://i.diawi.com/MK4jA6

@YamatoRyou
Copy link

@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.

I just installed the debug APK and tested it.
On this device, the previously mentioned issue has resolved.
{6335BF90-7F79-6A6E-87BB-D4D89109EBD5}

@jmartinesp
Copy link
Member Author

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.

@YamatoRyou
Copy link

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.
{50095F8B-6CCD-0CDA-C33C-A1B2AE5ED87D}


App: 99cd75b5

Copy link
Member

@bmarty bmarty left a 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

…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.
@jmartinesp jmartinesp force-pushed the fix/workmanager-expedited-on-android-12-below branch from 6ac271f to 50f2209 Compare October 27, 2025 10:32
@jmartinesp jmartinesp changed the title Add getForegroundInfo implementation to try to fix issues with Work… Fix issues with WorkManager on Android 12 and below Oct 27, 2025
@jmartinesp jmartinesp added the PR-Bugfix For bug fix label Oct 27, 2025
@jmartinesp jmartinesp marked this pull request as ready for review October 27, 2025 10:37
@jmartinesp jmartinesp requested a review from a team as a code owner October 27, 2025 10:37
@jmartinesp jmartinesp requested review from bmarty and removed request for a team October 27, 2025 10:37
Instead of using Robolectric with API < 33 (since Pro uses minSdk 33) use a `BuildVersionSdkIntProvider`
Copy link
Member

@bmarty bmarty left a 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.

@codecov
Copy link

codecov bot commented Oct 27, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.70%. Comparing base (9baf948) to head (44125e3).
⚠️ Report is 17 commits behind head on develop.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@bmarty bmarty added the Z-NextRelease For issues and PRs which should be included in the NextRelease. label Oct 28, 2025
@jmartinesp jmartinesp requested a review from bmarty October 28, 2025 12:35
Copy link
Member

@bmarty bmarty left a 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>
Copy link
Member

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.

@bmarty bmarty enabled auto-merge (squash) October 28, 2025 19:35
@sonarqubecloud
Copy link

@bmarty bmarty merged commit 84d0338 into develop Oct 28, 2025
31 of 32 checks passed
@bmarty bmarty deleted the fix/workmanager-expedited-on-android-12-below branch October 28, 2025 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR-Bugfix For bug fix Z-NextRelease For issues and PRs which should be included in the NextRelease.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants