Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5e2938bb authored by Steven Ng's avatar Steven Ng
Browse files

Move per display wallpaper dagger bindings into its own module

Flag: com.android.window.flags.enable_connected_displays_wallpaper_presentations
Test: manually test wallpaper presentation is shown in a connected display
Fix: 440563735
Change-Id: I2059850ce7288f9bb5e99947427ff272356f58de
parent 35a39902
Loading
Loading
Loading
Loading
+9 −35
Original line number Diff line number Diff line
@@ -38,23 +38,24 @@ import com.android.systemui.statusbar.dagger.PerDisplayStatusBarModule
import com.android.systemui.statusbar.phone.DarkIconDispatcherImpl
import com.android.systemui.statusbar.phone.SysuiDarkIconDispatcher
import com.android.systemui.statusbar.pipeline.shared.ui.composable.StatusBarRootFactory
import com.android.systemui.wallpapers.WallpaperPresentationEnabled
import com.android.systemui.wallpapers.WallpaperPresentationManager
import com.android.systemui.wallpapers.domain.interactor.DisplayWallpaperPresentationInteractor
import com.android.systemui.wallpapers.domain.interactor.DisplayWallpaperPresentationInteractorImpl
import com.android.systemui.wallpapers.domain.interactor.NoOpDisplayWallpaperPresentationInteractor
import com.android.systemui.wallpapers.dagger.PerDisplayWallpaperModule
import dagger.Binds
import dagger.Module
import dagger.Provides
import dagger.multibindings.ElementsIntoSet
import dagger.multibindings.IntoSet
import dagger.multibindings.Multibinds
import javax.inject.Provider
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope

/** Module providing common dependencies for per-display singletons. */
@Module(includes = [PerDisplayStatusBarModule::class, PerDisplayConfigurationModule::class])
@Module(
    includes =
        [
            PerDisplayStatusBarModule::class,
            PerDisplayConfigurationModule::class,
            PerDisplayWallpaperModule::class,
        ]
)
interface PerDisplaySystemUIModule {

    @Multibinds
@@ -138,32 +139,5 @@ interface PerDisplaySystemUIModule {
        }

        @Provides @DisplayAware fun provideDisplayId(@DisplayId displayId: Int): Int = displayId

        @Provides
        @PerDisplaySingleton
        @DisplayAware
        fun bindsDisplayWallpaperPresentationInteractor(
            @WallpaperPresentationEnabled isWallpaperPresentationEnabled: Boolean,
            impl: Provider<DisplayWallpaperPresentationInteractorImpl>,
        ): DisplayWallpaperPresentationInteractor =
            if (isWallpaperPresentationEnabled) {
                impl.get()
            } else {
                NoOpDisplayWallpaperPresentationInteractor
            }

        @Provides
        @PerDisplaySingleton
        @DisplayAware
        @ElementsIntoSet
        fun bindWallpaperPresentationManagerLifecycleListener(
            @WallpaperPresentationEnabled isWallpaperPresentationEnabled: Boolean,
            impl: Provider<WallpaperPresentationManager>,
        ): Set<SystemUIDisplaySubcomponent.LifecycleListener> =
            if (isWallpaperPresentationEnabled) {
                setOf(impl.get())
            } else {
                emptySet()
            }
    }
}
+67 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.wallpapers.dagger

import com.android.systemui.display.dagger.SystemUIDisplaySubcomponent
import com.android.systemui.display.dagger.SystemUIDisplaySubcomponent.DisplayAware
import com.android.systemui.display.dagger.SystemUIDisplaySubcomponent.PerDisplaySingleton
import com.android.systemui.wallpapers.WallpaperPresentationEnabled
import com.android.systemui.wallpapers.WallpaperPresentationManager
import com.android.systemui.wallpapers.domain.interactor.DisplayWallpaperPresentationInteractor
import com.android.systemui.wallpapers.domain.interactor.DisplayWallpaperPresentationInteractorImpl
import com.android.systemui.wallpapers.domain.interactor.NoOpDisplayWallpaperPresentationInteractor
import dagger.Module
import dagger.Provides
import dagger.multibindings.ElementsIntoSet
import javax.inject.Provider

/**
 * Module providing [SystemUIDisplaySubcomponent.DisplayAware] components that are related to the
 * wallpaper.
 */
@Module
interface PerDisplayWallpaperModule {

    companion object {
        @Provides
        @PerDisplaySingleton
        @DisplayAware
        fun bindsDisplayWallpaperPresentationInteractor(
            @WallpaperPresentationEnabled isWallpaperPresentationEnabled: Boolean,
            impl: Provider<DisplayWallpaperPresentationInteractorImpl>,
        ): DisplayWallpaperPresentationInteractor =
            if (isWallpaperPresentationEnabled) {
                impl.get()
            } else {
                NoOpDisplayWallpaperPresentationInteractor
            }

        @Provides
        @PerDisplaySingleton
        @DisplayAware
        @ElementsIntoSet
        fun bindWallpaperPresentationManagerLifecycleListener(
            @WallpaperPresentationEnabled isWallpaperPresentationEnabled: Boolean,
            impl: Provider<WallpaperPresentationManager>,
        ): Set<SystemUIDisplaySubcomponent.LifecycleListener> =
            if (isWallpaperPresentationEnabled) {
                setOf(impl.get())
            } else {
                emptySet()
            }
    }
}