Merge "Waiting for the psim subscriptionInfo ready" into main

This commit is contained in:
SongFerng Wang
2024-12-15 22:26:28 -08:00
committed by Android (Google) Code Review
3 changed files with 493 additions and 432 deletions

View File

@@ -40,6 +40,7 @@ import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.flow.onStart
import kotlinx.coroutines.flow.shareIn
import java.util.stream.Collectors
private const val TAG = "SubscriptionRepository"
@@ -154,6 +155,18 @@ class SubscriptionRepository(private val context: Context) {
.conflate()
.flowOn(Dispatchers.Default)
fun removableSubscriptionInfoListFlow(): Flow<List<SubscriptionInfo>> {
return subscriptionsChangedFlow()
.map {
subscriptionManager.availableSubscriptionInfoList?.stream()
?.filter { sub: SubscriptionInfo -> !sub.isEmbedded }
?.collect(Collectors.toList()) ?: emptyList()
}
.conflate()
.onEach { Log.d(TAG, "getRemovableSubscriptionVisibleFlow: $it") }
.flowOn(Dispatchers.Default)
}
@OptIn(ExperimentalCoroutinesApi::class)
fun phoneNumberFlow(subId: Int): Flow<String?> =
activeSubscriptionInfoFlow(subId).flatMapLatest { subInfo ->