From dae308fcf74e878bf23e5e81fa333308c6fc3459 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 8 Apr 2026 11:15:51 +0200 Subject: [PATCH] Fix crash, ensure that `super.onTimeout(startId)` is not called when the method is not available. --- .../libraries/push/impl/push/FetchPushForegroundService.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/push/FetchPushForegroundService.kt b/libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/push/FetchPushForegroundService.kt index da5dc80707..d54b7f5497 100644 --- a/libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/push/FetchPushForegroundService.kt +++ b/libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/push/FetchPushForegroundService.kt @@ -106,7 +106,7 @@ class FetchPushForegroundService : Service() { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.VANILLA_ICE_CREAM) { coroutineScope.launch { delay(wakelockTimeout) - onTimeout(startId) + onTimeoutAction(calledByTheSystem = false) } } @@ -124,7 +124,11 @@ class FetchPushForegroundService : Service() { override fun onTimeout(startId: Int) { super.onTimeout(startId) + onTimeoutAction(calledByTheSystem = true) + } + private fun onTimeoutAction(calledByTheSystem: Boolean) { + Timber.d("onTimeoutAction, calledByTheSystem: $calledByTheSystem, isOnForeground: $isOnForeground") if (isOnForeground) { Timber.d("Wakelock timeout reached, stopping FetchPushForegroundService") coroutineScope.launch { pushHandlingWakeLock.unlock() }