summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author burakov <burakov@google.com> 2024-10-15 17:47:58 +0000
committer burakov <burakov@google.com> 2024-10-22 09:01:02 +0000
commit14495ce3af3949114899de16462c162e3418b90c (patch)
treea0a7ce476d53b9e867b8a3603ea1e6477513de58
parent80371cf33f4dff11058b07754e6a9151af006f89 (diff)
Remove redundant flows from SharedNotificationContainerInteractor
There is already an existing flow for configuration changes in `configurationInteractor`, and it's a better practice to depend on this interactor than the underlying repository anyway. The other flow, `isSplitShadeEnabled`, is redundant since its usages have been removed in ag/29864236. This is part of a refactoring that will improve NSSL positioning to support Dual Shade and Connected Displays. Bug: 338033836 Flag: com.android.systemui.scene_container Test: Existing unit tests still pass. Change-Id: I736234dac0692468980ea126c328cbbc479fc099
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/domain/interactor/SharedNotificationContainerInteractor.kt25
-rw-r--r--packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/stack/domain/interactor/SharedNotificationContainerInteractorKosmos.kt9
2 files changed, 16 insertions, 18 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/domain/interactor/SharedNotificationContainerInteractor.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/domain/interactor/SharedNotificationContainerInteractor.kt
index 5d3747628e7e..6042964281c2 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/domain/interactor/SharedNotificationContainerInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/domain/interactor/SharedNotificationContainerInteractor.kt
@@ -18,7 +18,7 @@
package com.android.systemui.statusbar.notification.stack.domain.interactor
import android.content.Context
-import com.android.systemui.common.ui.data.repository.ConfigurationRepository
+import com.android.systemui.common.ui.domain.interactor.ConfigurationInteractor
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.deviceentry.domain.interactor.DeviceEntryUdfpsInteractor
import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor
@@ -29,6 +29,8 @@ import com.android.systemui.shade.domain.interactor.ShadeInteractor
import com.android.systemui.statusbar.policy.SplitShadeStateController
import dagger.Lazy
import javax.inject.Inject
+import kotlinx.coroutines.ExperimentalCoroutinesApi
+import kotlinx.coroutines.FlowPreview
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
@@ -36,17 +38,17 @@ import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.debounce
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.map
-import kotlinx.coroutines.flow.onStart
/** Encapsulates business-logic specifically related to the shared notification stack container. */
+@OptIn(ExperimentalCoroutinesApi::class, FlowPreview::class)
@SysUISingleton
class SharedNotificationContainerInteractor
@Inject
constructor(
- configurationRepository: ConfigurationRepository,
private val context: Context,
private val splitShadeStateController: Lazy<SplitShadeStateController>,
private val shadeInteractor: Lazy<ShadeInteractor>,
+ configurationInteractor: ConfigurationInteractor,
keyguardInteractor: KeyguardInteractor,
deviceEntryUdfpsInteractor: DeviceEntryUdfpsInteractor,
largeScreenHeaderHelperLazy: Lazy<LargeScreenHeaderHelper>,
@@ -59,9 +61,6 @@ constructor(
/** An internal modification was made to notifications */
val notificationStackChanged = _notificationStackChanged.debounce(20L)
- private val configurationChangeEvents =
- configurationRepository.onAnyConfigurationChange.onStart { emit(Unit) }
-
/* Warning: Even though the value it emits only contains the split shade status, this flow must
* emit a value whenever the configuration *or* the split shade status changes. Adding a
* distinctUntilChanged() to this would cause configurationBasedDimensions to miss configuration
@@ -69,13 +68,14 @@ constructor(
*/
private val dimensionsUpdateEventsWithShouldUseSplitShade: Flow<Boolean> =
if (SceneContainerFlag.isEnabled) {
- combine(configurationChangeEvents, shadeInteractor.get().isShadeLayoutWide) {
- _,
- isShadeLayoutWide ->
+ combine(
+ configurationInteractor.onAnyConfigurationChange,
+ shadeInteractor.get().isShadeLayoutWide,
+ ) { _, isShadeLayoutWide ->
isShadeLayoutWide
}
} else {
- configurationChangeEvents.map {
+ configurationInteractor.onAnyConfigurationChange.map {
splitShadeStateController.get().shouldUseSplitNotificationShade(context.resources)
}
}
@@ -115,11 +115,6 @@ constructor(
isUdfpsSupported || !ambientIndicationVisible
}
- val isSplitShadeEnabled: Flow<Boolean> =
- configurationBasedDimensions
- .map { dimens: ConfigurationBasedDimensions -> dimens.useSplitShade }
- .distinctUntilChanged()
-
/** Top position (without translation) of the shared container. */
fun setTopPosition(top: Float) {
_topPosition.value = top
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/stack/domain/interactor/SharedNotificationContainerInteractorKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/stack/domain/interactor/SharedNotificationContainerInteractorKosmos.kt
index 3234e66024a8..83fc3e9f0c58 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/stack/domain/interactor/SharedNotificationContainerInteractorKosmos.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/stack/domain/interactor/SharedNotificationContainerInteractorKosmos.kt
@@ -14,26 +14,29 @@
* limitations under the License.
*/
+@file:OptIn(ExperimentalCoroutinesApi::class)
+
package com.android.systemui.statusbar.notification.stack.domain.interactor
import android.content.applicationContext
-import com.android.systemui.common.ui.data.repository.configurationRepository
+import com.android.systemui.common.ui.domain.interactor.configurationInteractor
import com.android.systemui.deviceentry.domain.interactor.deviceEntryUdfpsInteractor
import com.android.systemui.keyguard.domain.interactor.keyguardInteractor
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.shade.domain.interactor.shadeInteractor
import com.android.systemui.shade.largeScreenHeaderHelper
import com.android.systemui.statusbar.policy.splitShadeStateController
+import kotlinx.coroutines.ExperimentalCoroutinesApi
val Kosmos.sharedNotificationContainerInteractor by
Kosmos.Fixture {
SharedNotificationContainerInteractor(
- configurationRepository = configurationRepository,
context = applicationContext,
splitShadeStateController = { splitShadeStateController },
shadeInteractor = { shadeInteractor },
+ configurationInteractor = configurationInteractor,
keyguardInteractor = keyguardInteractor,
deviceEntryUdfpsInteractor = deviceEntryUdfpsInteractor,
- largeScreenHeaderHelperLazy = { largeScreenHeaderHelper }
+ largeScreenHeaderHelperLazy = { largeScreenHeaderHelper },
)
}