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

Commit d1765c39 authored by Evan Laird's avatar Evan Laird Committed by Android (Google) Code Review
Browse files

Merge changes Ic0664697,Ief318002 into main

* changes:
  [sb] use concurrenthashmap for mobile vm cache
  [sb] Use a threadsafe hashmap for the repo cache
parents e16f8993 bc8316ad
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(
+2 −1
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import com.android.systemui.statusbar.pipeline.mobile.ui.MobileViewLogger
import com.android.systemui.statusbar.pipeline.mobile.ui.VerboseMobileViewLogger
import com.android.systemui.statusbar.pipeline.mobile.ui.view.ModernStatusBarMobileView
import com.android.systemui.statusbar.pipeline.shared.ConnectivityConstants
import java.util.concurrent.ConcurrentHashMap
import javax.inject.Inject
import kotlin.coroutines.CoroutineContext
import kotlinx.coroutines.CoroutineScope
@@ -62,7 +63,7 @@ constructor(
    @Background private val scope: CoroutineScope,
) {
    @VisibleForTesting
    val reuseCache = mutableMapOf<Int, Pair<MobileIconViewModel, CoroutineScope>>()
    val reuseCache = ConcurrentHashMap<Int, Pair<MobileIconViewModel, CoroutineScope>>()

    val subscriptionIdsFlow: StateFlow<List<Int>> =
        interactor.filteredSubscriptions