Skip to content

Commit

Permalink
Rely on connectionState to decide if to unbind the service
Browse files Browse the repository at this point in the history
  • Loading branch information
Rawa committed Jan 16, 2025
1 parent b7ac66c commit 1d87e84
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import net.mullvad.mullvadvpn.lib.theme.AppTheme
import net.mullvad.mullvadvpn.repository.SplashCompleteRepository
import net.mullvad.mullvadvpn.repository.UserPreferencesRepository
import net.mullvad.mullvadvpn.ui.serviceconnection.ServiceConnectionManager
import net.mullvad.mullvadvpn.ui.serviceconnection.ServiceConnectionState
import net.mullvad.mullvadvpn.viewmodel.MullvadAppViewModel
import org.koin.android.ext.android.inject
import org.koin.android.scope.AndroidScopeComponent
Expand Down Expand Up @@ -121,10 +122,8 @@ class MainActivity : ComponentActivity(), AndroidScopeComponent {

override fun onStop() {
super.onStop()
lifecycleScope.launch {
if (userPreferencesRepository.preferences().isPrivacyDisclosureAccepted) {
serviceConnectionManager.unbind()
}
if (serviceConnectionManager.connectionState.value == ServiceConnectionState.Bound) {
serviceConnectionManager.unbind()
}
}

Expand Down

0 comments on commit 1d87e84

Please sign in to comment.