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

Commit 098991b9 authored by Lucas Dupin's avatar Lucas Dupin Committed by Android (Google) Code Review
Browse files

Merge "Do not set wallpaper zoom on non-attached window"

parents be54745c 728b5280
Loading
Loading
Loading
Loading
+5 −1
Original line number Original line Diff line number Diff line
@@ -189,7 +189,11 @@ class NotificationShadeDepthController @Inject constructor(
        blurUtils.applyBlur(blurRoot?.viewRootImpl ?: root.viewRootImpl, blur)
        blurUtils.applyBlur(blurRoot?.viewRootImpl ?: root.viewRootImpl, blur)
        val zoomOut = blurUtils.ratioOfBlurRadius(blur)
        val zoomOut = blurUtils.ratioOfBlurRadius(blur)
        try {
        try {
            if (root.isAttachedToWindow) {
                wallpaperManager.setWallpaperZoomOut(root.windowToken, zoomOut)
                wallpaperManager.setWallpaperZoomOut(root.windowToken, zoomOut)
            } else {
                Log.i(TAG, "Won't set zoom. Window not attached $root")
            }
        } catch (e: IllegalArgumentException) {
        } catch (e: IllegalArgumentException) {
            Log.w(TAG, "Can't set zoom. Window is gone: ${root.windowToken}", e)
            Log.w(TAG, "Can't set zoom. Window is gone: ${root.windowToken}", e)
        }
        }
+9 −0
Original line number Original line Diff line number Diff line
@@ -45,6 +45,7 @@ import org.mockito.Mockito.anyString
import org.mockito.Mockito.clearInvocations
import org.mockito.Mockito.clearInvocations
import org.mockito.Mockito.doThrow
import org.mockito.Mockito.doThrow
import org.mockito.Mockito.never
import org.mockito.Mockito.never
import org.mockito.Mockito.times
import org.mockito.Mockito.verify
import org.mockito.Mockito.verify
import org.mockito.junit.MockitoJUnit
import org.mockito.junit.MockitoJUnit


@@ -79,6 +80,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
    @Before
    @Before
    fun setup() {
    fun setup() {
        `when`(root.viewRootImpl).thenReturn(viewRootImpl)
        `when`(root.viewRootImpl).thenReturn(viewRootImpl)
        `when`(root.isAttachedToWindow).thenReturn(true)
        `when`(statusBarStateController.state).then { statusBarState }
        `when`(statusBarStateController.state).then { statusBarState }
        `when`(blurUtils.blurRadiusOfRatio(anyFloat())).then { answer ->
        `when`(blurUtils.blurRadiusOfRatio(anyFloat())).then { answer ->
            (answer.arguments[0] as Float * maxBlur).toInt()
            (answer.arguments[0] as Float * maxBlur).toInt()
@@ -219,6 +221,13 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {


    @Test
    @Test
    fun updateBlurCallback_invalidWindow() {
    fun updateBlurCallback_invalidWindow() {
        `when`(root.isAttachedToWindow).thenReturn(false)
        notificationShadeDepthController.updateBlurCallback.doFrame(0)
        verify(wallpaperManager, times(0)).setWallpaperZoomOut(any(), anyFloat())
    }

    @Test
    fun updateBlurCallback_exception() {
        doThrow(IllegalArgumentException("test exception")).`when`(wallpaperManager)
        doThrow(IllegalArgumentException("test exception")).`when`(wallpaperManager)
                .setWallpaperZoomOut(any(), anyFloat())
                .setWallpaperZoomOut(any(), anyFloat())
        notificationShadeDepthController.updateBlurCallback.doFrame(0)
        notificationShadeDepthController.updateBlurCallback.doFrame(0)