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

Commit 8d0a510b authored by Matt Pietal's avatar Matt Pietal Committed by Android (Google) Code Review
Browse files

Merge "Update ambient support on config changes" into main

parents e8effee2 9456a37d
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import com.android.app.wallpaperManager
import com.android.internal.R
import com.android.systemui.SysuiTestCase
import com.android.systemui.broadcast.broadcastDispatcher
import com.android.systemui.common.ui.data.repository.fakeConfigurationRepository
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.kosmos.testScope
import com.android.systemui.res.R as SysUIR
@@ -64,6 +65,7 @@ class WallpaperRepositoryImplTest : SysuiTestCase() {
    private val testScope = kosmos.testScope
    private val userRepository = kosmos.fakeUserRepository
    private val broadcastDispatcher = kosmos.broadcastDispatcher
    private val configRepository = kosmos.fakeConfigurationRepository

    // Initialized in each test since certain flows rely on mocked data that isn't
    // modifiable after start, like wallpaperManager.isWallpaperSupported
@@ -251,10 +253,18 @@ class WallpaperRepositoryImplTest : SysuiTestCase() {
            secureSettings.putInt(Settings.Secure.DOZE_ALWAYS_ON_WALLPAPER_ENABLED, 1)
            context.orCreateTestableResources.addOverride(
                R.bool.config_dozeSupportsAodWallpaper,
                true,
                false,
            )

            configRepository.onAnyConfigurationChange()
            val latest by collectLastValue(underTest.wallpaperSupportsAmbientMode)
            assertThat(latest).isFalse()

            // Validate that a configuration change recalculates the flow
            context.orCreateTestableResources.addOverride(
                R.bool.config_dozeSupportsAodWallpaper,
                true,
            )
            configRepository.onAnyConfigurationChange()
            assertThat(latest).isTrue()
        }

+13 −3
Original line number Diff line number Diff line
@@ -30,9 +30,11 @@ import android.util.Log
import android.view.View
import com.android.internal.R
import com.android.systemui.broadcast.BroadcastDispatcher
import com.android.systemui.common.ui.domain.interactor.ConfigurationInteractor
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.res.R as SysUIR
import com.android.systemui.shade.ShadeDisplayAware
import com.android.systemui.shared.Flags.ambientAod
import com.android.systemui.shared.Flags.extendedWallpaperEffects
import com.android.systemui.user.data.model.SelectedUserModel
@@ -88,6 +90,7 @@ constructor(
    private val wallpaperManager: WallpaperManager,
    private val context: Context,
    private val secureSettings: SecureSettings,
    @ShadeDisplayAware configurationInteractor: ConfigurationInteractor,
) : WallpaperRepository {
    private val wallpaperChanged: Flow<Unit> =
        broadcastDispatcher
@@ -123,9 +126,16 @@ constructor(
        }

    override val wallpaperSupportsAmbientMode: Flow<Boolean> =
        combine(
                secureSettings
            .observerFlow(UserHandle.USER_ALL, Settings.Secure.DOZE_ALWAYS_ON_WALLPAPER_ENABLED)
            .onStart { emit(Unit) }
                    .observerFlow(
                        UserHandle.USER_ALL,
                        Settings.Secure.DOZE_ALWAYS_ON_WALLPAPER_ENABLED,
                    )
                    .onStart { emit(Unit) },
                configurationInteractor.onAnyConfigurationChange,
                ::Pair,
            )
            .map {
                val userEnabled =
                    secureSettings.getInt(Settings.Secure.DOZE_ALWAYS_ON_WALLPAPER_ENABLED, 1) == 1
+2 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.systemui.wallpapers.data.repository
import android.content.applicationContext
import com.android.app.wallpaperManager
import com.android.systemui.broadcast.broadcastDispatcher
import com.android.systemui.common.ui.domain.interactor.configurationInteractor
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.Kosmos.Fixture
import com.android.systemui.kosmos.testDispatcher
@@ -35,5 +36,6 @@ val Kosmos.wallpaperRepository by Fixture {
        userRepository = userRepository,
        wallpaperManager = wallpaperManager,
        secureSettings = fakeSettings,
        configurationInteractor = configurationInteractor,
    )
}