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.
This commit is contained in:
Jorge Martin Espinosa 2026-03-23 18:07:25 +01:00 committed by GitHub
parent 78c9076281
commit 13bbd24df1
7 changed files with 157 additions and 13 deletions

View file

@ -9,11 +9,21 @@
package io.element.android.libraries.pushproviders.api
interface PushHandler {
/**
* Handle a push received from the provider.
*
* @param pushData the data of the push, containing the client secret and the push content.
* @param providerInfo an identifier of the provider that sent the push, for logging and debugging purposes.
* @return `true` if the push was handled successfully and is now enqueued for processing, false otherwise.
*/
suspend fun handle(
pushData: PushData,
providerInfo: String,
)
): Boolean
/**
* Handle an invalid push received from the provider.
*/
suspend fun handleInvalid(
providerInfo: String,
data: String,