Cleanup FetchPushForegroundService (#6577)

* Rename `PushHandlingWakeLock` to `FetchPushForegroundServiceManager`. Move the start/stop logic from `FetchPushForegroundService.Companion` to it.

* Add more tests using Robolectric.

* Remove `FeatureFlags.SyncNotificationsWithWorkManager` and associated code: this should have been removed in one of the previous refactors, since we don't have the 2 ways to sync notifications anymore, everything uses the `WorkManager`

---------

Co-authored-by: Benoit Marty <benoit@matrix.org>
This commit is contained in:
Jorge Martin Espinosa 2026-04-20 16:03:12 +02:00 committed by GitHub
parent 8853f160e2
commit f80a140cf9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 329 additions and 215 deletions

View file

@ -0,0 +1,23 @@
/*
* Copyright (c) 2026 Element Creations Ltd.
*
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
* Please see LICENSE files in the repository root for full details.
*/
package io.element.android.libraries.push.test.push
import io.element.android.libraries.push.api.push.FetchPushForegroundServiceManager
class FakeFetchPushForegroundServiceManager(
private val lock: () -> Boolean = { true },
private val unlock: () -> Boolean = { true },
) : FetchPushForegroundServiceManager {
override fun start(): Boolean {
return lock.invoke()
}
override suspend fun stop(): Boolean {
return unlock.invoke()
}
}

View file

@ -1,24 +0,0 @@
/*
* Copyright (c) 2026 Element Creations Ltd.
*
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
* Please see LICENSE files in the repository root for full details.
*/
package io.element.android.libraries.push.test.push
import io.element.android.libraries.push.api.push.PushHandlingWakeLock
import kotlin.time.Duration
class FakePushHandlingWakeLock(
private val lock: (time: Duration) -> Unit = {},
private val unlock: () -> Unit = {},
) : PushHandlingWakeLock {
override fun lock(time: Duration) {
lock.invoke(time)
}
override suspend fun unlock() {
unlock.invoke()
}
}