summaryrefslogtreecommitdiffhomepage
path: root/android
diff options
context:
space:
mode:
Diffstat (limited to 'android')
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/ipc/Event.kt4
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/model/LoginStatus.kt9
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/AccountCache.kt33
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/ServiceEndpoint.kt1
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/serviceconnection/AccountCache.kt25
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/serviceconnection/ServiceConnection.kt1
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/LoginViewModel.kt8
7 files changed, 12 insertions, 69 deletions
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ipc/Event.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ipc/Event.kt
index f8790d126a..bbf84bf143 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ipc/Event.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ipc/Event.kt
@@ -11,7 +11,6 @@ import net.mullvad.mullvadvpn.model.DeviceState
import net.mullvad.mullvadvpn.model.GeoIpLocation
import net.mullvad.mullvadvpn.model.KeygenEvent
import net.mullvad.mullvadvpn.model.LoginResult
-import net.mullvad.mullvadvpn.model.LoginStatus as LoginStatusData
import net.mullvad.mullvadvpn.model.RelayList
import net.mullvad.mullvadvpn.model.Settings
import net.mullvad.mullvadvpn.model.TunnelState
@@ -46,9 +45,6 @@ sealed class Event : Message.EventMessage() {
data class ListenerReady(val connection: Messenger, val listenerId: Int) : Event()
@Parcelize
- data class LoginStatus(val status: LoginStatusData?) : Event()
-
- @Parcelize
data class LoginEvent(val result: LoginResult) : Event()
@Parcelize
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/model/LoginStatus.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/model/LoginStatus.kt
deleted file mode 100644
index e1a1f485e8..0000000000
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/model/LoginStatus.kt
+++ /dev/null
@@ -1,9 +0,0 @@
-package net.mullvad.mullvadvpn.model
-
-import android.os.Parcelable
-import kotlinx.parcelize.Parcelize
-
-@Parcelize
-data class LoginStatus(
- val account: String
-) : Parcelable
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/AccountCache.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/AccountCache.kt
index 0ebb900d75..909d230f98 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/AccountCache.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/AccountCache.kt
@@ -13,7 +13,6 @@ import net.mullvad.mullvadvpn.model.AccountCreationResult
import net.mullvad.mullvadvpn.model.AccountExpiry
import net.mullvad.mullvadvpn.model.AccountHistory
import net.mullvad.mullvadvpn.model.GetAccountDataResult
-import net.mullvad.mullvadvpn.model.LoginStatus
import net.mullvad.mullvadvpn.util.JobTracker
import net.mullvad.talpid.util.EventNotifier
import org.joda.time.DateTime
@@ -38,19 +37,12 @@ class AccountCache(private val endpoint: ServiceEndpoint) {
val onAccountNumberChange = EventNotifier<String?>(null)
val onAccountExpiryChange = EventNotifier<AccountExpiry>(AccountExpiry.Missing)
val onAccountHistoryChange = EventNotifier<AccountHistory>(AccountHistory.Missing)
- val onLoginStatusChange = EventNotifier<LoginStatus?>(null)
-
- var newlyCreatedAccount = false
- private set
private val jobTracker = JobTracker()
private var accountExpiry by onAccountExpiryChange.notifiable()
private var accountHistory by onAccountHistoryChange.notifiable()
- var loginStatus by onLoginStatusChange.notifiable()
- private set
-
init {
jobTracker.newBackgroundJob("autoFetchAccountExpiry") {
daemon.await().deviceStateUpdates.collect { deviceState ->
@@ -63,10 +55,6 @@ class AccountCache(private val endpoint: ServiceEndpoint) {
endpoint.sendEvent(Event.AccountHistoryEvent(history))
}
- onLoginStatusChange.subscribe(this) { status ->
- endpoint.sendEvent(Event.LoginStatus(status))
- }
-
onAccountExpiryChange.subscribe(this) {
endpoint.sendEvent(Event.AccountExpiryEvent(it))
}
@@ -116,7 +104,6 @@ class AccountCache(private val endpoint: ServiceEndpoint) {
onAccountNumberChange.unsubscribeAll()
onAccountExpiryChange.unsubscribeAll()
onAccountHistoryChange.unsubscribeAll()
- onLoginStatusChange.unsubscribeAll()
commandChannel.close()
}
@@ -165,27 +152,19 @@ class AccountCache(private val endpoint: ServiceEndpoint) {
daemon.await().loginAccount(account).also { result ->
endpoint.sendEvent(Event.LoginEvent(result))
}
-
- synchronized(this) {
- loginStatus = LoginStatus(account)
- }
}
private suspend fun doLogout() {
daemon.await().logoutAccount()
- loginStatus = null
accountHistory = fetchAccountHistory()
}
- // TODO: Refactor in later commit.
- private fun fetchAccountHistory() {
- jobTracker.newBackgroundJob("fetchHistory") {
- daemon.await().getAccountHistory().let { history ->
- accountHistory = if (history != null) {
- AccountHistory.Available(history)
- } else {
- AccountHistory.Missing
- }
+ private suspend fun fetchAccountHistory(): AccountHistory {
+ return daemon.await().getAccountHistory().let { history ->
+ if (history != null) {
+ AccountHistory.Available(history)
+ } else {
+ AccountHistory.Missing
}
}
}
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/ServiceEndpoint.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/ServiceEndpoint.kt
index 7aed21ba3a..2592ffa3ec 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/ServiceEndpoint.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/ServiceEndpoint.kt
@@ -134,7 +134,6 @@ class ServiceEndpoint(
val initialEvents = mutableListOf(
Event.TunnelStateChange(connectionProxy.state),
- Event.LoginStatus(accountCache.onLoginStatusChange.latestEvent),
Event.AccountHistoryEvent(accountCache.onAccountHistoryChange.latestEvent),
Event.SettingsUpdate(settingsListener.settings),
Event.NewLocation(locationInfoCache.location),
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/serviceconnection/AccountCache.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/serviceconnection/AccountCache.kt
index 58295a521d..19552893ad 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/serviceconnection/AccountCache.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/serviceconnection/AccountCache.kt
@@ -12,14 +12,9 @@ import net.mullvad.mullvadvpn.ipc.Request
import net.mullvad.mullvadvpn.model.AccountCreationResult
import net.mullvad.mullvadvpn.model.AccountExpiry
import net.mullvad.mullvadvpn.model.AccountHistory
-import net.mullvad.mullvadvpn.model.LoginStatus
-import net.mullvad.talpid.util.EventNotifier
import org.joda.time.DateTime
class AccountCache(private val connection: Messenger, eventDispatcher: EventDispatcher) {
- val onLoginStatusChange = EventNotifier<LoginStatus?>(null)
-
- private var loginStatus by onLoginStatusChange.notifiable()
private val _accountCreationEvents = MutableSharedFlow<AccountCreationResult>(
extraBufferCapacity = 1,
@@ -44,25 +39,21 @@ class AccountCache(private val connection: Messenger, eventDispatcher: EventDisp
init {
eventDispatcher.apply {
- registerHandler(Event.AccountHistoryEvent::class) { event ->
- _accountHistoryEvents.tryEmit(event.history)
+ registerHandler(Event.AccountCreationEvent::class) { event ->
+ _accountCreationEvents.tryEmit(event.result)
}
- registerHandler(Event.LoginStatus::class) { event ->
- loginStatus = event.status
+ registerHandler(Event.AccountExpiryEvent::class) { event ->
+ _accountExpiryState.tryEmit(event.expiry)
}
- registerHandler(Event.AccountCreationEvent::class) { event ->
- _accountCreationEvents.tryEmit(event.result)
+ registerHandler(Event.AccountHistoryEvent::class) { event ->
+ _accountHistoryEvents.tryEmit(event.history)
}
registerHandler(Event.LoginEvent::class) { event ->
_loginEvents.tryEmit(event)
}
-
- registerHandler(Event.AccountExpiryEvent::class) { event ->
- _accountExpiryState.tryEmit(event.expiry)
- }
}
}
@@ -95,8 +86,4 @@ class AccountCache(private val connection: Messenger, eventDispatcher: EventDisp
fun clearAccountHistory() {
connection.send(Request.ClearAccountHistory.message)
}
-
- fun onDestroy() {
- onLoginStatusChange.unsubscribeAll()
- }
}
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/serviceconnection/ServiceConnection.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/serviceconnection/ServiceConnection.kt
index bea6c34ecb..7c44013bca 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/serviceconnection/ServiceConnection.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/serviceconnection/ServiceConnection.kt
@@ -61,7 +61,6 @@ class ServiceConnection(
closeScope()
dispatcher.onDestroy()
- accountCache.onDestroy()
authTokenCache.onDestroy()
connectionProxy.onDestroy()
keyStatusListener.onDestroy()
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/LoginViewModel.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/LoginViewModel.kt
index d4bb58d369..4ec72c529d 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/LoginViewModel.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/LoginViewModel.kt
@@ -1,7 +1,6 @@
package net.mullvad.mullvadvpn.viewmodel
import android.app.Application
-import androidx.annotation.RestrictTo
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
@@ -45,8 +44,6 @@ class LoginViewModel(
// Ensures the view model has an up-to-date instance of account cache. This is an intermediate
// solution due to limitations in the current app architecture.
fun updateAccountCacheInstance(newAccountCache: AccountCache?) {
- accountCache?.onLoginStatusChange?.unsubscribe(this)
-
accountCache = newAccountCache?.apply {
viewModelScope.launch {
accountHistoryEvents.collect {
@@ -86,11 +83,6 @@ class LoginViewModel(
}
}
- @RestrictTo(RestrictTo.Scope.TESTS)
- public override fun onCleared() {
- accountCache?.onLoginStatusChange?.unsubscribe(this)
- }
-
private fun AccountCreationResult.mapToUiState(): LoginUiState {
return when (this) {
is AccountCreationResult.Success -> LoginUiState.AccountCreated