@@ -3,6 +3,7 @@ package at.bitfire.icsdroid
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.WorkerParameters
@@ -47,13 +48,12 @@ open class BaseSyncWorker(
47
48
val onlyMigrate = inputData.getBoolean(ONLY_MIGRATE , false )
48
49
Log .i(Constants .TAG , " Synchronizing (forceReSync=$forceReSync ,onlyMigrate=$onlyMigrate )" )
49
50
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
+ }
57
57
58
58
var syncFailed = false
59
59
@@ -88,6 +88,12 @@ open class BaseSyncWorker(
88
88
syncFailed = true
89
89
}
90
90
}
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()
91
97
} catch (e: InterruptedException ) {
92
98
Log .e(Constants .TAG , " Thread interrupted" , e)
93
99
return Result .retry()
@@ -183,8 +189,7 @@ open class BaseSyncWorker(
183
189
" Creating local calendar from subscription #${subscription.id} "
184
190
)
185
191
// create local calendar
186
- val uri =
187
- AndroidCalendar .create(account, provider, subscription.toCalendarProperties())
192
+ val uri = AndroidCalendar .create(account, provider, subscription.toCalendarProperties())
188
193
// update calendar ID in DB
189
194
val newCalendarId = ContentUris .parseId(uri)
190
195
subscriptionsDao.updateCalendarId(subscription.id, newCalendarId)
0 commit comments