File tree 4 files changed +19
-6
lines changed
app/src/main/java/com/x8bit/bitwarden
platform/manager/flightrecorder
ui/platform/components/coachmark
core/src/main/kotlin/com/bitwarden/core/data/util
4 files changed +19
-6
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import android.content.BroadcastReceiver
4
4
import android.content.Context
5
5
import android.content.Intent
6
6
import android.content.IntentFilter
7
+ import com.bitwarden.core.data.util.concurrentMapOf
7
8
import com.bitwarden.data.manager.DispatcherManager
8
9
import com.x8bit.bitwarden.data.platform.datasource.disk.SettingsDiskSource
9
10
import com.x8bit.bitwarden.data.platform.datasource.disk.model.FlightRecorderDataSet
@@ -23,7 +24,6 @@ import timber.log.Timber
23
24
import java.time.Clock
24
25
import java.time.temporal.ChronoUnit
25
26
import java.util.UUID
26
- import java.util.concurrent.ConcurrentHashMap
27
27
28
28
private const val EXPIRATION_DURATION_DAYS : Long = 30
29
29
@@ -40,7 +40,7 @@ internal class FlightRecorderManagerImpl(
40
40
private val unconfinedScope = CoroutineScope (context = dispatcherManager.unconfined)
41
41
private val ioScope = CoroutineScope (context = dispatcherManager.io)
42
42
private var cancellationJob: Job = Job ().apply { complete() }
43
- private val expirationJobMap: ConcurrentHashMap <String , Job > = ConcurrentHashMap ()
43
+ private val expirationJobMap: MutableMap <String , Job > = concurrentMapOf ()
44
44
private val flightRecorderTree = FlightRecorderTree ()
45
45
46
46
override val flightRecorderData: FlightRecorderDataSet
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import com.bitwarden.core.InitUserCryptoMethod
9
9
import com.bitwarden.core.InitUserCryptoRequest
10
10
import com.bitwarden.core.data.repository.util.bufferedMutableSharedFlow
11
11
import com.bitwarden.core.data.util.asSuccess
12
+ import com.bitwarden.core.data.util.concurrentMapOf
12
13
import com.bitwarden.core.data.util.flatMap
13
14
import com.bitwarden.crypto.HashPurpose
14
15
import com.bitwarden.crypto.Kdf
@@ -58,7 +59,6 @@ import kotlinx.coroutines.flow.onEach
58
59
import kotlinx.coroutines.flow.update
59
60
import kotlinx.coroutines.launch
60
61
import java.time.Clock
61
- import java.util.concurrent.ConcurrentHashMap
62
62
import kotlin.time.Duration.Companion.minutes
63
63
64
64
/* *
@@ -88,7 +88,7 @@ class VaultLockManagerImpl(
88
88
* This [Map] tracks all active timeout [Job]s that are running and their associated data using
89
89
* the user ID as the key.
90
90
*/
91
- private val userIdTimerJobMap: MutableMap <String , TimeoutJobData > = ConcurrentHashMap ()
91
+ private val userIdTimerJobMap: MutableMap <String , TimeoutJobData > = concurrentMapOf ()
92
92
93
93
private val activeUserId: String? get() = authDiskSource.userState?.activeUserId
94
94
Original file line number Diff line number Diff line change @@ -8,10 +8,10 @@ import androidx.compose.runtime.saveable.Saver
8
8
import androidx.compose.runtime.saveable.listSaver
9
9
import androidx.compose.runtime.saveable.rememberSaveable
10
10
import androidx.compose.ui.geometry.Rect
11
+ import com.bitwarden.core.data.util.concurrentMapOf
11
12
import com.x8bit.bitwarden.ui.platform.components.coachmark.model.CoachMarkHighlightShape
12
13
import com.x8bit.bitwarden.ui.platform.components.coachmark.model.CoachMarkHighlightState
13
14
import com.x8bit.bitwarden.ui.platform.components.tooltip.BitwardenToolTipState
14
- import java.util.concurrent.ConcurrentHashMap
15
15
import kotlin.math.max
16
16
import kotlin.math.min
17
17
@@ -33,7 +33,7 @@ open class CoachMarkState<T : Enum<T>>(
33
33
initialCoachMarkHighlight : T ? = null ,
34
34
isCoachMarkVisible : Boolean = false ,
35
35
) {
36
- private val highlights: MutableMap <T , CoachMarkHighlightState <T >? > = ConcurrentHashMap ()
36
+ private val highlights: MutableMap <T , CoachMarkHighlightState <T >? > = concurrentMapOf ()
37
37
private val mutableCurrentHighlight = mutableStateOf(initialCoachMarkHighlight)
38
38
val currentHighlight: State <T ?> = mutableCurrentHighlight
39
39
private val mutableCurrentHighlightBounds = mutableStateOf(Rect .Zero )
Original file line number Diff line number Diff line change
1
+ @file:OmitFromCoverage
2
+
3
+ package com.bitwarden.core.data.util
4
+
5
+ import com.bitwarden.core.annotation.OmitFromCoverage
6
+ import java.util.concurrent.ConcurrentHashMap
7
+
8
+ /* *
9
+ * Creates a thread-safe [MutableMap].
10
+ */
11
+ fun <T , R > concurrentMapOf (
12
+ vararg items : Pair <T , R >,
13
+ ): MutableMap <T , R > = ConcurrentHashMap <T , R >().apply { this .putAll(items) }
You can’t perform that action at this time.
0 commit comments