Skip to content

Commit 65b5df2

Browse files
authored
Retry sync on DeadObjectException (#503)
* Retry on DeadObjectException * Update ical4android
1 parent afd03d8 commit 65b5df2

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

app/src/main/java/at/bitfire/icsdroid/BaseSyncWorker.kt

+14-9
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package at.bitfire.icsdroid
33
import android.content.ContentProviderClient
44
import android.content.ContentUris
55
import android.content.Context
6+
import android.os.DeadObjectException
67
import android.util.Log
78
import androidx.work.CoroutineWorker
89
import androidx.work.WorkerParameters
@@ -47,13 +48,12 @@ open class BaseSyncWorker(
4748
val onlyMigrate = inputData.getBoolean(ONLY_MIGRATE, false)
4849
Log.i(Constants.TAG, "Synchronizing (forceReSync=$forceReSync,onlyMigrate=$onlyMigrate)")
4950

50-
provider =
51-
try {
52-
LocalCalendar.getCalendarProvider(applicationContext)
53-
} catch (e: SecurityException) {
54-
NotificationUtils.showCalendarPermissionNotification(applicationContext)
55-
return Result.failure()
56-
}
51+
provider = try {
52+
LocalCalendar.getCalendarProvider(applicationContext)
53+
} catch (_: SecurityException) {
54+
NotificationUtils.showCalendarPermissionNotification(applicationContext)
55+
return Result.failure()
56+
}
5757

5858
var syncFailed = false
5959

@@ -88,6 +88,12 @@ open class BaseSyncWorker(
8888
syncFailed = true
8989
}
9090
}
91+
} catch (e: DeadObjectException) {
92+
/* May happen when the remote process dies or (since Android 14) when IPC (for instance
93+
with the calendar provider) is suddenly forbidden because our sync process was demoted
94+
from a "service process" to a "cached process". */
95+
Log.e(Constants.TAG, "Received DeadObjectException, treating as soft error", e)
96+
return Result.retry()
9197
} catch (e: InterruptedException) {
9298
Log.e(Constants.TAG, "Thread interrupted", e)
9399
return Result.retry()
@@ -183,8 +189,7 @@ open class BaseSyncWorker(
183189
"Creating local calendar from subscription #${subscription.id}"
184190
)
185191
// create local calendar
186-
val uri =
187-
AndroidCalendar.create(account, provider, subscription.toCalendarProperties())
192+
val uri = AndroidCalendar.create(account, provider, subscription.toCalendarProperties())
188193
// update calendar ID in DB
189194
val newCalendarId = ContentUris.parseId(uri)
190195
subscriptionsDao.updateCalendarId(subscription.id, newCalendarId)

gradle/libs.versions.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ androidx-test-rules = "1.6.1"
1111
androidx-test-runner = "1.6.2"
1212
androidx-work = "2.10.0"
1313
bitfire-cert4android = "f0964cb"
14-
bitfire-ical4android = "12df9bf"
14+
bitfire-ical4android = "883954c"
1515
compose-dialogs = "1.3.0"
1616
compose-material = "1.7.7"
1717
compose-material3 = "1.3.1"

0 commit comments

Comments
 (0)