diff options
Diffstat (limited to 'android')
4 files changed, 5 insertions, 35 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 c3e37d6115..dbddc614d3 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/ForegroundNotificationManager.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/ForegroundNotificationManager.kt @@ -92,21 +92,9 @@ class ForegroundNotificationManager( service.unregisterReceiver(deviceLockListener) updater.close() - tunnelStateNotification.visible = false } - fun 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>( Dispatchers.Main, Channel.UNLIMITED @@ -132,7 +120,7 @@ class ForegroundNotificationManager( onForeground = true } - private fun updateNotification() { + fun updateNotification() { if (shouldBeOnForeground != onForeground) { if (shouldBeOnForeground) { showOnForeground() diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadTileService.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadTileService.kt index 8045dfbe06..434f6db8ee 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadTileService.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadTileService.kt @@ -51,11 +51,11 @@ class MullvadTileService : TileService() { if (secured) { intent.action = MullvadVpnService.KEY_DISCONNECT_ACTION + startService(intent) } else { intent.action = MullvadVpnService.KEY_CONNECT_ACTION + startForegroundService(intent) } - - startForegroundService(intent) } override fun onStopListening() { diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadVpnService.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadVpnService.kt index 177db1d712..71067c44d7 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadVpnService.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadVpnService.kt @@ -61,14 +61,6 @@ class MullvadVpnService : TalpidVpnService() { } } - private var isBound: Boolean by observable(false) { _, _, isBound -> - notificationManager.lockedToForeground = isUiVisible or isBound - } - - private var isUiVisible: Boolean by observable(false) { _, _, isUiVisible -> - notificationManager.lockedToForeground = isUiVisible or isBound - } - override fun onCreate() { super.onCreate() Log.d(TAG, "Initializing service") @@ -91,7 +83,6 @@ class MullvadVpnService : TalpidVpnService() { notificationManager = ForegroundNotificationManager(this, connectionProxy, keyguardManager).apply { - acknowledgeStartForegroundService() accountNumberEvents = endpoint.settingsListener.accountNumberNotifier } @@ -121,7 +112,7 @@ class MullvadVpnService : TalpidVpnService() { val startResult = super.onStartCommand(intent, flags, startId) var quitCommand = false - notificationManager.acknowledgeStartForegroundService() + notificationManager.updateNotification() if (!keyguardManager.isDeviceLocked) { val action = intent?.action @@ -145,15 +136,11 @@ class MullvadVpnService : TalpidVpnService() { override fun onBind(intent: Intent): IBinder { Log.d(TAG, "New connection to service") - isBound = true - return super.onBind(intent) ?: endpoint.messenger.binder } override fun onRebind(intent: Intent) { Log.d(TAG, "Connection to service restored") - isBound = true - if (state == State.Stopping) { restart() } @@ -165,7 +152,6 @@ class MullvadVpnService : TalpidVpnService() { override fun onUnbind(intent: Intent): Boolean { Log.d(TAG, "Closed all connections to service") - isBound = false if (state != State.Running) { stop() diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/MainActivity.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/MainActivity.kt index 69db9c1243..dfc541d8d5 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/MainActivity.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/MainActivity.kt @@ -26,7 +26,6 @@ open class MainActivity : FragmentActivity() { val problemReport = MullvadProblemReport() val serviceNotifier = EventNotifier<ServiceConnection?>(null) - private var isUiVisible = false private var visibleSecureScreens = HashSet<Fragment>() private val deviceIsTv by lazy { @@ -87,11 +86,9 @@ open class MainActivity : FragmentActivity() { android.util.Log.d("mullvad", "Starting main activity") super.onStart() - isUiVisible = true - val intent = Intent(this, MullvadVpnService::class.java) - startForegroundService(intent) + startService(intent) bindService(intent, serviceConnectionManager, 0) } @@ -109,7 +106,6 @@ open class MainActivity : FragmentActivity() { override fun onStop() { android.util.Log.d("mullvad", "Stoping main activity") - isUiVisible = false unbindService(serviceConnectionManager) super.onStop() |
