Loading packages/SystemUI/multivalentTests/src/com/android/systemui/util/kotlin/BooleanFlowOperatorsTest.kt +10 −10 Original line number Diff line number Diff line Loading @@ -23,9 +23,9 @@ import com.android.systemui.coroutines.collectLastValue import com.android.systemui.coroutines.collectValues import com.android.systemui.kosmos.testScope import com.android.systemui.testKosmos import com.android.systemui.util.kotlin.BooleanFlowOperators.and import com.android.systemui.util.kotlin.BooleanFlowOperators.allOf import com.android.systemui.util.kotlin.BooleanFlowOperators.anyOf import com.android.systemui.util.kotlin.BooleanFlowOperators.not import com.android.systemui.util.kotlin.BooleanFlowOperators.or import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableStateFlow Loading @@ -45,21 +45,21 @@ class BooleanFlowOperatorsTest : SysuiTestCase() { @Test fun and_allTrue_returnsTrue() = testScope.runTest { val result by collectLastValue(and(TRUE, TRUE)) val result by collectLastValue(allOf(TRUE, TRUE)) assertThat(result).isTrue() } @Test fun and_anyFalse_returnsFalse() = testScope.runTest { val result by collectLastValue(and(TRUE, FALSE, TRUE)) val result by collectLastValue(allOf(TRUE, FALSE, TRUE)) assertThat(result).isFalse() } @Test fun and_allFalse_returnsFalse() = testScope.runTest { val result by collectLastValue(and(FALSE, FALSE, FALSE)) val result by collectLastValue(allOf(FALSE, FALSE, FALSE)) assertThat(result).isFalse() } Loading @@ -68,7 +68,7 @@ class BooleanFlowOperatorsTest : SysuiTestCase() { testScope.runTest { val flow1 = MutableStateFlow(false) val flow2 = MutableStateFlow(false) val values by collectValues(and(flow1, flow2)) val values by collectValues(allOf(flow1, flow2)) assertThat(values).containsExactly(false) flow1.value = true Loading @@ -81,21 +81,21 @@ class BooleanFlowOperatorsTest : SysuiTestCase() { @Test fun or_allTrue_returnsTrue() = testScope.runTest { val result by collectLastValue(or(TRUE, TRUE)) val result by collectLastValue(anyOf(TRUE, TRUE)) assertThat(result).isTrue() } @Test fun or_anyTrue_returnsTrue() = testScope.runTest { val result by collectLastValue(or(FALSE, TRUE, FALSE)) val result by collectLastValue(anyOf(FALSE, TRUE, FALSE)) assertThat(result).isTrue() } @Test fun or_allFalse_returnsFalse() = testScope.runTest { val result by collectLastValue(or(FALSE, FALSE, FALSE)) val result by collectLastValue(anyOf(FALSE, FALSE, FALSE)) assertThat(result).isFalse() } Loading @@ -104,7 +104,7 @@ class BooleanFlowOperatorsTest : SysuiTestCase() { testScope.runTest { val flow1 = MutableStateFlow(false) val flow2 = MutableStateFlow(false) val values by collectValues(or(flow1, flow2)) val values by collectValues(anyOf(flow1, flow2)) assertThat(values).containsExactly(false) flow1.value = true Loading packages/SystemUI/src/com/android/systemui/bouncer/domain/interactor/AlternateBouncerInteractor.kt +2 −2 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInterac import com.android.systemui.keyguard.shared.model.KeyguardState import com.android.systemui.plugins.statusbar.StatusBarStateController import com.android.systemui.statusbar.policy.KeyguardStateController import com.android.systemui.util.kotlin.BooleanFlowOperators.or import com.android.systemui.util.kotlin.BooleanFlowOperators.anyOf import com.android.systemui.util.time.SystemClock import dagger.Lazy import javax.inject.Inject Loading Loading @@ -78,7 +78,7 @@ constructor( bouncerRepository.alternateBouncerUIAvailable } private val isDozingOrAod: Flow<Boolean> = or( anyOf( keyguardTransitionInteractor.get().transitionValue(KeyguardState.DOZING).map { it > 0f }, Loading packages/SystemUI/src/com/android/systemui/classifier/FalsingCollectorImpl.java +1 −1 Original line number Diff line number Diff line Loading @@ -206,7 +206,7 @@ class FalsingCollectorImpl implements FalsingCollector { ); final CommunalInteractor communalInteractor = mCommunalInteractorLazy.get(); mJavaAdapter.alwaysCollectFlow( BooleanFlowOperators.INSTANCE.and( BooleanFlowOperators.INSTANCE.allOf( communalInteractor.isCommunalEnabled(), communalInteractor.isCommunalShowing()), this::onShowingCommunalHubChanged Loading packages/SystemUI/src/com/android/systemui/communal/domain/interactor/CommunalInteractor.kt +4 −4 Original line number Diff line number Diff line Loading @@ -60,9 +60,9 @@ import com.android.systemui.scene.shared.flag.SceneContainerFlag import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.settings.UserTracker import com.android.systemui.smartspace.data.repository.SmartspaceRepository import com.android.systemui.util.kotlin.BooleanFlowOperators.and import com.android.systemui.util.kotlin.BooleanFlowOperators.allOf import com.android.systemui.util.kotlin.BooleanFlowOperators.anyOf import com.android.systemui.util.kotlin.BooleanFlowOperators.not import com.android.systemui.util.kotlin.BooleanFlowOperators.or import com.android.systemui.util.kotlin.emitOnStart import javax.inject.Inject import kotlinx.coroutines.CoroutineDispatcher Loading Loading @@ -127,10 +127,10 @@ constructor( /** Whether communal features are enabled and available. */ val isCommunalAvailable: Flow<Boolean> = and( allOf( communalSettingsInteractor.isCommunalEnabled, not(keyguardInteractor.isEncryptedOrLockdown), or(keyguardInteractor.isKeyguardShowing, keyguardInteractor.isDreaming) anyOf(keyguardInteractor.isKeyguardShowing, keyguardInteractor.isDreaming) ) .distinctUntilChanged() .onEach { available -> Loading packages/SystemUI/src/com/android/systemui/communal/widgets/CommunalAppWidgetHostStartable.kt +2 −2 Original line number Diff line number Diff line Loading @@ -23,7 +23,7 @@ import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Background import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.settings.UserTracker import com.android.systemui.util.kotlin.BooleanFlowOperators.or import com.android.systemui.util.kotlin.BooleanFlowOperators.anyOf import com.android.systemui.util.kotlin.pairwise import com.android.systemui.util.kotlin.sample import javax.inject.Inject Loading @@ -46,7 +46,7 @@ constructor( ) : CoreStartable { override fun start() { or(communalInteractor.isCommunalAvailable, communalInteractor.editModeOpen) anyOf(communalInteractor.isCommunalAvailable, communalInteractor.editModeOpen) // Only trigger updates on state changes, ignoring the initial false value. .pairwise(false) .filter { (previous, new) -> previous != new } Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/util/kotlin/BooleanFlowOperatorsTest.kt +10 −10 Original line number Diff line number Diff line Loading @@ -23,9 +23,9 @@ import com.android.systemui.coroutines.collectLastValue import com.android.systemui.coroutines.collectValues import com.android.systemui.kosmos.testScope import com.android.systemui.testKosmos import com.android.systemui.util.kotlin.BooleanFlowOperators.and import com.android.systemui.util.kotlin.BooleanFlowOperators.allOf import com.android.systemui.util.kotlin.BooleanFlowOperators.anyOf import com.android.systemui.util.kotlin.BooleanFlowOperators.not import com.android.systemui.util.kotlin.BooleanFlowOperators.or import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableStateFlow Loading @@ -45,21 +45,21 @@ class BooleanFlowOperatorsTest : SysuiTestCase() { @Test fun and_allTrue_returnsTrue() = testScope.runTest { val result by collectLastValue(and(TRUE, TRUE)) val result by collectLastValue(allOf(TRUE, TRUE)) assertThat(result).isTrue() } @Test fun and_anyFalse_returnsFalse() = testScope.runTest { val result by collectLastValue(and(TRUE, FALSE, TRUE)) val result by collectLastValue(allOf(TRUE, FALSE, TRUE)) assertThat(result).isFalse() } @Test fun and_allFalse_returnsFalse() = testScope.runTest { val result by collectLastValue(and(FALSE, FALSE, FALSE)) val result by collectLastValue(allOf(FALSE, FALSE, FALSE)) assertThat(result).isFalse() } Loading @@ -68,7 +68,7 @@ class BooleanFlowOperatorsTest : SysuiTestCase() { testScope.runTest { val flow1 = MutableStateFlow(false) val flow2 = MutableStateFlow(false) val values by collectValues(and(flow1, flow2)) val values by collectValues(allOf(flow1, flow2)) assertThat(values).containsExactly(false) flow1.value = true Loading @@ -81,21 +81,21 @@ class BooleanFlowOperatorsTest : SysuiTestCase() { @Test fun or_allTrue_returnsTrue() = testScope.runTest { val result by collectLastValue(or(TRUE, TRUE)) val result by collectLastValue(anyOf(TRUE, TRUE)) assertThat(result).isTrue() } @Test fun or_anyTrue_returnsTrue() = testScope.runTest { val result by collectLastValue(or(FALSE, TRUE, FALSE)) val result by collectLastValue(anyOf(FALSE, TRUE, FALSE)) assertThat(result).isTrue() } @Test fun or_allFalse_returnsFalse() = testScope.runTest { val result by collectLastValue(or(FALSE, FALSE, FALSE)) val result by collectLastValue(anyOf(FALSE, FALSE, FALSE)) assertThat(result).isFalse() } Loading @@ -104,7 +104,7 @@ class BooleanFlowOperatorsTest : SysuiTestCase() { testScope.runTest { val flow1 = MutableStateFlow(false) val flow2 = MutableStateFlow(false) val values by collectValues(or(flow1, flow2)) val values by collectValues(anyOf(flow1, flow2)) assertThat(values).containsExactly(false) flow1.value = true Loading
packages/SystemUI/src/com/android/systemui/bouncer/domain/interactor/AlternateBouncerInteractor.kt +2 −2 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInterac import com.android.systemui.keyguard.shared.model.KeyguardState import com.android.systemui.plugins.statusbar.StatusBarStateController import com.android.systemui.statusbar.policy.KeyguardStateController import com.android.systemui.util.kotlin.BooleanFlowOperators.or import com.android.systemui.util.kotlin.BooleanFlowOperators.anyOf import com.android.systemui.util.time.SystemClock import dagger.Lazy import javax.inject.Inject Loading Loading @@ -78,7 +78,7 @@ constructor( bouncerRepository.alternateBouncerUIAvailable } private val isDozingOrAod: Flow<Boolean> = or( anyOf( keyguardTransitionInteractor.get().transitionValue(KeyguardState.DOZING).map { it > 0f }, Loading
packages/SystemUI/src/com/android/systemui/classifier/FalsingCollectorImpl.java +1 −1 Original line number Diff line number Diff line Loading @@ -206,7 +206,7 @@ class FalsingCollectorImpl implements FalsingCollector { ); final CommunalInteractor communalInteractor = mCommunalInteractorLazy.get(); mJavaAdapter.alwaysCollectFlow( BooleanFlowOperators.INSTANCE.and( BooleanFlowOperators.INSTANCE.allOf( communalInteractor.isCommunalEnabled(), communalInteractor.isCommunalShowing()), this::onShowingCommunalHubChanged Loading
packages/SystemUI/src/com/android/systemui/communal/domain/interactor/CommunalInteractor.kt +4 −4 Original line number Diff line number Diff line Loading @@ -60,9 +60,9 @@ import com.android.systemui.scene.shared.flag.SceneContainerFlag import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.settings.UserTracker import com.android.systemui.smartspace.data.repository.SmartspaceRepository import com.android.systemui.util.kotlin.BooleanFlowOperators.and import com.android.systemui.util.kotlin.BooleanFlowOperators.allOf import com.android.systemui.util.kotlin.BooleanFlowOperators.anyOf import com.android.systemui.util.kotlin.BooleanFlowOperators.not import com.android.systemui.util.kotlin.BooleanFlowOperators.or import com.android.systemui.util.kotlin.emitOnStart import javax.inject.Inject import kotlinx.coroutines.CoroutineDispatcher Loading Loading @@ -127,10 +127,10 @@ constructor( /** Whether communal features are enabled and available. */ val isCommunalAvailable: Flow<Boolean> = and( allOf( communalSettingsInteractor.isCommunalEnabled, not(keyguardInteractor.isEncryptedOrLockdown), or(keyguardInteractor.isKeyguardShowing, keyguardInteractor.isDreaming) anyOf(keyguardInteractor.isKeyguardShowing, keyguardInteractor.isDreaming) ) .distinctUntilChanged() .onEach { available -> Loading
packages/SystemUI/src/com/android/systemui/communal/widgets/CommunalAppWidgetHostStartable.kt +2 −2 Original line number Diff line number Diff line Loading @@ -23,7 +23,7 @@ import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Background import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.settings.UserTracker import com.android.systemui.util.kotlin.BooleanFlowOperators.or import com.android.systemui.util.kotlin.BooleanFlowOperators.anyOf import com.android.systemui.util.kotlin.pairwise import com.android.systemui.util.kotlin.sample import javax.inject.Inject Loading @@ -46,7 +46,7 @@ constructor( ) : CoreStartable { override fun start() { or(communalInteractor.isCommunalAvailable, communalInteractor.editModeOpen) anyOf(communalInteractor.isCommunalAvailable, communalInteractor.editModeOpen) // Only trigger updates on state changes, ignoring the initial false value. .pairwise(false) .filter { (previous, new) -> previous != new } Loading