Fix isInCallFlow when no active subscription am: c63f06d4c8
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/27205448 Change-Id: I5a58046c3e7ed2a1164648516248b39ee4feb5ef Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -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