Change AndroidAlarmManager to use ContextCompat and add ContextCompat.RECEIVER_NOT_EXPORTED to work with api 34

This commit is contained in:
Wolf-Martell Montwé 2024-01-18 12:25:07 +01:00
parent c9d631d8b0
commit fb5cc67977
No known key found for this signature in database
GPG key ID: 6D45B21512ACBF72

View file

@ -6,6 +6,7 @@ import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.os.SystemClock
import androidx.core.content.ContextCompat
import com.fsck.k9.backend.imap.SystemAlarmManager
import com.fsck.k9.helper.AlarmManagerCompat
import com.fsck.k9.helper.PendingIntentCompat.FLAG_IMMUTABLE
@ -40,7 +41,8 @@ class AndroidAlarmManager(
init {
val intentFilter = IntentFilter(ALARM_ACTION)
context.registerReceiver(
ContextCompat.registerReceiver(
context,
object : BroadcastReceiver() {
override fun onReceive(context: Context?, intent: Intent?) {
val callback = callback.getAndSet(null)
@ -54,6 +56,7 @@ class AndroidAlarmManager(
}
},
intentFilter,
ContextCompat.RECEIVER_NOT_EXPORTED,
)
}