diff options
| author | 2024-11-21 18:09:59 +0000 | |
|---|---|---|
| committer | 2024-11-21 18:09:59 +0000 | |
| commit | 1da37826dfc8b79fd2ce85a3d7e35b00ea10c907 (patch) | |
| tree | ce626696d6b39b599b8228aa87336f930c556c0c | |
| parent | 7a9271bcb2f6f3002d29dc2e53728c7ede36b109 (diff) | |
| parent | a13172285b16df63fb7a2c3a75bfa49866a88c6b (diff) | |
Merge "Add ShadeDisplaysInteractor to ShadeDisplayAwareModule" into main
3 files changed, 35 insertions, 3 deletions
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/interactor/ShadeDisplaysInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/interactor/ShadeDisplaysInteractorTest.kt index 08a22a87c2ba..016a24acd461 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/interactor/ShadeDisplaysInteractorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/interactor/ShadeDisplaysInteractorTest.kt @@ -31,6 +31,7 @@ import com.android.systemui.display.shared.model.DisplayWindowProperties import com.android.systemui.scene.ui.view.WindowRootView import com.android.systemui.shade.data.repository.FakeShadeDisplayRepository import com.android.systemui.statusbar.phone.ConfigurationForwarder +import java.util.Optional import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.TestScope import kotlinx.coroutines.test.UnconfinedTestDispatcher @@ -65,7 +66,7 @@ class ShadeDisplaysInteractorTest : SysuiTestCase() { private val interactor = ShadeDisplaysInteractor( - shadeRootview, + Optional.of(shadeRootview), positionRepository, MutableContextWrapper(defaultContext), resources, diff --git a/packages/SystemUI/src/com/android/systemui/shade/ShadeDisplayAwareModule.kt b/packages/SystemUI/src/com/android/systemui/shade/ShadeDisplayAwareModule.kt index bf2ea56b0c67..0b36e685d914 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/ShadeDisplayAwareModule.kt +++ b/packages/SystemUI/src/com/android/systemui/shade/ShadeDisplayAwareModule.kt @@ -29,16 +29,20 @@ import com.android.systemui.common.ui.data.repository.ConfigurationRepositoryImp import com.android.systemui.common.ui.domain.interactor.ConfigurationInteractor import com.android.systemui.common.ui.domain.interactor.ConfigurationInteractorImpl import com.android.systemui.dagger.SysUISingleton +import com.android.systemui.scene.ui.view.WindowRootView import com.android.systemui.shade.data.repository.ShadeDisplaysRepository import com.android.systemui.shade.data.repository.ShadeDisplaysRepositoryImpl +import com.android.systemui.shade.domain.interactor.ShadeDisplaysInteractor import com.android.systemui.shade.shared.flag.ShadeWindowGoesAround import com.android.systemui.statusbar.phone.ConfigurationControllerImpl import com.android.systemui.statusbar.phone.ConfigurationForwarder import com.android.systemui.statusbar.policy.ConfigurationController +import dagger.BindsOptionalOf import dagger.Module import dagger.Provides import dagger.multibindings.ClassKey import dagger.multibindings.IntoMap +import javax.inject.Provider /** * Module responsible for managing display-specific components and resources for the notification @@ -52,7 +56,7 @@ import dagger.multibindings.IntoMap * By using this dedicated module, we ensure the notification shade window always utilizes the * correct display context and resources, regardless of the display it's on. */ -@Module +@Module(includes = [OptionalShadeDisplayAwareBindings::class]) object ShadeDisplayAwareModule { /** Creates a new context for the shade window. */ @@ -169,4 +173,20 @@ object ShadeDisplayAwareModule { CoreStartable.NOP } } + + @Provides + @IntoMap + @ClassKey(ShadeDisplaysInteractor::class) + fun provideShadeDisplaysInteractor(impl: Provider<ShadeDisplaysInteractor>): CoreStartable { + return if (ShadeWindowGoesAround.isEnabled) { + impl.get() + } else { + CoreStartable.NOP + } + } +} + +@Module +internal interface OptionalShadeDisplayAwareBindings { + @BindsOptionalOf fun bindOptionalOfWindowRootView(): WindowRootView } diff --git a/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeDisplaysInteractor.kt b/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeDisplaysInteractor.kt index 18dbba1d0d25..432d5f553fbb 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeDisplaysInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeDisplaysInteractor.kt @@ -38,6 +38,8 @@ import com.android.systemui.shade.ShadeWindowLayoutParams import com.android.systemui.shade.data.repository.ShadeDisplaysRepository import com.android.systemui.shade.shared.flag.ShadeWindowGoesAround import com.android.systemui.statusbar.phone.ConfigurationForwarder +import com.android.systemui.util.kotlin.getOrNull +import java.util.Optional import javax.inject.Inject import kotlin.coroutines.CoroutineContext import kotlinx.coroutines.CoroutineScope @@ -48,7 +50,7 @@ import kotlinx.coroutines.withContext class ShadeDisplaysInteractor @Inject constructor( - private val shadeRootView: WindowRootView, + optionalShadeRootView: Optional<WindowRootView>, private val shadePositionRepository: ShadeDisplaysRepository, @ShadeDisplayAware private val shadeContext: Context, @ShadeDisplayAware private val shadeResources: Resources, @@ -58,6 +60,15 @@ constructor( @Main private val mainThreadContext: CoroutineContext, ) : CoreStartable { + private val shadeRootView = + optionalShadeRootView.getOrNull() + ?: error( + """ + ShadeRootView must be provided for this ShadeDisplayInteractor to work. + If it is not, it means this is being instantiated in a SystemUI variant that shouldn't. + """ + .trimIndent() + ) // TODO: b/362719719 - Get rid of this callback as the root view should automatically get the // correct configuration once it's moved to another window. private var unregisterConfigChangedCallbacks: (() -> Unit)? = null |