Merge Tusky PR 4292 to fix sending posts on API 34.

This commit is contained in:
Mike Barnes 2025-03-23 10:06:56 +11:00
commit 5456297612
2 changed files with 13 additions and 4 deletions

View file

@ -197,6 +197,7 @@
</service>
<service android:name=".service.SendStatusService"
android:foregroundServiceType="shortService"
android:exported="false" />
<provider

View file

@ -115,15 +115,23 @@ class SendStatusService : Service(), Injectable {
statusesToSend[sendingNotificationId] = statusToSend
sendStatus(sendingNotificationId--)
} else {
if (intent.hasExtra(KEY_CANCEL)) {
cancelSending(intent.getIntExtra(KEY_CANCEL, 0))
}
} else if (intent.hasExtra(KEY_CANCEL)) {
cancelSending(intent.getIntExtra(KEY_CANCEL, 0))
}
return START_NOT_STICKY
}
override fun onTimeout(startId: Int) {
// https://developer.android.com/about/versions/14/changes/fgs-types-required#short-service
// max time for short service reached on Android 14+, stop sending
statusesToSend.forEach { (statusId, _) ->
serviceScope.launch {
failSending(statusId)
}
}
}
private fun sendStatus(statusId: Int) {
// when statusToSend == null, sending has been canceled
val statusToSend = statusesToSend[statusId] ?: return