Skip to content
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
9d4f747
Upgrade UnifiedPush Connector to 3.0.4
ArnyminerZ Feb 25, 2025
bd1f2ae
Updated overrides
ArnyminerZ Feb 25, 2025
24a31a3
Added storing keys and auths
ArnyminerZ Feb 25, 2025
bab9463
Excluded tink
ArnyminerZ Feb 25, 2025
f961096
Fixed deprecations and calls
ArnyminerZ Feb 25, 2025
19f3a4a
Merge branch 'main-ose' into 1245-push-support-unifiedpush-connector-3x
ArnyminerZ Mar 7, 2025
15a33a0
Merge branch 'main-ose' into 1245-push-support-unifiedpush-connector-3x
rfc2822 Apr 13, 2025
07b1eea
Integrate UnifiedPush 3.x connector and FCM distributor
rfc2822 Apr 13, 2025
c6a4de7
Integrate UnifiedPush connector 3.x, use VAPID and message encryption
rfc2822 Apr 13, 2025
3ebf030
Merge branch 'main-ose' into 1245-push-support-unifiedpush-connector-3x
rfc2822 Apr 15, 2025
2adea34
[WIP] Refactor push registration logic and remove deprecated methods
rfc2822 Apr 15, 2025
1dadfda
[WIP] Remove PushRegistrationWorkerManager and refactor PushRegistrat…
rfc2822 Apr 16, 2025
d93ed99
Remove unused service repository dependency and update worker to suspend
rfc2822 Apr 18, 2025
93e1c19
Merge branch 'main-ose' into 1245-push-support-unifiedpush-connector-3x
rfc2822 Apr 20, 2025
4865c9b
Add suspend modifier to DAO methods and repository methods
rfc2822 Apr 20, 2025
fe665f6
Add runBlocking to getByService call in CollectionListRefresherTest
rfc2822 Apr 21, 2025
8d440bb
Add documentation for UnifiedPushService and PushRegistrationManager
rfc2822 Apr 21, 2025
78a9680
Add fallback for push messages without topic
rfc2822 Apr 21, 2025
57c64bf
[WIP] Add UnifiedPushService test with workaround for PushService binder
rfc2822 Apr 22, 2025
eaeb767
Merge branch 'main-ose' into 1245-push-support-unifiedpush-connector-3x
rfc2822 Apr 23, 2025
5b68505
Update UnifiedPush library version and clean up test code
rfc2822 Apr 23, 2025
d1945d7
Refactor push message handling, synchronization and coroutines
rfc2822 Apr 23, 2025
5f801a0
Add coroutine dispatchers for push registration and unregistration
rfc2822 Apr 23, 2025
5b3df43
Merge remote-tracking branch 'origin/1245-push-support-unifiedpush-co…
rfc2822 Apr 23, 2025
07c0fef
Merge branch 'main-ose' into 1245-push-support-unifiedpush-connector-3x
rfc2822 Apr 24, 2025
6ebe97c
Add async support for push subscription updates
rfc2822 Apr 24, 2025
88512ce
Refactor unsubscribe logic into reusable method
rfc2822 Apr 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,13 @@ dependencies {
implementation(libs.okhttp.brotli)
implementation(libs.okhttp.logging)
implementation(libs.openid.appauth)
implementation(libs.unifiedpush)
implementation(libs.unifiedpush) {
// UnifiedPush connector seems to be using a workaround by importing this library.
// Will be removed after https://github.com/tink-crypto/tink-java-apps/pull/5 is merged.
// See: https://codeberg.org/UnifiedPush/android-connector/src/commit/28cb0d622ed0a972996041ab9cc85b701abc48c6/connector/build.gradle#L56-L59
exclude(group = "com.google.crypto.tink", module = "tink")
}
implementation(libs.unifiedpush.fcm)

// force some versions for compatibility with our minSdk level (see version catalog for details)
implementation(libs.commons.codec)
Expand Down
14 changes: 0 additions & 14 deletions app/src/androidTest/kotlin/at/bitfire/davdroid/TestModules.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,13 @@

package at.bitfire.davdroid

import at.bitfire.davdroid.push.PushRegistrationWorkerManager
import at.bitfire.davdroid.repository.DavCollectionRepository
import at.bitfire.davdroid.startup.StartupPlugin
import at.bitfire.davdroid.startup.TasksAppWatcher
import dagger.Module
import dagger.hilt.components.SingletonComponent
import dagger.hilt.testing.TestInstallIn
import dagger.multibindings.Multibinds

// remove PushRegistrationWorkerModule from Android tests
@Module
@TestInstallIn(
components = [SingletonComponent::class],
replaces = [PushRegistrationWorkerManager.PushRegistrationWorkerModule::class]
)
abstract class TestPushRegistrationWorkerModule {
// provides empty set of listeners
@Multibinds
abstract fun empty(): Set<DavCollectionRepository.OnChangeListener>
}

// remove TasksAppWatcherModule from Android tests
@Module
@TestInstallIn(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import dagger.hilt.android.testing.HiltAndroidTest
import io.mockk.every
import io.mockk.impl.annotations.MockK
import io.mockk.junit4.MockKRule
import kotlinx.coroutines.runBlocking
import okhttp3.mockwebserver.Dispatcher
import okhttp3.mockwebserver.MockResponse
import okhttp3.mockwebserver.MockWebServer
Expand Down Expand Up @@ -142,7 +143,7 @@ class CollectionListRefresherTest {
displayName = "My Contacts",
description = "My Contacts Description"
),
db.collectionDao().getByService(service.id).first()
runBlocking { db.collectionDao().getByService(service.id).first() }
)
}

