@@ -3,6 +3,7 @@ package at.bitfire.icsdroid.worker
3
3
import android.content.ContentProviderClient
4
4
import android.content.ContentUris
5
5
import android.content.Context
6
+ import android.os.DeadObjectException
6
7
import android.util.Log
7
8
import androidx.work.CoroutineWorker
8
9
import androidx.work.NetworkType
@@ -112,13 +113,12 @@ open class BaseSyncWorker(
112
113
val onlyMigrate = inputData.getBoolean(ONLY_MIGRATE , false )
113
114
Log .i(Constants .TAG , " Synchronizing (forceReSync=$forceReSync ,onlyMigrate=$onlyMigrate )" )
114
115
115
- provider =
116
- try {
117
- LocalCalendar .getCalendarProvider(applicationContext)
118
- } catch (e: SecurityException ) {
119
- NotificationUtils .showCalendarPermissionNotification(applicationContext)
120
- return Result .failure()
121
- }
116
+ provider = try {
117
+ LocalCalendar .getCalendarProvider(applicationContext)
118
+ } catch (_: SecurityException ) {
119
+ NotificationUtils .showCalendarPermissionNotification(applicationContext)
120
+ return Result .failure()
121
+ }
122
122
123
123
var syncFailed = false
124
124
@@ -154,6 +154,12 @@ open class BaseSyncWorker(
154
154
syncFailed = true
155
155
}
156
156
}
157
+ } catch (e: DeadObjectException ) {
158
+ /* May happen when the remote process dies or (since Android 14) when IPC (for instance
159
+ with the calendar provider) is suddenly forbidden because our sync process was demoted
160
+ from a "service process" to a "cached process". */
161
+ Log .e(Constants .TAG , " Received DeadObjectException, retrying." , e)
162
+ return Result .retry()
157
163
} catch (e: InterruptedException ) {
158
164
Log .e(Constants .TAG , " Thread interrupted" , e)
159
165
return Result .retry()
@@ -249,8 +255,7 @@ open class BaseSyncWorker(
249
255
" Creating local calendar from subscription #${subscription.id} "
250
256
)
251
257
// create local calendar
252
- val uri =
253
- AndroidCalendar .create(account, provider, subscription.toCalendarProperties())
258
+ val uri = AndroidCalendar .create(account, provider, subscription.toCalendarProperties())
254
259
// update calendar ID in DB
255
260
val newCalendarId = ContentUris .parseId(uri)
256
261
subscriptionsDao.updateCalendarId(subscription.id, newCalendarId)
0 commit comments