diff options
| author | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2020-11-24 14:25:02 -0300 |
|---|---|---|
| committer | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2020-11-24 14:25:02 -0300 |
| commit | 299c6e6a6013f866a9f618e060edf0bfbb2fd7fc (patch) | |
| tree | dab5f4efdd9ed121002c3564a4a65c3693e55ec4 /android/src | |
| parent | 6b9120724681885968b5161c7e782776ee0fda0d (diff) | |
| parent | 60aee67c462e7f2f7c42910fbf030fd6fb3a9a45 (diff) | |
| download | mullvadvpn-299c6e6a6013f866a9f618e060edf0bfbb2fd7fc.tar.xz mullvadvpn-299c6e6a6013f866a9f618e060edf0bfbb2fd7fc.zip | |
Merge branch 'fix-missing-call-to-start-foreground-again'
Diffstat (limited to 'android/src')
| -rw-r--r-- | android/src/main/kotlin/net/mullvad/mullvadvpn/service/ForegroundNotificationManager.kt | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/ForegroundNotificationManager.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/ForegroundNotificationManager.kt index 2daf1477ba..a5d05628b2 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/ForegroundNotificationManager.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/ForegroundNotificationManager.kt @@ -26,7 +26,6 @@ class ForegroundNotificationManager( private sealed class UpdaterMessage { class UpdateNotification : UpdaterMessage() class UpdateAction : UpdaterMessage() - class AcknowledgeStartForegroundService : UpdaterMessage() class NewTunnelState(val newState: TunnelState) : UpdaterMessage() } @@ -102,10 +101,19 @@ class ForegroundNotificationManager( service.unregisterReceiver(deviceLockListener) updater.close() + + tunnelStateNotification.visible = false } fun acknowledgeStartForegroundService() { - updater.sendBlocking(UpdaterMessage.AcknowledgeStartForegroundService()) + // When sending start commands to the service, it is necessary to request the service to be + // on the foreground. With such request, when the service is started it must be placed on + // the foreground with a call to startForeground before a timeout expires, otherwise Android + // kills the app. + showOnForeground() + + // Restore the notification to its correct state. + updateNotification() } private fun runUpdater() = GlobalScope.actor<UpdaterMessage>( @@ -116,28 +124,12 @@ class ForegroundNotificationManager( when (message) { is UpdaterMessage.UpdateNotification -> updateNotification() is UpdaterMessage.UpdateAction -> updateNotificationAction() - is UpdaterMessage.AcknowledgeStartForegroundService -> { - doAcknowledgeStartForegroundService() - } is UpdaterMessage.NewTunnelState -> { tunnelStateNotification.tunnelState = message.newState updateNotification() } } } - - tunnelStateNotification.visible = false - } - - private fun doAcknowledgeStartForegroundService() { - // When sending start commands to the service, it is necessary to request the service to be - // on the foreground. With such request, when the service is started it must be placed on - // the foreground with a call to startForeground before a timeout expires, otherwise Android - // kills the app. - showOnForeground() - - // Restore the notification to its correct state. - updateNotification() } private fun showOnForeground() { |
