Commit Graph

680 Commits

Author SHA1 Message Date
Jorge Martin Espinosa
15dc582279 Tentative fix for ForegroundServiceStartNotAllowedException (#6509)
* Tentative fix for `ForegroundServiceStartNotAllowedException`

When failing to start the service in foreground, don't crash. This is a helper to speed up the scheduling by keeping the CPU awake, not a critical part that should succeed

* Simplify `DefaultPushHandlingWakeLock`

It seems like restarting the service from background won't work in some cases, so don't try it.
2026-04-02 11:10:47 +02:00
Jorge Martin Espinosa
4725148919 Try handling ForegroundServiceStartNotAllowedException better (#6483)
* Try handling `ForegroundServiceStartNotAllowedException` better

The docs mention starting a foreground service when the app is on background is allowed when FCM receives a high priority notification, so we don't do it if the priority is not high.

Also, we handle the case where starting the foreground service fails so it doesn't crash the app.
2026-03-30 18:44:08 +02:00
Jorge Martin Espinosa
8239a5ba0a Fix ForegroundServiceDidNotStartInTimeException (#6470)
* Start the `FetchPushForegroundService ` in foreground ASAP. This is a first step to mitigate `ForegroundServiceDidNotStartInTimeException` being thrown.

* Don't stop the service immediately if it's running but not in foreground. Try waiting up to 5s for it to be in foreground.
2026-03-27 06:54:27 +00:00
ganfra
f9f09b12f8 Merge branch 'develop' into feature/fga/live_location_sharing_setup 2026-03-24 10:17:24 +01:00
Jorge Martin Espinosa
13bbd24df1 Fix wakelock not stopping early when notifications are disabled (#6424)
If notifications for a device are disabled when there is no connection with the HS, the push registration will still exist, so the device can still receive push notifications.

In that cases, we were running into an issue where the wakelock for push notifications was started immediately after receiving a push but was never stopped and it ran for 3 minutes until its timeout, keeping the device awake for no reason.

This patch changes `DefaultPushHandler` so if we don't need the wakelock it returns `false` and we can stop the wakelock early.
2026-03-23 18:07:25 +01:00
Jorge Martin Espinosa
96e2f882a2 Add a foreground service with a wakelock for fetching push notifications (#6321)
* Create `PushHandlingWakeLock` to start a foreground service:

When receiving a push and scheduling the notification fetching, several problems can happen:

1. Some async operation is waiting for a timeout and it takes way longer than that to finish (i.e. timeout of 10s but it took 30s to advance).
2. The same, but when starting new coroutines. I've seen the time between scheduling a coroutine and it running sometimes take up to 1 minute.
3. Notification fetching can be scheduled immediately, but it can take a while to actually run because the OS understands the app is now in Doze.

Having a wakelock that runs as soon as the push handling starts fixes these: it continues the previous wakelock held by either Firebase or the UnifiedPush distributor.

* Acquire the wakelock as soon as we received the pushes in both receivers

* Also release the wakelock ahead of time if possible
2026-03-17 14:24:26 +01:00
Benoit Marty
993250f1ea Merge pull request #6352 from element-hq/sync-localazy
Sync Strings - iterate on wording about crypto identity
2026-03-16 16:06:54 +01:00
Benoit Marty
0fbed400eb Sync string again. 2026-03-16 14:54:06 +01:00
renovate[bot]
7cdf1a264b fix(deps): update activity to v1.13.0 (#6327)
* fix(deps): update activity to v1.13.0

* Remove usages of deprecated  `bundleOf`

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Jorge Martín <jorgem@element.io>
2026-03-16 08:50:43 +00:00
bmarty
3a0e01b63d Sync Strings from Localazy 2026-03-16 00:42:32 +00:00
ganfra
7c6a5638ad Fix some existing tests after changes 2026-03-13 10:18:28 +01:00
Jorge Martin Espinosa
f77098ed47 Add network constraints for fetching notifications with WorkManager (#6305)
* Add `isNetworkBlocked` and `isInAirGappedEnvironment` to `NetworkMonitor`.

* Improve the DI of `SyncPendingNotificationsRequestBuilder` to simplify its usage.

* Only update `isInAirGappedEnvironment` in `DefaultNetworkManager` if the current build is an enterprise one.

* Add network constraints to `DefaultSyncPendingNotificationsRequestBuilder` based on the air-gapped status.

* Add a feature flag to disable the new check, in case it doesn't work as expected.
2026-03-10 12:44:31 +00:00
Valere Fedronic
477c482810 Merge branch 'develop' into valere/rtc/voice_call 2026-03-09 17:18:55 +01:00
ElementBot
2ad55f4bc6 Sync Strings (#6302)
Co-authored-by: bmarty <3940906+bmarty@users.noreply.github.com>
2026-03-09 10:38:07 +01:00
Valere
b26728309a fix tests 2026-03-04 19:07:53 +01:00
Valere
04a9c677fb Merge branch 'develop' into valere/rtc/voice_call 2026-03-04 13:46:54 +01:00
Valere
d37e32834b rename voiceIntent to isAudioCall 2026-03-04 11:10:40 +01:00
Valere
a3dd2c78b3 Support incoming audio only calls 2026-03-04 08:56:33 +01:00
Jorge Martin Espinosa
721add707c Simplify push notification flow by using locally stored values for pending pushes (#6258)
* Create `PushRequest` in push history DB: this will be used to store requests for push notifications, either pending or completed ones.

* Rename `WorkManagerRequest` to `WorkManagerRequestBuilder`: make its `build` method return a list of `WorkManagerRequestWrapper`, which can be used to enqueue normal or unique workers.

* Rename `PerformDatabaseVacuumRequestBuilder` and adapt it to the new API.

* Adjust other components using `WorkManagerRequest`.

* Replace `SyncNotificationWorkManagerRequestBuilder` with `SyncPendingNotificationsRequestBuilder` and `FetchNotificationsWorker` with `FetchPendingNotificationsWorker`: this new pair of request builder and worker allow enqueuing requests for a session id and, once the worker runs, retrieve all the pending request data and use it to fetch the associated events. This simplifies quite a bit how this data had to be passed or grouped, since it's no longer necessary to do so

* Add new methods to `PushHistoryService` to modify the `PushDatabase`:

- insertOrUpdatePushRequest
- insertOrUpdatePushRequests
- getPendingPushRequests
- removeOldPushRequests

* Make `PushHandler` just handle incoming pushes: those will be inserted into the pending push request table in DB, then handled by the new worker. Once the process finished, a new `NotificationResultProcessor` will handle the results and what needs to be done with them (call ringing, displaying notifications, etc.)

* Add `requestType` optional parameter to `WorkManagerScheduler.cancel` so we can decide to only cancel some kinds of requests.

* Add migration to remove existing work manager requests for fetching notifications, since the previous worker class no longer exists.
2026-03-03 15:14:36 +00:00
renovate[bot]
7c97ec1155 Update metro to v0.11.2 (#6270)
* Update metro to v0.11.2

* Bind push tests to the right scope .Add a comment so we don't forget to do it for future ones.

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Jorge Martín <jorgem@element.io>
2026-03-03 13:39:43 +01:00
Benoit Marty
1f69958dab Merge pull request #6035 from element-hq/fix/remove-fragment-part-in-mxc-urls
Add `MediaSource.safeUrl` for removing invalid fragment part from URLs
2026-03-03 11:57:49 +01:00
Valere
ec420332c3 WIP: Support using Element Call for voice calls in DMs 2026-03-03 11:50:22 +01:00
Benoit Marty
66c3bf267a Merge pull request #6241 from element-hq/feature/bma/fixRedactedNotification
Ensure that redacted event from encrypted room does not trigger a fallback notification
2026-03-03 11:43:45 +01:00
ElementBot
5bcaad1e81 Sync Strings from Localazy (#6269)
Co-authored-by: bmarty <3940906+bmarty@users.noreply.github.com>
2026-03-02 14:54:50 +01:00
Benoit Marty
b3b22033aa Handle EventRedacted case. Fixes #5569 2026-03-02 09:15:53 +01:00
Jorge Martín
cdd850d4dd Apply suggestion:
- Added `MediaSource.safeUrl` property replacing `withCleanUrl` method.
- Made `url` private so it can't be used externally.
- Reverted code in `CoilMediaFetcher`
- Also add tests
2026-02-27 09:52:17 +01:00
renovate[bot]
89a6f5a7bf Update metro to v0.11.0 (#6245)
* Update metro to v0.11.0

* Fix `@AssistedInject` usages

Now the injected variables in the factories must match the names in the constructors

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Jorge Martín <jorgem@element.io>
2026-02-25 16:19:47 +01:00
Jorge Martin Espinosa
fe4554703c Check if network access if blocked when fetching notifications (#6247)
* Add `NetworkMonitor.isNetworkBlocked()`, use it to check if Doze prevented us from loading notifications

* Only check if network is blocked after checking if we have a network available, otherwise it's always `true`

* Extract `NetworkBlockedChecker` to handle deprecations more carefully
2026-02-25 12:04:07 +00:00
Jorge Martin Espinosa
2f80b101c5 Add extra analytics for notification performance (#6237)
* Add extra analytics for notification performance

Add technical spans to track how long a notification fetching work request takes to run, then how long it takes to actually fetch the events for the notifications

* Remove `withContext(io)` for `FetchNotificationsWorker`

The default `Dispatchers.Default` dispatcher used should be good enough and more performant

* Add network check span
2026-02-24 13:39:32 +01:00
bmarty
6c81e88689 Sync Strings from Localazy 2026-02-23 00:39:49 +00:00
Benoit Marty
d2ca80e7e8 Fix compilation issue after merging develop. 2026-02-13 16:44:42 +01:00
Benoit Marty
c1f3233dce Merge branch 'develop' into feature/bma/notificationCustomSound 2026-02-13 15:48:19 +01:00
Benoit Marty
0233f4dde4 Add name parameters 2026-02-12 17:57:52 +01:00
Benoit Marty
88a104a6d4 Swap receiver and parameter for a nicer code. 2026-02-12 17:57:31 +01:00
Benoit Marty
130ff40e5c Fix typo 2026-02-12 14:42:58 +01:00
Benoit Marty
48fae51ef0 Ignore fallback notification when the room list is rendered.
Add more tests.
2026-02-12 13:30:46 +01:00
Benoit Marty
a651a1cd6f Improve FakeAppNavigationStateService 2026-02-12 13:30:06 +01:00
Benoit Marty
00fb4498f4 Dismiss fallback notification when the room list is rendered. 2026-02-12 13:26:53 +01:00
Benoit Marty
b9d5645853 Remove NavigationState.Space. (#6185)
* Remove `NavigationState.Space`.
We do not have the concept of current space.

* Fix test.
2026-02-12 13:24:51 +01:00
Benoit Marty
ff4455b0ce Fix test. 2026-02-12 09:12:17 +01:00
Benoit Marty
44cab62fc3 Merge branch 'develop' into feature/bma/notificationFallbackCounter 2026-02-11 21:10:14 +01:00
Benoit Marty
9fbb21fb39 Add missing test 2026-02-11 21:06:19 +01:00
Benoit Marty
843e1a28b2 Cleanup 2026-02-11 20:51:05 +01:00
Benoit Marty
83fee6d9ba Remove NavigationState.Space.
We do not have the concept of current space.
2026-02-11 20:41:55 +01:00
Benoit Marty
e3ace3c87e Rely on the SessionObserver to detect a sign out. 2026-02-11 18:06:32 +01:00
Benoit Marty
4234600d06 Notification: implement a counter in the fallback notification. 2026-02-11 16:43:03 +01:00
Benoit Marty
71fef289d1 Cleanup: remove unused summaryLine field. 2026-02-11 15:36:12 +01:00
Benoit Marty
6e958f3132 Let enterprise build be able to use a different notification channel for noisy notification. 2026-02-11 11:57:01 +01:00
Benoit Marty
7535258bae Remove file sound (it is the same file than the file in the main scope). 2026-02-10 18:13:09 +01:00
Benoit Marty
21595b2155 Format file. 2026-02-10 17:40:20 +01:00