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

Commit b01a9571 authored by Bryce Lee's avatar Bryce Lee Committed by Android (Google) Code Review
Browse files

Merge "Use blurred wallpaper for Glanceable Hub background." into main

parents a86fcf96 762b011d
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -1206,6 +1206,13 @@ flag {
  }
}

flag {
  name: "glanceable_hub_blurred_background"
  namespace: "systemui"
  description: "Allow blurred background on glanceable hub"
  bug: "389788272"
}

flag {
  name: "communal_widget_resizing"
  namespace: "systemui"
+4 −0
Original line number Diff line number Diff line
@@ -256,6 +256,7 @@ fun ContentScope.CommunalScene(
            CommunalBackgroundType.STATIC_GRADIENT -> StaticLinearGradient()
            CommunalBackgroundType.ANIMATED -> AnimatedLinearGradient()
            CommunalBackgroundType.NONE -> BackgroundTopScrim()
            CommunalBackgroundType.BLUR -> Background()
        }

        with(content) {
@@ -314,6 +315,9 @@ private fun BoxScope.BackgroundTopScrim() {
    Box(Modifier.matchParentSize().alpha(0.34f).background(scrimOnTopColor))
}

/** Transparent (nothing) composable for when the background is blurred. */
@Composable private fun BoxScope.Background() {}

/** The duration to use for the gradient background animation. */
private const val ANIMATION_DURATION_MS = 10_000

+2 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import android.platform.test.flag.junit.FlagsParameterization
import android.provider.Settings
import androidx.test.filters.SmallTest
import com.android.systemui.Flags.FLAG_COMMUNAL_HUB
import com.android.systemui.Flags.FLAG_GLANCEABLE_HUB_BLURRED_BACKGROUND
import com.android.systemui.Flags.FLAG_GLANCEABLE_HUB_V2
import com.android.systemui.SysuiTestCase
import com.android.systemui.broadcast.broadcastDispatcher
@@ -279,6 +280,7 @@ class CommunalSettingsRepositoryImplTest(flags: FlagsParameterization?) : SysuiT
        }

    @Test
    @DisableFlags(FLAG_GLANCEABLE_HUB_BLURRED_BACKGROUND)
    fun backgroundType_defaultValue() =
        testScope.runTest {
            val backgroundType by collectLastValue(underTest.getBackground(PRIMARY_USER))
+70 −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.keyguard.ui.viewmodel

import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.common.ui.data.repository.fakeConfigurationRepository
import com.android.systemui.flags.DisableSceneContainer
import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository
import com.android.systemui.keyguard.shared.model.KeyguardState
import com.android.systemui.keyguard.shared.model.TransitionStep
import com.android.systemui.keyguard.ui.transitions.blurConfig
import com.android.systemui.kosmos.collectValues
import com.android.systemui.kosmos.runTest
import com.android.systemui.kosmos.testScope
import com.android.systemui.testKosmos
import kotlinx.coroutines.ExperimentalCoroutinesApi
import org.junit.Test
import org.junit.runner.RunWith

@OptIn(ExperimentalCoroutinesApi::class)
@SmallTest
@RunWith(AndroidJUnit4::class)
class DozingToGlanceableHubTransitionViewModelTest : SysuiTestCase() {
    val kosmos = testKosmos()
    val testScope = kosmos.testScope

    val keyguardTransitionRepository = kosmos.fakeKeyguardTransitionRepository
    val configurationRepository = kosmos.fakeConfigurationRepository
    val underTest by lazy { kosmos.dozingToGlanceableHubTransitionViewModel }

    @Test
    @DisableSceneContainer
    fun blurBecomesMaxValueImmediately() =
        kosmos.runTest {
            val values by collectValues(underTest.windowBlurRadius)

            keyguardWindowBlurTestUtil.assertTransitionToBlurRadius(
                transitionProgress = listOf(0.0f, 0.2f, 0.3f, 0.65f, 0.7f, 1.0f),
                startValue = blurConfig.minBlurRadiusPx,
                endValue = blurConfig.maxBlurRadiusPx,
                actualValuesProvider = { values },
                transitionFactory = { step, transitionState ->
                    TransitionStep(
                        from = KeyguardState.DOZING,
                        to = KeyguardState.GLANCEABLE_HUB,
                        value = step,
                        transitionState = transitionState,
                        ownerName = "DozingToGlanceableHubTransitionViewModelTest",
                    )
                },
                checkInterpolatedValues = false,
            )
        }
}
+36 −13
Original line number Diff line number Diff line
@@ -23,16 +23,19 @@ import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.common.ui.data.repository.fakeConfigurationRepository
import com.android.systemui.coroutines.collectValues
import com.android.systemui.flags.DisableSceneContainer
import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository
import com.android.systemui.keyguard.shared.model.KeyguardState
import com.android.systemui.keyguard.shared.model.TransitionState
import com.android.systemui.keyguard.shared.model.TransitionStep
import com.android.systemui.keyguard.ui.transitions.blurConfig
import com.android.systemui.kosmos.collectValues
import com.android.systemui.kosmos.runTest
import com.android.systemui.kosmos.testScope
import com.android.systemui.res.R
import com.android.systemui.testKosmos
import com.google.common.collect.Range
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.test.runTest
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.kotlin.mock
@@ -49,11 +52,11 @@ class DreamingToGlanceableHubTransitionViewModelTest : SysuiTestCase() {

    @Test
    fun dreamOverlayAlpha() =
        testScope.runTest {
        kosmos.runTest {
            val values by collectValues(underTest.dreamOverlayAlpha)
            assertThat(values).isEmpty()

            kosmos.fakeKeyguardTransitionRepository.sendTransitionSteps(
            fakeKeyguardTransitionRepository.sendTransitionSteps(
                listOf(
                    // Should start running here...
                    step(0f, TransitionState.STARTED),
@@ -72,10 +75,10 @@ class DreamingToGlanceableHubTransitionViewModelTest : SysuiTestCase() {

    @Test
    fun dreamOverlayTranslationX() =
        testScope.runTest {
        kosmos.runTest {
            configurationRepository.setDimensionPixelSize(
                R.dimen.dreaming_to_hub_transition_dream_overlay_translation_x,
                -100
                -100,
            )
            val configuration: Configuration = mock()
            whenever(configuration.layoutDirection).thenReturn(LayoutDirection.LTR)
@@ -84,12 +87,8 @@ class DreamingToGlanceableHubTransitionViewModelTest : SysuiTestCase() {
            val values by collectValues(underTest.dreamOverlayTranslationX)
            assertThat(values).isEmpty()

            kosmos.fakeKeyguardTransitionRepository.sendTransitionSteps(
                listOf(
                    step(0f, TransitionState.STARTED),
                    step(0.3f),
                    step(0.6f),
                ),
            fakeKeyguardTransitionRepository.sendTransitionSteps(
                listOf(step(0f, TransitionState.STARTED), step(0.3f), step(0.6f)),
                testScope,
            )

@@ -97,16 +96,40 @@ class DreamingToGlanceableHubTransitionViewModelTest : SysuiTestCase() {
            values.forEach { assertThat(it).isIn(Range.closed(-100f, 0f)) }
        }

    @Test
    @DisableSceneContainer
    fun blurBecomesMaxValueImmediately() =
        kosmos.runTest {
            val values by collectValues(underTest.windowBlurRadius)

            keyguardWindowBlurTestUtil.assertTransitionToBlurRadius(
                transitionProgress = listOf(0.0f, 0.2f, 0.3f, 0.65f, 0.7f, 1.0f),
                startValue = blurConfig.minBlurRadiusPx,
                endValue = blurConfig.maxBlurRadiusPx,
                actualValuesProvider = { values },
                transitionFactory = { step, transitionState ->
                    TransitionStep(
                        from = KeyguardState.DREAMING,
                        to = KeyguardState.GLANCEABLE_HUB,
                        value = step,
                        transitionState = transitionState,
                        ownerName = "DreamingToGlanceableHubTransitionViewModelTest",
                    )
                },
                checkInterpolatedValues = false,
            )
        }

    private fun step(
        value: Float,
        state: TransitionState = TransitionState.RUNNING
        state: TransitionState = TransitionState.RUNNING,
    ): TransitionStep {
        return TransitionStep(
            from = KeyguardState.DREAMING,
            to = KeyguardState.GLANCEABLE_HUB,
            value = value,
            transitionState = state,
            ownerName = "DreamingToGlanceableHubTransitionViewModelTest"
            ownerName = "DreamingToGlanceableHubTransitionViewModelTest",
        )
    }
}
Loading