summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Tracy Zhou <tracyzhou@google.com> 2025-02-19 16:16:43 -0800
committer Tracy Zhou <tracyzhou@google.com> 2025-02-20 22:09:22 -0800
commit5b243752002d4fd38eb8a61d09e455d8f5eef2bb (patch)
tree1f8cc61e3c86c0516032cb88d1f862ca7442eb12
parent3e9d30d82443d2025a09ad58cc5291fcb0e5b824 (diff)
Blur ambient AOD wallpaper
Bouncer: blur + zoomout. AOD: blur + no zoomout. Hence in this change we are separating the signals for blur radius to make it clear when passing down. Bug: 397818296 Test: manual Flag: com.android.systemui.shared.ambient_aod Change-Id: Id27683c658fc00c472b5b192dda18069c7266c67
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/NotificationShadeDepthControllerTest.kt24
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/NotificationShadeDepthController.kt55
2 files changed, 57 insertions, 22 deletions
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/NotificationShadeDepthControllerTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/NotificationShadeDepthControllerTest.kt
index 83361dad9ff0..4b06cde1384d 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/NotificationShadeDepthControllerTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/NotificationShadeDepthControllerTest.kt
@@ -34,7 +34,6 @@ import com.android.systemui.kosmos.testScope
import com.android.systemui.plugins.statusbar.StatusBarStateController
import com.android.systemui.res.R
import com.android.systemui.shade.ShadeExpansionChangeEvent
-import com.android.systemui.shared.Flags as SharedFlags
import com.android.systemui.statusbar.phone.BiometricUnlockController
import com.android.systemui.statusbar.phone.DozeParameters
import com.android.systemui.statusbar.phone.ScrimController
@@ -44,11 +43,10 @@ import com.android.systemui.statusbar.policy.ResourcesSplitShadeStateController
import com.android.systemui.testKosmos
import com.android.systemui.util.WallpaperController
import com.android.systemui.util.mockito.eq
+import com.android.systemui.wallpapers.domain.interactor.WallpaperInteractor
import com.android.systemui.window.domain.interactor.WindowRootViewBlurInteractor
import com.android.wm.shell.appzoomout.AppZoomOut
import com.google.common.truth.Truth.assertThat
-import java.util.Optional
-import java.util.function.Consumer
import org.junit.Before
import org.junit.Rule
import org.junit.Test
@@ -69,6 +67,8 @@ import org.mockito.Mockito.reset
import org.mockito.Mockito.verify
import org.mockito.Mockito.`when`
import org.mockito.junit.MockitoJUnit
+import java.util.Optional
+import java.util.function.Consumer
@RunWith(AndroidJUnit4::class)
@RunWithLooper
@@ -76,6 +76,7 @@ import org.mockito.junit.MockitoJUnit
class NotificationShadeDepthControllerTest : SysuiTestCase() {
private val kosmos = testKosmos()
+ private val applicationScope = kosmos.testScope.backgroundScope
@Mock private lateinit var windowRootViewBlurInteractor: WindowRootViewBlurInteractor
@Mock private lateinit var statusBarStateController: StatusBarStateController
@Mock private lateinit var blurUtils: BlurUtils
@@ -84,6 +85,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
@Mock private lateinit var keyguardInteractor: KeyguardInteractor
@Mock private lateinit var choreographer: Choreographer
@Mock private lateinit var wallpaperController: WallpaperController
+ @Mock private lateinit var wallpaperInteractor: WallpaperInteractor
@Mock private lateinit var notificationShadeWindowController: NotificationShadeWindowController
@Mock private lateinit var dumpManager: DumpManager
@Mock private lateinit var appZoomOutOptional: Optional<AppZoomOut>
@@ -128,12 +130,14 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
keyguardInteractor,
choreographer,
wallpaperController,
+ wallpaperInteractor,
notificationShadeWindowController,
dozeParameters,
context,
ResourcesSplitShadeStateController(),
windowRootViewBlurInteractor,
appZoomOutOptional,
+ applicationScope,
dumpManager,
configurationController,
)
@@ -310,19 +314,21 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
}
@Test
- @DisableFlags(SharedFlags.FLAG_AMBIENT_AOD)
- fun onDozeAmountChanged_appliesBlur() {
+ fun onDozeAmountChanged_doesNotApplyBlurWithAmbientAod() {
+ notificationShadeDepthController.wallpaperSupportsAmbientMode = false
+
statusBarStateListener.onDozeAmountChanged(1f, 1f)
notificationShadeDepthController.updateBlurCallback.doFrame(0)
- verify(blurUtils).applyBlur(any(), eq(maxBlur), eq(false))
+ verify(blurUtils).applyBlur(any(), eq(0), eq(false))
}
@Test
- @EnableFlags(SharedFlags.FLAG_AMBIENT_AOD)
- fun onDozeAmountChanged_doesNotApplyBlurWithAmbientAod() {
+ fun onDozeAmountChanged_appliesBlurWithAmbientAod() {
+ notificationShadeDepthController.wallpaperSupportsAmbientMode = true
+
statusBarStateListener.onDozeAmountChanged(1f, 1f)
notificationShadeDepthController.updateBlurCallback.doFrame(0)
- verify(blurUtils).applyBlur(any(), eq(0), eq(false))
+ verify(blurUtils).applyBlur(any(), eq(maxBlur), eq(false))
}
@Test
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShadeDepthController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShadeDepthController.kt
index 3db004848d22..84266e805773 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShadeDepthController.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShadeDepthController.kt
@@ -38,13 +38,13 @@ import com.android.systemui.Flags
import com.android.systemui.Flags.spatialModelAppPushback
import com.android.systemui.animation.ShadeInterpolation
import com.android.systemui.dagger.SysUISingleton
+import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.dump.DumpManager
import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor
import com.android.systemui.plugins.statusbar.StatusBarStateController
import com.android.systemui.shade.ShadeDisplayAware
import com.android.systemui.shade.ShadeExpansionChangeEvent
import com.android.systemui.shade.ShadeExpansionListener
-import com.android.systemui.shared.Flags.ambientAod
import com.android.systemui.statusbar.phone.BiometricUnlockController
import com.android.systemui.statusbar.phone.BiometricUnlockController.MODE_WAKE_AND_UNLOCK
import com.android.systemui.statusbar.phone.DozeParameters
@@ -53,8 +53,11 @@ import com.android.systemui.statusbar.policy.ConfigurationController
import com.android.systemui.statusbar.policy.KeyguardStateController
import com.android.systemui.statusbar.policy.SplitShadeStateController
import com.android.systemui.util.WallpaperController
+import com.android.systemui.wallpapers.domain.interactor.WallpaperInteractor
import com.android.systemui.window.domain.interactor.WindowRootViewBlurInteractor
import com.android.wm.shell.appzoomout.AppZoomOut
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.launch
import java.io.PrintWriter
import java.util.Optional
import javax.inject.Inject
@@ -76,12 +79,14 @@ constructor(
private val keyguardInteractor: KeyguardInteractor,
private val choreographer: Choreographer,
private val wallpaperController: WallpaperController,
+ private val wallpaperInteractor: WallpaperInteractor,
private val notificationShadeWindowController: NotificationShadeWindowController,
private val dozeParameters: DozeParameters,
@ShadeDisplayAware private val context: Context,
private val splitShadeStateController: SplitShadeStateController,
private val windowRootViewBlurInteractor: WindowRootViewBlurInteractor,
private val appZoomOutOptional: Optional<AppZoomOut>,
+ @Application private val applicationScope: CoroutineScope,
dumpManager: DumpManager,
configurationController: ConfigurationController,
) : ShadeExpansionListener, Dumpable {
@@ -110,6 +115,8 @@ constructor(
private var prevTimestamp: Long = -1
private var prevShadeDirection = 0
private var prevShadeVelocity = 0f
+ private var prevDozeAmount: Float = 0f
+ @VisibleForTesting var wallpaperSupportsAmbientMode: Boolean = false
// tracks whether app launch transition is in progress. This involves two independent factors
// that control blur, shade expansion and app launch animation from outside sysui.
// They can complete out of order, this flag will be reset by the animation that finishes later.
@@ -219,7 +226,15 @@ constructor(
}
/** Blur radius of the wake-up animation on this frame. */
- private var wakeAndUnlockBlurRadius = 0f
+ private var wakeBlurRadius = 0f
+ set(value) {
+ if (field == value) return
+ field = value
+ scheduleUpdate()
+ }
+
+ /** Blur radius of the unlock animation on this frame. */
+ private var unlockBlurRadius = 0f
set(value) {
if (field == value) return
field = value
@@ -246,14 +261,16 @@ constructor(
ShadeInterpolation.getNotificationScrimAlpha(qsPanelExpansion) * shadeExpansion
combinedBlur = max(combinedBlur, blurUtils.blurRadiusOfRatio(qsExpandedRatio))
combinedBlur = max(combinedBlur, blurUtils.blurRadiusOfRatio(transitionToFullShadeProgress))
- var shadeRadius = max(combinedBlur, wakeAndUnlockBlurRadius)
+ var shadeRadius = max(combinedBlur, max(wakeBlurRadius, unlockBlurRadius))
if (areBlursDisabledForAppLaunch || blursDisabledForUnlock) {
shadeRadius = 0f
}
var blur = shadeRadius.toInt()
- val zoomOut = blurRadiusToZoomOut(blurRadius = shadeRadius)
+ // If the blur comes from waking up, we don't want to zoom out the background
+ val zoomOut =
+ if (shadeRadius != wakeBlurRadius) blurRadiusToZoomOut(blurRadius = shadeRadius) else 0f
// Make blur be 0 if it is necessary to stop blur effect.
if (scrimsVisible) {
if (!Flags.notificationShadeBlur()) {
@@ -338,14 +355,14 @@ constructor(
startDelay = keyguardStateController.keyguardFadingAwayDelay
interpolator = Interpolators.FAST_OUT_SLOW_IN
addUpdateListener { animation: ValueAnimator ->
- wakeAndUnlockBlurRadius =
+ unlockBlurRadius =
blurUtils.blurRadiusOfRatio(animation.animatedValue as Float)
}
addListener(
object : AnimatorListenerAdapter() {
override fun onAnimationEnd(animation: Animator) {
keyguardAnimator = null
- wakeAndUnlockBlurRadius = 0f
+ unlockBlurRadius = 0f
}
}
)
@@ -381,15 +398,20 @@ constructor(
}
override fun onDozeAmountChanged(linear: Float, eased: Float) {
- wakeAndUnlockBlurRadius =
- if (ambientAod()) {
- 0f
- } else {
- blurUtils.blurRadiusOfRatio(eased)
- }
+ prevDozeAmount = eased
+ updateWakeBlurRadius(prevDozeAmount)
}
}
+ private fun updateWakeBlurRadius(ratio: Float) {
+ wakeBlurRadius =
+ if (!wallpaperSupportsAmbientMode) {
+ 0f
+ } else {
+ blurUtils.blurRadiusOfRatio(ratio)
+ }
+ }
+
init {
dumpManager.registerCriticalDumpable(javaClass.name, this)
if (WAKE_UP_ANIMATION_ENABLED) {
@@ -411,6 +433,12 @@ constructor(
}
}
)
+ applicationScope.launch {
+ wallpaperInteractor.wallpaperSupportsAmbientMode.collect { supported ->
+ wallpaperSupportsAmbientMode = supported
+ updateWakeBlurRadius(prevDozeAmount)
+ }
+ }
initBlurListeners()
}
@@ -585,7 +613,8 @@ constructor(
it.println("shouldApplyShadeBlur: ${shouldApplyShadeBlur()}")
it.println("shadeAnimation: ${shadeAnimation.radius}")
it.println("brightnessMirrorRadius: ${brightnessMirrorSpring.radius}")
- it.println("wakeAndUnlockBlur: $wakeAndUnlockBlurRadius")
+ it.println("wakeBlur: $wakeBlurRadius")
+ it.println("unlockBlur: $wakeBlurRadius")
it.println("blursDisabledForAppLaunch: $blursDisabledForAppLaunch")
it.println("appLaunchTransitionIsInProgress: $appLaunchTransitionIsInProgress")
it.println("qsPanelExpansion: $qsPanelExpansion")