1
0
Fork 0
mirror of https://github.com/bitwarden/android.git synced 2025-01-30 19:53:47 +03:00

Vault timeout logging

This commit is contained in:
David Perez 2025-01-21 14:55:15 -06:00
parent 66ff5942e4
commit 8252f737f9
No known key found for this signature in database
GPG key ID: 3E29BD8B1BF090AC
2 changed files with 12 additions and 0 deletions
app/src/main/java/com/x8bit/bitwarden/data

View file

@ -12,6 +12,7 @@ import com.x8bit.bitwarden.data.platform.manager.model.AppForegroundState
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
import timber.log.Timber
/**
* Primary implementation of [AppStateManager].
@ -38,10 +39,12 @@ class AppStateManagerImpl(
private inner class AppForegroundObserver : DefaultLifecycleObserver {
override fun onStart(owner: LifecycleOwner) {
mutableAppForegroundStateFlow.value = AppForegroundState.FOREGROUNDED
Timber.e("App Foregrounded")
}
override fun onStop(owner: LifecycleOwner) {
mutableAppForegroundStateFlow.value = AppForegroundState.BACKGROUNDED
Timber.e("App Backgrounded")
}
}

View file

@ -50,6 +50,7 @@ import kotlinx.coroutines.flow.onCompletion
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch
import timber.log.Timber
import kotlin.time.Duration.Companion.minutes
/**
@ -254,6 +255,7 @@ class VaultLockManagerImpl(
if (!wasVaultUnlocked) {
mutableVaultStateEventSharedFlow.tryEmit(VaultStateEvent.Unlocked(userId = userId))
}
Timber.e("Vault Unlocked -- $userId")
}
private fun setVaultToLocked(userId: String) {
@ -269,12 +271,14 @@ class VaultLockManagerImpl(
if (!wasVaultLocked) {
mutableVaultStateEventSharedFlow.tryEmit(VaultStateEvent.Locked(userId = userId))
}
Timber.e("Vault Locked -- $userId")
}
private fun setVaultToUnlocking(userId: String) {
mutableVaultUnlockDataStateFlow.update {
it.update(userId, VaultUnlockData.Status.UNLOCKING)
}
Timber.e("Vault Unlocking -- $userId")
}
private fun setVaultToNotUnlocking(userId: String) {
@ -283,6 +287,7 @@ class VaultLockManagerImpl(
mutableVaultUnlockDataStateFlow.update {
it.update(userId, null)
}
Timber.e("Vault Not Unlocking -- $userId")
}
private fun storeUserAutoUnlockKeyIfNecessary(userId: String) {
@ -363,6 +368,7 @@ class VaultLockManagerImpl(
private fun handleOnForeground() {
val userId = activeUserId ?: return
Timber.e("Canceling Timeout Delay -- $userId")
userIdTimerJobMap[userId]?.cancel()
}
@ -460,6 +466,7 @@ class VaultLockManagerImpl(
) {
// Make sure to clear the now-active user's timeout job.
userIdTimerJobMap[currentActiveUserId]?.cancel()
Timber.e("Canceling Timeout Delay -- $currentActiveUserId")
// Check if the user's timeout action should be performed as we switch away.
checkForVaultTimeout(
userId = previousActiveUserId,
@ -551,6 +558,7 @@ class VaultLockManagerImpl(
vaultTimeoutAction: VaultTimeoutAction,
delayInMs: Long,
) {
Timber.e("Setup Timeout Delay ($delayInMs) $vaultTimeoutAction -- $userId")
userIdTimerJobMap[userId]?.cancel()
userIdTimerJobMap[userId] = unconfinedScope.launch {
delay(timeMillis = delayInMs)
@ -568,6 +576,7 @@ class VaultLockManagerImpl(
) {
when (vaultTimeoutAction) {
VaultTimeoutAction.LOCK -> {
Timber.e("Locking for timeout -- $userId")
setVaultToLocked(userId = userId)
}