Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9d5599fd authored by Evan Laird's avatar Evan Laird
Browse files

[sb] Use a threadsafe hashmap for the repo cache

This should guard against the potential that different threads request
the same connection repo at the same time.

Test: tests in statusbar/pipeline/mobile
Bug: 388401782
Flag: EXEMPT bugfix
Change-Id: Ief318002b55cd9bd4bf32472503e5c628469c535
parent 93d7e93f
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ import com.android.systemui.util.kotlin.pairwise
import com.android.systemui.utils.coroutines.flow.conflatedCallbackFlow
import java.io.PrintWriter
import java.lang.ref.WeakReference
import java.util.concurrent.ConcurrentHashMap
import javax.inject.Inject
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
@@ -108,9 +109,8 @@ constructor(
) : MobileConnectionsRepository, Dumpable {

    // TODO(b/333912012): for now, we are never invalidating the cache. We can do better though
    private var subIdRepositoryCache:
        MutableMap<Int, WeakReference<FullMobileConnectionRepository>> =
        mutableMapOf()
    private var subIdRepositoryCache =
        ConcurrentHashMap<Int, WeakReference<FullMobileConnectionRepository>>()

    private val defaultNetworkName =
        NetworkNameModel.Default(