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

Commit 9c7d4ea7 authored by Shawn Lee's avatar Shawn Lee
Browse files

[flexiglass] Fix HUN placeholder remaining visible after the Shade is opened and closed

In legacy, opening the shade calls HeadsUpManagerPhone.onExpandingFinished (the call comes from NPVC). This leads to the HUN entry being removed, which in flexiglass will trigger the HUN placeholder disappearing. We need to relocate this side-effect to depend on scene state instead, in order to avoid leaving the placeholder and flexiglass visibility in a bad state.

Bug: 357661886
Test: manually verified that notification placeholder and flexiglass are not visible after receiving a HUN, opening shade, and then closing shade.
Test: manually verified with logging that HeadsUpManager entries are updated correctly upon changing scenes.
Flag: com.android.systemui.scene_container
Change-Id: Id78e47f9b384cbf5ffc42c8845d893043d2a0615
parent 86472f4d
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -47,4 +47,7 @@ interface HeadsUpRepository {

    /** Unpin all currently pinned HUNs. */
    fun unpinAll(userUnPinned: Boolean)

    /** Release entries that were waiting for a shade expansion to complete. */
    fun releaseAfterExpansion()
}
+5 −0
Original line number Diff line number Diff line
@@ -153,6 +153,11 @@ constructor(
    fun unpinAll(userUnPinned: Boolean) {
        headsUpRepository.unpinAll(userUnPinned)
    }

    /** Notifies that the current scene transition is idle. */
    fun onTransitionIdle() {
        headsUpRepository.releaseAfterExpansion()
    }
}

class HeadsUpRowInteractor(repository: HeadsUpRowRepository)
+11 −0
Original line number Diff line number Diff line
@@ -16,10 +16,12 @@

package com.android.systemui.statusbar.notification.stack.ui.viewmodel

import com.android.compose.animation.scene.ObservableTransitionState
import com.android.systemui.dump.DumpManager
import com.android.systemui.flags.FeatureFlagsClassic
import com.android.systemui.flags.Flags
import com.android.systemui.lifecycle.SysUiViewModel
import com.android.systemui.scene.domain.interactor.SceneInteractor
import com.android.systemui.scene.shared.flag.SceneContainerFlag
import com.android.systemui.shade.domain.interactor.ShadeInteractor
import com.android.systemui.statusbar.notification.domain.interactor.HeadsUpNotificationInteractor
@@ -33,6 +35,7 @@ import dagger.assisted.AssistedInject
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.launch

/**
@@ -43,6 +46,7 @@ class NotificationsPlaceholderViewModel
@AssistedInject
constructor(
    private val interactor: NotificationStackAppearanceInteractor,
    private val sceneInteractor: SceneInteractor,
    private val shadeInteractor: ShadeInteractor,
    private val headsUpNotificationInteractor: HeadsUpNotificationInteractor,
    featureFlags: FeatureFlagsClassic,
@@ -67,6 +71,13 @@ constructor(
                    .filter { it }
                    .collect { headsUpNotificationInteractor.unpinAll(true) }
            }

            launch {
                sceneInteractor.transitionState
                    .map { state -> state is ObservableTransitionState.Idle }
                    .filter { it }
                    .collect { headsUpNotificationInteractor.onTransitionIdle() }
            }
        }
        activateFlowDumper()
    }
+7 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.plugins.statusbar.StatusBarStateController.StateListener;
import com.android.systemui.res.R;
import com.android.systemui.scene.shared.flag.SceneContainerFlag;
import com.android.systemui.shade.domain.interactor.ShadeInteractor;
import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
@@ -251,6 +252,12 @@ public class HeadsUpManagerPhone extends BaseHeadsUpManager implements
        return entry != null && mSystemClock.elapsedRealtime() < entry.mPostTime;
    }

    @Override
    public void releaseAfterExpansion() {
        if (SceneContainerFlag.isUnexpectedlyInLegacyMode()) return;
        onExpandingFinished();
    }

    public void onExpandingFinished() {
        if (mReleaseOnExpandFinish) {
            releaseAllImmediately();
+4 −0
Original line number Diff line number Diff line
@@ -48,6 +48,10 @@ class FakeHeadsUpNotificationRepository : HeadsUpRepository {
        // do nothing
    }

    override fun releaseAfterExpansion() {
        // do nothing
    }

    fun setNotifications(notifications: List<HeadsUpRowRepository>) {
        this.orderedHeadsUpRows.value = notifications.toList()
    }
Loading