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:
parent
78c9076281
commit
13bbd24df1
7 changed files with 157 additions and 13 deletions
|
|
@ -71,11 +71,17 @@ class VectorUnifiedPushMessagingReceiver : MessagingReceiver() {
|
|||
providerInfo = "${UnifiedPushConfig.NAME} - $instance",
|
||||
data = String(message.content),
|
||||
)
|
||||
pushHandlingWakeLock.unlock()
|
||||
} else {
|
||||
pushHandler.handle(
|
||||
val handled = pushHandler.handle(
|
||||
pushData = pushData,
|
||||
providerInfo = "${UnifiedPushConfig.NAME} - $instance",
|
||||
)
|
||||
|
||||
// If we failed to handle the push, we should release the wakelock early to avoid keeping the device awake for too long.
|
||||
if (!handled) {
|
||||
pushHandlingWakeLock.unlock()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue