Merge Tusky PR 4292 to fix sending posts on API 34.
This commit is contained in:
parent
992160717b
commit
054b8d3dda
2 changed files with 13 additions and 4 deletions
|
|
@ -197,6 +197,7 @@
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
<service android:name=".service.SendStatusService"
|
<service android:name=".service.SendStatusService"
|
||||||
|
android:foregroundServiceType="shortService"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
|
|
||||||
<provider
|
<provider
|
||||||
|
|
|
||||||
|
|
@ -115,15 +115,23 @@ class SendStatusService : Service(), Injectable {
|
||||||
|
|
||||||
statusesToSend[sendingNotificationId] = statusToSend
|
statusesToSend[sendingNotificationId] = statusToSend
|
||||||
sendStatus(sendingNotificationId--)
|
sendStatus(sendingNotificationId--)
|
||||||
} else {
|
} else if (intent.hasExtra(KEY_CANCEL)) {
|
||||||
if (intent.hasExtra(KEY_CANCEL)) {
|
|
||||||
cancelSending(intent.getIntExtra(KEY_CANCEL, 0))
|
cancelSending(intent.getIntExtra(KEY_CANCEL, 0))
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return START_NOT_STICKY
|
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) {
|
private fun sendStatus(statusId: Int) {
|
||||||
// when statusToSend == null, sending has been canceled
|
// when statusToSend == null, sending has been canceled
|
||||||
val statusToSend = statusesToSend[statusId] ?: return
|
val statusToSend = statusesToSend[statusId] ?: return
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue