Loading packages/SystemUI/src/com/android/systemui/statusbar/NotificationShadeDepthController.kt +24 −2 Original line number Diff line number Diff line Loading @@ -84,6 +84,7 @@ class NotificationShadeDepthController @Inject constructor( private var isClosed: Boolean = true private var isOpen: Boolean = false private var isBlurred: Boolean = false private var listeners = mutableListOf<DepthListener>() private var prevTracking: Boolean = false private var prevTimestamp: Long = -1 Loading Loading @@ -187,12 +188,15 @@ class NotificationShadeDepthController @Inject constructor( } blurUtils.applyBlur(blurRoot?.viewRootImpl ?: root.viewRootImpl, blur) val zoomOut = blurUtils.ratioOfBlurRadius(blur) try { wallpaperManager.setWallpaperZoomOut(root.windowToken, blurUtils.ratioOfBlurRadius(blur)) wallpaperManager.setWallpaperZoomOut(root.windowToken, zoomOut) } catch (e: IllegalArgumentException) { Log.w(TAG, "Can't set zoom. Window is gone: ${root.windowToken}", e) } listeners.forEach { it.onWallpaperZoomOutChanged(zoomOut) } notificationShadeWindowController.setBackgroundBlurRadius(blur) } Loading Loading @@ -271,6 +275,14 @@ class NotificationShadeDepthController @Inject constructor( shadeAnimation.setDampingRatio(SpringForce.DAMPING_RATIO_NO_BOUNCY) } fun addListener(listener: DepthListener) { listeners.add(listener) } fun removeListener(listener: DepthListener) { listeners.remove(listener) } /** * Update blurs when pulling down the shade */ Loading Loading @@ -482,4 +494,14 @@ class NotificationShadeDepthController @Inject constructor( springAnimation.setStartVelocity(velocity) } } /** * Invoked when changes are needed in z-space */ interface DepthListener { /** * Current wallpaper zoom out, where 0 is the closest, and 1 the farthest */ fun onWallpaperZoomOutChanged(zoomOut: Float) } } packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +10 −0 Original line number Diff line number Diff line Loading @@ -97,6 +97,7 @@ import android.util.ArraySet; import android.util.DisplayMetrics; import android.util.EventLog; import android.util.Log; import android.util.MathUtils; import android.util.Slog; import android.view.Display; import android.view.IWindowManager; Loading Loading @@ -1156,6 +1157,15 @@ public class StatusBar extends SystemUI implements DemoMode, BackDropView backdrop = mNotificationShadeWindowView.findViewById(R.id.backdrop); mMediaManager.setup(backdrop, backdrop.findViewById(R.id.backdrop_front), backdrop.findViewById(R.id.backdrop_back), mScrimController, mLockscreenWallpaper); float maxWallpaperZoom = mContext.getResources().getFloat( com.android.internal.R.dimen.config_wallpaperMaxScale); mNotificationShadeDepthControllerLazy.get().addListener(depth -> { float scale = MathUtils.lerp(maxWallpaperZoom, 1f, depth); backdrop.setPivotX(backdrop.getWidth() / 2f); backdrop.setPivotY(backdrop.getHeight() / 2f); backdrop.setScaleX(scale); backdrop.setScaleY(scale); }); mNotificationPanelViewController.setUserSetupComplete(mUserSetup); if (UserManager.get(mContext).isUserSwitcherEnabled()) { Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationShadeDepthControllerTest.kt +7 −8 Original line number Diff line number Diff line Loading @@ -31,13 +31,13 @@ import com.android.systemui.statusbar.phone.BiometricUnlockController import com.android.systemui.statusbar.phone.DozeParameters import com.android.systemui.statusbar.phone.NotificationShadeWindowController import com.android.systemui.statusbar.policy.KeyguardStateController import com.android.systemui.util.mockito.eq import org.junit.Before import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.mockito.ArgumentCaptor import org.mockito.ArgumentMatchers.anyInt import org.mockito.ArgumentMatchers.eq import org.mockito.Mock import org.mockito.Mockito.`when` import org.mockito.Mockito.any Loading Loading @@ -68,6 +68,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() { @Mock private lateinit var shadeAnimation: NotificationShadeDepthController.DepthAnimation @Mock private lateinit var globalActionsSpring: NotificationShadeDepthController.DepthAnimation @Mock private lateinit var brightnessSpring: NotificationShadeDepthController.DepthAnimation @Mock private lateinit var listener: NotificationShadeDepthController.DepthListener @Mock private lateinit var dozeParameters: DozeParameters @JvmField @Rule val mockitoRule = MockitoJUnit.rule() Loading Loading @@ -103,7 +104,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() { @Test fun setupListeners() { verify(dumpManager).registerDumpable(anyString(), safeEq(notificationShadeDepthController)) verify(dumpManager).registerDumpable(anyString(), eq(notificationShadeDepthController)) } @Test Loading Loading @@ -171,7 +172,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() { @Test fun updateGlobalDialogVisibility_animatesBlur() { notificationShadeDepthController.updateGlobalDialogVisibility(0.5f, root) verify(globalActionsSpring).animateTo(eq(maxBlur / 2), safeEq(root)) verify(globalActionsSpring).animateTo(eq(maxBlur / 2), eq(root)) } @Test Loading @@ -191,8 +192,10 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() { @Test fun updateBlurCallback_setsBlurAndZoom() { notificationShadeDepthController.addListener(listener) notificationShadeDepthController.updateBlurCallback.doFrame(0) verify(wallpaperManager).setWallpaperZoomOut(any(), anyFloat()) verify(listener).onWallpaperZoomOutChanged(anyFloat()) verify(blurUtils).applyBlur(any(), anyInt()) } Loading Loading @@ -245,7 +248,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() { notificationShadeDepthController.updateBlurCallback.doFrame(0) verify(notificationShadeWindowController).setBackgroundBlurRadius(0) verify(blurUtils).applyBlur(safeEq(viewRootImpl), eq(0)) verify(blurUtils).applyBlur(eq(viewRootImpl), eq(0)) } @Test Loading @@ -267,8 +270,4 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() { verify(shadeSpring, never()).animateTo(anyInt(), any()) verify(shadeAnimation, never()).animateTo(anyInt(), any()) } private fun <T : Any> safeEq(value: T): T { return eq(value) ?: value } } No newline at end of file Loading
packages/SystemUI/src/com/android/systemui/statusbar/NotificationShadeDepthController.kt +24 −2 Original line number Diff line number Diff line Loading @@ -84,6 +84,7 @@ class NotificationShadeDepthController @Inject constructor( private var isClosed: Boolean = true private var isOpen: Boolean = false private var isBlurred: Boolean = false private var listeners = mutableListOf<DepthListener>() private var prevTracking: Boolean = false private var prevTimestamp: Long = -1 Loading Loading @@ -187,12 +188,15 @@ class NotificationShadeDepthController @Inject constructor( } blurUtils.applyBlur(blurRoot?.viewRootImpl ?: root.viewRootImpl, blur) val zoomOut = blurUtils.ratioOfBlurRadius(blur) try { wallpaperManager.setWallpaperZoomOut(root.windowToken, blurUtils.ratioOfBlurRadius(blur)) wallpaperManager.setWallpaperZoomOut(root.windowToken, zoomOut) } catch (e: IllegalArgumentException) { Log.w(TAG, "Can't set zoom. Window is gone: ${root.windowToken}", e) } listeners.forEach { it.onWallpaperZoomOutChanged(zoomOut) } notificationShadeWindowController.setBackgroundBlurRadius(blur) } Loading Loading @@ -271,6 +275,14 @@ class NotificationShadeDepthController @Inject constructor( shadeAnimation.setDampingRatio(SpringForce.DAMPING_RATIO_NO_BOUNCY) } fun addListener(listener: DepthListener) { listeners.add(listener) } fun removeListener(listener: DepthListener) { listeners.remove(listener) } /** * Update blurs when pulling down the shade */ Loading Loading @@ -482,4 +494,14 @@ class NotificationShadeDepthController @Inject constructor( springAnimation.setStartVelocity(velocity) } } /** * Invoked when changes are needed in z-space */ interface DepthListener { /** * Current wallpaper zoom out, where 0 is the closest, and 1 the farthest */ fun onWallpaperZoomOutChanged(zoomOut: Float) } }
packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +10 −0 Original line number Diff line number Diff line Loading @@ -97,6 +97,7 @@ import android.util.ArraySet; import android.util.DisplayMetrics; import android.util.EventLog; import android.util.Log; import android.util.MathUtils; import android.util.Slog; import android.view.Display; import android.view.IWindowManager; Loading Loading @@ -1156,6 +1157,15 @@ public class StatusBar extends SystemUI implements DemoMode, BackDropView backdrop = mNotificationShadeWindowView.findViewById(R.id.backdrop); mMediaManager.setup(backdrop, backdrop.findViewById(R.id.backdrop_front), backdrop.findViewById(R.id.backdrop_back), mScrimController, mLockscreenWallpaper); float maxWallpaperZoom = mContext.getResources().getFloat( com.android.internal.R.dimen.config_wallpaperMaxScale); mNotificationShadeDepthControllerLazy.get().addListener(depth -> { float scale = MathUtils.lerp(maxWallpaperZoom, 1f, depth); backdrop.setPivotX(backdrop.getWidth() / 2f); backdrop.setPivotY(backdrop.getHeight() / 2f); backdrop.setScaleX(scale); backdrop.setScaleY(scale); }); mNotificationPanelViewController.setUserSetupComplete(mUserSetup); if (UserManager.get(mContext).isUserSwitcherEnabled()) { Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationShadeDepthControllerTest.kt +7 −8 Original line number Diff line number Diff line Loading @@ -31,13 +31,13 @@ import com.android.systemui.statusbar.phone.BiometricUnlockController import com.android.systemui.statusbar.phone.DozeParameters import com.android.systemui.statusbar.phone.NotificationShadeWindowController import com.android.systemui.statusbar.policy.KeyguardStateController import com.android.systemui.util.mockito.eq import org.junit.Before import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.mockito.ArgumentCaptor import org.mockito.ArgumentMatchers.anyInt import org.mockito.ArgumentMatchers.eq import org.mockito.Mock import org.mockito.Mockito.`when` import org.mockito.Mockito.any Loading Loading @@ -68,6 +68,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() { @Mock private lateinit var shadeAnimation: NotificationShadeDepthController.DepthAnimation @Mock private lateinit var globalActionsSpring: NotificationShadeDepthController.DepthAnimation @Mock private lateinit var brightnessSpring: NotificationShadeDepthController.DepthAnimation @Mock private lateinit var listener: NotificationShadeDepthController.DepthListener @Mock private lateinit var dozeParameters: DozeParameters @JvmField @Rule val mockitoRule = MockitoJUnit.rule() Loading Loading @@ -103,7 +104,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() { @Test fun setupListeners() { verify(dumpManager).registerDumpable(anyString(), safeEq(notificationShadeDepthController)) verify(dumpManager).registerDumpable(anyString(), eq(notificationShadeDepthController)) } @Test Loading Loading @@ -171,7 +172,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() { @Test fun updateGlobalDialogVisibility_animatesBlur() { notificationShadeDepthController.updateGlobalDialogVisibility(0.5f, root) verify(globalActionsSpring).animateTo(eq(maxBlur / 2), safeEq(root)) verify(globalActionsSpring).animateTo(eq(maxBlur / 2), eq(root)) } @Test Loading @@ -191,8 +192,10 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() { @Test fun updateBlurCallback_setsBlurAndZoom() { notificationShadeDepthController.addListener(listener) notificationShadeDepthController.updateBlurCallback.doFrame(0) verify(wallpaperManager).setWallpaperZoomOut(any(), anyFloat()) verify(listener).onWallpaperZoomOutChanged(anyFloat()) verify(blurUtils).applyBlur(any(), anyInt()) } Loading Loading @@ -245,7 +248,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() { notificationShadeDepthController.updateBlurCallback.doFrame(0) verify(notificationShadeWindowController).setBackgroundBlurRadius(0) verify(blurUtils).applyBlur(safeEq(viewRootImpl), eq(0)) verify(blurUtils).applyBlur(eq(viewRootImpl), eq(0)) } @Test Loading @@ -267,8 +270,4 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() { verify(shadeSpring, never()).animateTo(anyInt(), any()) verify(shadeAnimation, never()).animateTo(anyInt(), any()) } private fun <T : Any> safeEq(value: T): T { return eq(value) ?: value } } No newline at end of file