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

Commit 31c421da authored by Matt Pietal's avatar Matt Pietal
Browse files

Recalculate max notifications on lockscreen

NSSL has a listener that will be invoked when a notification changes,
and can be used to recalculate the number of notifications to show on
lockscreen. Use this signal to emit an event for the view model to
use.

Fixes: 296606746
Test: atest SharedNotificationContainerViewModelTest
Test: use Notify apk to add delayed notifications, ensure it stays to
the bounds
Flag: LEGACY MIGRATE_NSSL DISABLED

Change-Id: I7b59b56d167d2dec12761bda80fbea27f74bf239
parent 164b9b2e
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -30,6 +30,7 @@ import com.android.systemui.keyguard.ui.viewmodel.KeyguardSmartspaceViewModel
import com.android.systemui.res.R
import com.android.systemui.res.R
import com.android.systemui.shade.NotificationPanelView
import com.android.systemui.shade.NotificationPanelView
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController
import com.android.systemui.statusbar.notification.stack.NotificationStackSizeCalculator
import com.android.systemui.statusbar.notification.stack.ui.view.SharedNotificationContainer
import com.android.systemui.statusbar.notification.stack.ui.view.SharedNotificationContainer
import com.android.systemui.statusbar.notification.stack.ui.viewmodel.SharedNotificationContainerViewModel
import com.android.systemui.statusbar.notification.stack.ui.viewmodel.SharedNotificationContainerViewModel
import javax.inject.Inject
import javax.inject.Inject
@@ -44,6 +45,7 @@ constructor(
    sharedNotificationContainer: SharedNotificationContainer,
    sharedNotificationContainer: SharedNotificationContainer,
    sharedNotificationContainerViewModel: SharedNotificationContainerViewModel,
    sharedNotificationContainerViewModel: SharedNotificationContainerViewModel,
    controller: NotificationStackScrollLayoutController,
    controller: NotificationStackScrollLayoutController,
    notificationStackSizeCalculator: NotificationStackSizeCalculator,
    private val smartspaceViewModel: KeyguardSmartspaceViewModel,
    private val smartspaceViewModel: KeyguardSmartspaceViewModel,
) :
) :
    NotificationStackScrollLayoutSection(
    NotificationStackScrollLayoutSection(
@@ -53,6 +55,7 @@ constructor(
        sharedNotificationContainer,
        sharedNotificationContainer,
        sharedNotificationContainerViewModel,
        sharedNotificationContainerViewModel,
        controller,
        controller,
        notificationStackSizeCalculator,
    ) {
    ) {
    override fun applyConstraints(constraintSet: ConstraintSet) {
    override fun applyConstraints(constraintSet: ConstraintSet) {
        if (!featureFlags.isEnabled(Flags.MIGRATE_NSSL)) {
        if (!featureFlags.isEnabled(Flags.MIGRATE_NSSL)) {
+3 −0
Original line number Original line Diff line number Diff line
@@ -27,6 +27,7 @@ import com.android.systemui.keyguard.shared.model.KeyguardSection
import com.android.systemui.res.R
import com.android.systemui.res.R
import com.android.systemui.shade.NotificationPanelView
import com.android.systemui.shade.NotificationPanelView
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController
import com.android.systemui.statusbar.notification.stack.NotificationStackSizeCalculator
import com.android.systemui.statusbar.notification.stack.ui.view.SharedNotificationContainer
import com.android.systemui.statusbar.notification.stack.ui.view.SharedNotificationContainer
import com.android.systemui.statusbar.notification.stack.ui.viewbinder.SharedNotificationContainerBinder
import com.android.systemui.statusbar.notification.stack.ui.viewbinder.SharedNotificationContainerBinder
import com.android.systemui.statusbar.notification.stack.ui.viewmodel.SharedNotificationContainerViewModel
import com.android.systemui.statusbar.notification.stack.ui.viewmodel.SharedNotificationContainerViewModel
@@ -40,6 +41,7 @@ constructor(
    private val sharedNotificationContainer: SharedNotificationContainer,
    private val sharedNotificationContainer: SharedNotificationContainer,
    private val sharedNotificationContainerViewModel: SharedNotificationContainerViewModel,
    private val sharedNotificationContainerViewModel: SharedNotificationContainerViewModel,
    private val controller: NotificationStackScrollLayoutController,
    private val controller: NotificationStackScrollLayoutController,
    private val notificationStackSizeCalculator: NotificationStackSizeCalculator,
) : KeyguardSection() {
) : KeyguardSection() {
    private val placeHolderId = R.id.nssl_placeholder
    private val placeHolderId = R.id.nssl_placeholder
    private var disposableHandle: DisposableHandle? = null
    private var disposableHandle: DisposableHandle? = null
@@ -69,6 +71,7 @@ constructor(
                sharedNotificationContainer,
                sharedNotificationContainer,
                sharedNotificationContainerViewModel,
                sharedNotificationContainerViewModel,
                controller,
                controller,
                notificationStackSizeCalculator,
            )
            )
    }
    }


+3 −0
Original line number Original line Diff line number Diff line
@@ -30,6 +30,7 @@ import com.android.systemui.keyguard.ui.viewmodel.KeyguardSmartspaceViewModel
import com.android.systemui.res.R
import com.android.systemui.res.R
import com.android.systemui.shade.NotificationPanelView
import com.android.systemui.shade.NotificationPanelView
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController
import com.android.systemui.statusbar.notification.stack.NotificationStackSizeCalculator
import com.android.systemui.statusbar.notification.stack.ui.view.SharedNotificationContainer
import com.android.systemui.statusbar.notification.stack.ui.view.SharedNotificationContainer
import com.android.systemui.statusbar.notification.stack.ui.viewmodel.SharedNotificationContainerViewModel
import com.android.systemui.statusbar.notification.stack.ui.viewmodel.SharedNotificationContainerViewModel
import javax.inject.Inject
import javax.inject.Inject
@@ -44,6 +45,7 @@ constructor(
    sharedNotificationContainer: SharedNotificationContainer,
    sharedNotificationContainer: SharedNotificationContainer,
    sharedNotificationContainerViewModel: SharedNotificationContainerViewModel,
    sharedNotificationContainerViewModel: SharedNotificationContainerViewModel,
    controller: NotificationStackScrollLayoutController,
    controller: NotificationStackScrollLayoutController,
    notificationStackSizeCalculator: NotificationStackSizeCalculator,
    private val smartspaceViewModel: KeyguardSmartspaceViewModel,
    private val smartspaceViewModel: KeyguardSmartspaceViewModel,
) :
) :
    NotificationStackScrollLayoutSection(
    NotificationStackScrollLayoutSection(
@@ -53,6 +55,7 @@ constructor(
        sharedNotificationContainer,
        sharedNotificationContainer,
        sharedNotificationContainerViewModel,
        sharedNotificationContainerViewModel,
        controller,
        controller,
        notificationStackSizeCalculator,
    ) {
    ) {
    override fun applyConstraints(constraintSet: ConstraintSet) {
    override fun applyConstraints(constraintSet: ConstraintSet) {
        if (!featureFlags.isEnabled(Flags.MIGRATE_NSSL)) {
        if (!featureFlags.isEnabled(Flags.MIGRATE_NSSL)) {
+4 −4
Original line number Original line Diff line number Diff line
@@ -1483,16 +1483,16 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
    }
    }


    private void updateMaxDisplayedNotifications(boolean recompute) {
    private void updateMaxDisplayedNotifications(boolean recompute) {
        if (mFeatureFlags.isEnabled(Flags.MIGRATE_NSSL)) {
            return;
        }

        if (recompute) {
        if (recompute) {
            setMaxDisplayedNotifications(Math.max(computeMaxKeyguardNotifications(), 1));
            setMaxDisplayedNotifications(Math.max(computeMaxKeyguardNotifications(), 1));
        } else {
        } else {
            if (SPEW_LOGCAT) Log.d(TAG, "Skipping computeMaxKeyguardNotifications() by request");
            if (SPEW_LOGCAT) Log.d(TAG, "Skipping computeMaxKeyguardNotifications() by request");
        }
        }


        if (mFeatureFlags.isEnabled(Flags.MIGRATE_NSSL)) {
            return;
        }

        if (isKeyguardShowing() && !mKeyguardBypassController.getBypassEnabled()) {
        if (isKeyguardShowing() && !mKeyguardBypassController.getBypassEnabled()) {
            mNotificationStackScrollLayoutController.setMaxDisplayedNotifications(
            mNotificationStackScrollLayoutController.setMaxDisplayedNotifications(
                    mMaxAllowedKeyguardNotifications);
                    mMaxAllowedKeyguardNotifications);
+14 −0
Original line number Original line Diff line number Diff line
@@ -65,6 +65,10 @@ interface ShadeRepository {
     */
     */
    @Deprecated("Use ShadeInteractor instead") val legacyShadeTracking: StateFlow<Boolean>
    @Deprecated("Use ShadeInteractor instead") val legacyShadeTracking: StateFlow<Boolean>


    /** Specifically tracks the user expanding the shade on the lockscreen only */
    @Deprecated("Use ShadeInteractor.isUserInteractingWithShade instead")
    val legacyLockscreenShadeTracking: MutableStateFlow<Boolean>

    /**
    /**
     * QuickSettingsController.mTracking as a flow. "Tracking" means that the user is moving quick
     * QuickSettingsController.mTracking as a flow. "Tracking" means that the user is moving quick
     * settings up or down with a pointer. Going forward, this concept will be replaced by checks
     * settings up or down with a pointer. Going forward, this concept will be replaced by checks
@@ -106,6 +110,9 @@ interface ShadeRepository {
    /** Sets whether the user is moving the shade with a pointer */
    /** Sets whether the user is moving the shade with a pointer */
    fun setLegacyShadeTracking(tracking: Boolean)
    fun setLegacyShadeTracking(tracking: Boolean)


    /** Sets whether the user is moving the shade with a pointer, on lockscreen only */
    fun setLegacyLockscreenShadeTracking(tracking: Boolean)

    /** Amount shade has expanded with regard to the UDFPS location */
    /** Amount shade has expanded with regard to the UDFPS location */
    val udfpsTransitionToFullShadeProgress: StateFlow<Float>
    val udfpsTransitionToFullShadeProgress: StateFlow<Float>


@@ -177,6 +184,8 @@ constructor(shadeExpansionStateManager: ShadeExpansionStateManager) : ShadeRepos
    @Deprecated("Use ShadeInteractor instead")
    @Deprecated("Use ShadeInteractor instead")
    override val legacyShadeTracking: StateFlow<Boolean> = _legacyShadeTracking.asStateFlow()
    override val legacyShadeTracking: StateFlow<Boolean> = _legacyShadeTracking.asStateFlow()


    override val legacyLockscreenShadeTracking = MutableStateFlow(false)

    private val _legacyQsTracking = MutableStateFlow(false)
    private val _legacyQsTracking = MutableStateFlow(false)
    @Deprecated("Use ShadeInteractor instead")
    @Deprecated("Use ShadeInteractor instead")
    override val legacyQsTracking: StateFlow<Boolean> = _legacyQsTracking.asStateFlow()
    override val legacyQsTracking: StateFlow<Boolean> = _legacyQsTracking.asStateFlow()
@@ -212,6 +221,11 @@ constructor(shadeExpansionStateManager: ShadeExpansionStateManager) : ShadeRepos
        _legacyShadeTracking.value = tracking
        _legacyShadeTracking.value = tracking
    }
    }


    @Deprecated("Should only be called by NPVC and tests")
    override fun setLegacyLockscreenShadeTracking(tracking: Boolean) {
        legacyLockscreenShadeTracking.value = tracking
    }

    override fun setQsExpansion(qsExpansion: Float) {
    override fun setQsExpansion(qsExpansion: Float) {
        _qsExpansion.value = qsExpansion
        _qsExpansion.value = qsExpansion
    }
    }
Loading