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

Commit 552ce28c authored by Lyn Han's avatar Lyn Han Committed by Automerger Merge Worker
Browse files

Merge "Restore notification stack updates during lockscreen-to-shade" into tm-dev am: 022f4485

parents c34c64c9 022f4485
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -72,6 +72,9 @@ class LockscreenShadeTransitionController @Inject constructor(
    dumpManager: DumpManager
) : Dumpable {
    private var pulseHeight: Float = 0f
    @get:VisibleForTesting
    var fractionToShade: Float = 0f
        private set
    private var useSplitShade: Boolean = false
    private lateinit var nsslController: NotificationStackScrollLayoutController
    lateinit var notificationPanelController: NotificationPanelViewController
@@ -405,9 +408,9 @@ class LockscreenShadeTransitionController @Inject constructor(
            if (field != value || forceApplyAmount) {
                field = value
                if (!nsslController.isInLockedDownShade() || field == 0f || forceApplyAmount) {
                    val notificationShelfProgress =
                    fractionToShade =
                        MathUtils.saturate(dragDownAmount / notificationShelfTransitionDistance)
                    nsslController.setTransitionToFullShadeAmount(notificationShelfProgress)
                    nsslController.setTransitionToFullShadeAmount(fractionToShade)

                    qSDragProgress = MathUtils.saturate(dragDownAmount / qsTransitionDistance)
                    qS.setTransitionToFullShadeAmount(field, qSDragProgress)
+16 −7
Original line number Diff line number Diff line
@@ -19,9 +19,11 @@ package com.android.systemui.statusbar.notification.stack
import android.content.res.Resources
import android.util.Log
import android.view.View.GONE
import androidx.annotation.VisibleForTesting
import com.android.systemui.R
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.statusbar.LockscreenShadeTransitionController
import com.android.systemui.statusbar.StatusBarState.KEYGUARD
import com.android.systemui.statusbar.SysuiStatusBarStateController
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow
@@ -41,6 +43,7 @@ class NotificationStackSizeCalculator
@Inject
constructor(
    private val statusBarStateController: SysuiStatusBarStateController,
    private val lockscreenShadeTransitionController: LockscreenShadeTransitionController,
    @Main private val resources: Resources
) {

@@ -129,7 +132,7 @@ constructor(
        yield(dividerHeight + shelfIntrinsicHeight) // Only shelf.

        children.forEachIndexed { i, currentNotification ->
            height += currentNotification.spaceNeeded(i, previous, stack, onLockscreen)
            height += spaceNeeded(currentNotification, i, previous, stack, onLockscreen)
            previous = currentNotification

            val shelfHeight =
@@ -156,22 +159,28 @@ constructor(
    private val NotificationStackScrollLayout.childrenSequence: Sequence<ExpandableView>
        get() = children.map { it as ExpandableView }

    private fun onLockscreen() = statusBarStateController.state == KEYGUARD
    @VisibleForTesting
    fun onLockscreen() : Boolean {
        return statusBarStateController.state == KEYGUARD
                && lockscreenShadeTransitionController.fractionToShade == 0f
    }

    private fun ExpandableView.spaceNeeded(
    @VisibleForTesting
    fun spaceNeeded(
        view: ExpandableView,
        visibleIndex: Int,
        previousView: ExpandableView?,
        stack: NotificationStackScrollLayout,
        onLockscreen: Boolean
    ): Float {
        assert(isShowable(onLockscreen))
        assert(view.isShowable(onLockscreen))
        var size =
            if (onLockscreen) {
                getMinHeight(/* ignoreTemporaryStates= */ true).toFloat()
                view.getMinHeight(/* ignoreTemporaryStates= */ true).toFloat()
            } else {
                intrinsicHeight.toFloat()
                view.intrinsicHeight.toFloat()
            }
        size += calculateGapAndDividerHeight(stack, previousView, current = this, visibleIndex)
        size += calculateGapAndDividerHeight(stack, previousView, current = view, visibleIndex)
        return size
    }

+53 −1
Original line number Diff line number Diff line
@@ -23,6 +23,8 @@ import android.view.View.VISIBLE
import androidx.test.filters.SmallTest
import com.android.systemui.R
import com.android.systemui.SysuiTestCase
import com.android.systemui.statusbar.LockscreenShadeTransitionController
import com.android.systemui.statusbar.StatusBarState
import com.android.systemui.statusbar.SysuiStatusBarStateController
import com.android.systemui.statusbar.notification.collection.NotificationEntry
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow
@@ -44,7 +46,7 @@ import org.mockito.MockitoAnnotations
class NotificationStackSizeCalculatorTest : SysuiTestCase() {

    @Mock private lateinit var sysuiStatusBarStateController: SysuiStatusBarStateController

    @Mock private lateinit var lockscreenShadeTransitionController: LockscreenShadeTransitionController
    @Mock private lateinit var stackLayout: NotificationStackScrollLayout

    private val testableResources = mContext.getOrCreateTestableResources()
@@ -63,6 +65,7 @@ class NotificationStackSizeCalculatorTest : SysuiTestCase() {
        sizeCalculator =
            NotificationStackSizeCalculator(
                statusBarStateController = sysuiStatusBarStateController,
                lockscreenShadeTransitionController = lockscreenShadeTransitionController,
                testableResources.resources)
    }

@@ -155,6 +158,55 @@ class NotificationStackSizeCalculatorTest : SysuiTestCase() {
        assertThat(height).isAtMost(availableSpace)
    }

    @Test
    fun onLockscreen_onKeyguard_AndNotGoingToShade_returnsTrue() {
        whenever(sysuiStatusBarStateController.state).thenReturn(StatusBarState.KEYGUARD)
        whenever(lockscreenShadeTransitionController.fractionToShade).thenReturn(0f)
        assertThat(sizeCalculator.onLockscreen()).isTrue()
    }

    @Test
    fun onLockscreen_goingToShade_returnsFalse() {
        whenever(sysuiStatusBarStateController.state).thenReturn(StatusBarState.KEYGUARD)
        whenever(lockscreenShadeTransitionController.fractionToShade).thenReturn(0.5f)
        assertThat(sizeCalculator.onLockscreen()).isFalse()
    }

    @Test
    fun onLockscreen_notOnLockscreen_returnsFalse() {
        whenever(sysuiStatusBarStateController.state).thenReturn(StatusBarState.SHADE)
        whenever(lockscreenShadeTransitionController.fractionToShade).thenReturn(1f)
        assertThat(sizeCalculator.onLockscreen()).isFalse()
    }

    @Test
    fun spaceNeeded_onLockscreen_usesMinHeight() {
        setGapHeight(0f)
        // No divider height since we're testing one element where index = 0

        val expandableView = createMockRow(rowHeight)
        whenever(expandableView.getMinHeight(any())).thenReturn(5)
        whenever(expandableView.intrinsicHeight).thenReturn(10)

        val space = sizeCalculator.spaceNeeded(expandableView, visibleIndex = 0,
                previousView = null, stack = stackLayout, onLockscreen = true)
        assertThat(space).isEqualTo(5)
    }

    @Test
    fun spaceNeeded_notOnLockscreen_usesIntrinsicHeight() {
        setGapHeight(0f)
        // No divider height since we're testing one element where index = 0

        val expandableView = createMockRow(rowHeight)
        whenever(expandableView.getMinHeight(any())).thenReturn(5)
        whenever(expandableView.intrinsicHeight).thenReturn(10)

        val space = sizeCalculator.spaceNeeded(expandableView, visibleIndex = 0,
                previousView = null, stack = stackLayout, onLockscreen = false)
        assertThat(space).isEqualTo(10)
    }

    private fun computeMaxKeyguardNotifications(
        rows: List<ExpandableView>,
        availableSpace: Float,