Merge "Fix isInCallFlow when no active subscription am: c63f06d4c8" into main
This commit is contained in:
committed by
Android (Google) Code Review
commit
276b1db7b2
@@ -26,6 +26,7 @@ import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.combine
|
||||
import kotlinx.coroutines.flow.conflate
|
||||
import kotlinx.coroutines.flow.flatMapLatest
|
||||
import kotlinx.coroutines.flow.flowOf
|
||||
import kotlinx.coroutines.flow.flowOn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
|
||||
@@ -50,8 +51,12 @@ class CallStateRepository(private val context: Context) {
|
||||
fun isInCallFlow(): Flow<Boolean> = context.subscriptionsChangedFlow()
|
||||
.flatMapLatest {
|
||||
val subIds = subscriptionManager.activeSubscriptionIdList
|
||||
combine(subIds.map(::callStateFlow)) { states ->
|
||||
states.any { it != TelephonyManager.CALL_STATE_IDLE }
|
||||
if (subIds.isEmpty()) {
|
||||
flowOf(false)
|
||||
} else {
|
||||
combine(subIds.map(::callStateFlow)) { states ->
|
||||
states.any { it != TelephonyManager.CALL_STATE_IDLE }
|
||||
}
|
||||
}
|
||||
}
|
||||
.conflate()
|
||||
|
||||
Reference in New Issue
Block a user