summaryrefslogtreecommitdiffhomepage
path: root/android/service/src/main
diff options
context:
space:
mode:
authorKalle Lindström <karl.lindstrom@mullvad.net>2025-08-04 11:19:50 +0200
committerKalle Lindström <karl.lindstrom@mullvad.net>2025-08-04 12:44:04 +0200
commit0a12ecffef67b5a3422dcd6ae53eeca114d407d4 (patch)
tree44d63b0b26b4c01cba6ab3bcb97dd00d5b7676eb /android/service/src/main
parent1b2e05d8c9353da4caf97d71001e1f4f9311079a (diff)
downloadmullvadvpn-0a12ecffef67b5a3422dcd6ae53eeca114d407d4.tar.xz
mullvadvpn-0a12ecffef67b5a3422dcd6ae53eeca114d407d4.zip
Attempt to fix potential ANR
In onReceive in NotificationAlarmReceiver onBlocking() was used which could potentially take too much time and cause an ANR. This PR changes the onBlocking() call to instead use the goAsync() API so that the onReceive method can return immediately.
Diffstat (limited to 'android/service/src/main')
-rw-r--r--android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/notifications/accountexpiry/AccountExpiryNotificationProvider.kt5
1 files changed, 3 insertions, 2 deletions
diff --git a/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/notifications/accountexpiry/AccountExpiryNotificationProvider.kt b/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/notifications/accountexpiry/AccountExpiryNotificationProvider.kt
index 776ce47960..0be99896c9 100644
--- a/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/notifications/accountexpiry/AccountExpiryNotificationProvider.kt
+++ b/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/notifications/accountexpiry/AccountExpiryNotificationProvider.kt
@@ -20,7 +20,7 @@ class AccountExpiryNotificationProvider(private val channelId: NotificationChann
override val notifications: Flow<NotificationUpdate<Notification.AccountExpiry>>
get() = notificationChannel.receiveAsFlow()
- suspend fun showNotification(durationUntilExpiry: Duration) {
+ fun showNotification(durationUntilExpiry: Duration) {
val notification =
Notification.AccountExpiry(
channelId = channelId,
@@ -29,7 +29,8 @@ class AccountExpiryNotificationProvider(private val channelId: NotificationChann
)
val notificationUpdate = NotificationUpdate.Notify(NOTIFICATION_ID, notification)
- notificationChannel.send(notificationUpdate)
+ // Always succeeds because the channel is conflated.
+ notificationChannel.trySend(notificationUpdate)
}
suspend fun cancelNotification() {