Expand Down
11 changes: 4 additions & 7 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -268,15 +268,12 @@
android:resource="@xml/debug_paths" />
</provider>

<!-- UnifiedPush receiver -->
<receiver android:exported="true" android:enabled="true" android:name=".push.UnifiedPushReceiver" tools:ignore="ExportedReceiver">
<!-- UnifiedPush -->
<service android:exported="false" android:name=".push.UnifiedPushService">
<intent-filter>
<action android:name="org.unifiedpush.android.connector.MESSAGE"/>
<action android:name="org.unifiedpush.android.connector.UNREGISTERED"/>
<action android:name="org.unifiedpush.android.connector.NEW_ENDPOINT"/>
<action android:name="org.unifiedpush.android.connector.REGISTRATION_FAILED"/>
<action android:name="org.unifiedpush.android.connector.PUSH_EVENT"/>
</intent-filter>
</receiver>
</service>

<!-- Widgets -->
<receiver android:name=".ui.widget.SyncButtonWidgetReceiver"
Expand Down
18 changes: 12 additions & 6 deletions app/src/main/kotlin/at/bitfire/davdroid/db/CollectionDao.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ interface CollectionDao {
fun getFlow(id: Long): Flow<Collection?>

@Query("SELECT * FROM collection WHERE serviceId=:serviceId")
fun getByService(serviceId: Long): List<Collection>
suspend fun getByService(serviceId: Long): List<Collection>

@Query("SELECT * FROM collection WHERE serviceId=:serviceId AND homeSetId IS :homeSetId")
fun getByServiceAndHomeset(serviceId: Long, homeSetId: Long?): List<Collection>
Expand All @@ -35,6 +35,9 @@ interface CollectionDao {
@Query("SELECT * FROM collection WHERE pushTopic=:topic AND sync")
fun getSyncableByPushTopic(topic: String): Collection?

@Query("SELECT pushVapidKey FROM collection WHERE serviceId=:serviceId AND pushVapidKey IS NOT NULL LIMIT 1")
suspend fun getFirstVapidKey(serviceId: Long): String?

@Query("SELECT COUNT(*) FROM collection WHERE serviceId=:serviceId AND type=:type")
suspend fun anyOfType(serviceId: Long, @CollectionType type: String): Boolean

Expand Down Expand Up @@ -72,11 +75,14 @@ interface CollectionDao {
* Get a list of collections that are both sync enabled and push capable (supportsWebPush and
* pushTopic is available).
*/
@Query("SELECT * FROM collection WHERE sync AND supportsWebPush AND pushTopic IS NOT NULL")
suspend fun getPushCapableSyncCollections(): List<Collection>
@Query("SELECT * FROM collection WHERE serviceId=:serviceId AND sync AND supportsWebPush AND pushTopic IS NOT NULL")
suspend fun getPushCapableSyncCollections(serviceId: Long): List<Collection>

@Query("SELECT * FROM collection WHERE serviceId=:serviceId AND pushSubscription IS NOT NULL")
suspend fun getPushRegistered(serviceId: Long): List<Collection>

@Query("SELECT * FROM collection WHERE pushSubscription IS NOT NULL AND NOT sync")
suspend fun getPushRegisteredAndNotSyncable(): List<Collection>
@Query("SELECT * FROM collection WHERE serviceId=:serviceId AND pushSubscription IS NOT NULL AND NOT sync")
suspend fun getPushRegisteredAndNotSyncable(serviceId: Long): List<Collection>

@Insert(onConflict = OnConflictStrategy.IGNORE)
fun insert(collection: Collection): Long
Expand Down Expand Up @@ -116,4 +122,4 @@ interface CollectionDao {
@Delete
fun delete(collection: Collection)

}
}
3 changes: 3 additions & 0 deletions app/src/main/kotlin/at/bitfire/davdroid/db/ServiceDao.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ interface ServiceDao {
@Query("SELECT * FROM service WHERE id=:id")
fun get(id: Long): Service?

@Query("SELECT * FROM service")
suspend fun getAll(): List<Service>

@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insertOrReplace(service: Service): Long

Expand Down
Loading
Loading