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

Commit f990c4e2 authored by Behnam Heydarshahi's avatar Behnam Heydarshahi Committed by Android (Google) Code Review
Browse files

Revert^2 "ShadeHeaderCtrl: only apply new window insets"

This reverts commit e29ee218.

Reason for revert: jank introduced in b/410205946

Change-Id: I583bb58ea3ea2abb1e88af036397394509513ecf
parent e29ee218
Loading
Loading
Loading
Loading
+11 −4
Original line number Original line Diff line number Diff line
@@ -222,10 +222,14 @@ constructor(


    private val insetListener =
    private val insetListener =
        View.OnApplyWindowInsetsListener { view, insets ->
        View.OnApplyWindowInsetsListener { view, insets ->
            val windowInsets = WindowInsets(insets)
            if (windowInsets != lastInsets) {
                updateConstraintsForInsets(view as MotionLayout, insets)
                updateConstraintsForInsets(view as MotionLayout, insets)
            lastInsets = WindowInsets(insets)
                lastInsets = windowInsets

                view.onApplyWindowInsets(insets)
                view.onApplyWindowInsets(insets)
            } else {
                insets
            }
        }
        }


    private var singleCarrier = false
    private var singleCarrier = false
@@ -508,6 +512,9 @@ constructor(
            systemIconsHoverContainer.setOnClickListener(null)
            systemIconsHoverContainer.setOnClickListener(null)
            systemIconsHoverContainer.isClickable = false
            systemIconsHoverContainer.isClickable = false
        }
        }

        lastInsets?.let { updateConstraintsForInsets(header, it) }

        header.jumpToState(header.startState)
        header.jumpToState(header.startState)
        updatePosition()
        updatePosition()
        updateScrollY()
        updateScrollY()
+37 −0
Original line number Original line Diff line number Diff line
@@ -808,6 +808,43 @@ class ShadeHeaderControllerTest : SysuiTestCase() {
        verify(mockConstraintsChanges.largeScreenConstraintsChanges)!!.invoke(any())
        verify(mockConstraintsChanges.largeScreenConstraintsChanges)!!.invoke(any())
    }
    }


    @Test
    fun sameInsetsTwice_listenerCallsOnApplyWindowInsetsOnlyOnce() {
        val windowInsets = createWindowInsets()

        val captor = ArgumentCaptor.forClass(View.OnApplyWindowInsetsListener::class.java)
        verify(view).setOnApplyWindowInsetsListener(capture(captor))

        val listener = captor.value

        listener.onApplyWindowInsets(view, windowInsets)

        verify(view, times(1)).onApplyWindowInsets(any())

        listener.onApplyWindowInsets(view, windowInsets)

        verify(view, times(1)).onApplyWindowInsets(any())
    }

    @Test
    fun twoDifferentInsets_listenerCallsOnApplyWindowInsetsTwice() {
        val windowInsets1 = WindowInsets(Rect(1, 2, 3, 4))
        val windowInsets2 = WindowInsets(Rect(5, 6, 7, 8))

        val captor = ArgumentCaptor.forClass(View.OnApplyWindowInsetsListener::class.java)
        verify(view).setOnApplyWindowInsetsListener(capture(captor))

        val listener = captor.value

        listener.onApplyWindowInsets(view, windowInsets1)

        verify(view, times(1)).onApplyWindowInsets(any())

        listener.onApplyWindowInsets(view, windowInsets2)

        verify(view, times(2)).onApplyWindowInsets(any())
    }

    @Test
    @Test
    fun alarmIconNotIgnored() {
    fun alarmIconNotIgnored() {
        verify(statusIcons, Mockito.never())
        verify(statusIcons, Mockito.never())