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

Commit 0ecfe53c authored by lyn's avatar lyn
Browse files

Flag guard avalanche changes

Bug: 350797731
Test: HeadsUpManagerPhoneTest
Flag: com.android.systemui.notification_avalanche_throttle_hun
Change-Id: I01889eac4611138aa9e129e5141c505985c92678
parent 7c706ced
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ package com.android.systemui.statusbar.policy

import android.content.Context
import android.os.Handler
import android.platform.test.annotations.EnableFlags
import android.platform.test.flag.junit.FlagsParameterization
import android.testing.TestableLooper.RunWithLooper
import androidx.test.filters.SmallTest
@@ -239,6 +240,7 @@ class HeadsUpManagerPhoneTest(flags: FlagsParameterization) : BaseHeadsUpManager
    }

    @Test
    @EnableFlags(NotificationThrottleHun.FLAG_NAME)
    fun testShowNotification_reorderNotAllowed_notPulsing_seenInShadeTrue() {
        whenever(mVSProvider.isReorderingAllowed).thenReturn(false)
        val hmp = createHeadsUpManagerPhone()
@@ -253,6 +255,7 @@ class HeadsUpManagerPhoneTest(flags: FlagsParameterization) : BaseHeadsUpManager
    }

    @Test
    @EnableFlags(NotificationThrottleHun.FLAG_NAME)
    fun testShowNotification_reorderAllowed_notPulsing_seenInShadeFalse() {
        whenever(mVSProvider.isReorderingAllowed).thenReturn(true)
        val hmp = createHeadsUpManagerPhone()
+2 −1
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@ package com.android.systemui.statusbar.notification.collection.provider

import android.util.ArraySet
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.statusbar.notification.shared.NotificationThrottleHun
import com.android.systemui.util.ListenerSet
import javax.inject.Inject

@@ -21,7 +22,7 @@ class VisualStabilityProvider @Inject constructor() {
                field = value
                if (value) {
                    notifyReorderingAllowed()
                } else {
                } else if (NotificationThrottleHun.isEnabled){
                    banListeners.forEach { listener ->
                        listener.onReorderingBanned()
                    }
+8 −4
Original line number Diff line number Diff line
@@ -111,6 +111,7 @@ import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow
import com.android.systemui.statusbar.notification.row.ExpandableView;
import com.android.systemui.statusbar.notification.row.StackScrollerDecorView;
import com.android.systemui.statusbar.notification.shared.NotificationHeadsUpCycling;
import com.android.systemui.statusbar.notification.shared.NotificationThrottleHun;
import com.android.systemui.statusbar.notification.shared.NotificationsHeadsUpRefactor;
import com.android.systemui.statusbar.notification.shared.NotificationsImprovedHunAnimation;
import com.android.systemui.statusbar.notification.shared.NotificationsLiveDataStoreRefactor;
@@ -4857,10 +4858,13 @@ public class NotificationStackScrollLayout
     * @param isHeadsUp true for appear, false for disappear animations
     */
    public void generateHeadsUpAnimation(ExpandableNotificationRow row, boolean isHeadsUp) {
        boolean addAnimation =
                mAnimationsEnabled && (isHeadsUp || mHeadsUpGoingAwayAnimationsAllowed);
        if (NotificationThrottleHun.isEnabled()) {
            final boolean closedAndSeenInShade = !mIsExpanded && row.getEntry() != null
                    && row.getEntry().isSeenInShade();
        final boolean addAnimation = mAnimationsEnabled && !closedAndSeenInShade &&
                (isHeadsUp || mHeadsUpGoingAwayAnimationsAllowed);
            addAnimation = addAnimation && !closedAndSeenInShade;
        }
        if (SPEW) {
            Log.v(TAG, "generateHeadsUpAnimation:"
                    + " addAnimation=" + addAnimation
+32 −11
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ import com.android.systemui.statusbar.notification.collection.render.GroupMember
import com.android.systemui.statusbar.notification.data.repository.HeadsUpRepository;
import com.android.systemui.statusbar.notification.data.repository.HeadsUpRowRepository;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
import com.android.systemui.statusbar.notification.shared.NotificationThrottleHun;
import com.android.systemui.statusbar.notification.shared.NotificationsHeadsUpRefactor;
import com.android.systemui.statusbar.policy.AccessibilityManagerWrapper;
import com.android.systemui.statusbar.policy.AnimationStateHandler;
@@ -174,10 +175,13 @@ public class HeadsUpManagerPhone extends BaseHeadsUpManager implements
        });
        javaAdapter.alwaysCollectFlow(shadeInteractor.isAnyExpanded(),
                    this::onShadeOrQsExpanded);
        mVisualStabilityProvider.addPersistentReorderingBannedListener(mOnReorderingBannedListener);
        if (NotificationThrottleHun.isEnabled()) {
            mVisualStabilityProvider.addPersistentReorderingBannedListener(
                    mOnReorderingBannedListener);
            mVisualStabilityProvider.addPersistentReorderingAllowedListener(
                    mOnReorderingAllowedListener);
        }
    }

    public void setAnimationStateHandler(AnimationStateHandler handler) {
        mAnimationStateHandler = handler;
@@ -383,7 +387,9 @@ public class HeadsUpManagerPhone extends BaseHeadsUpManager implements

    private final OnReorderingAllowedListener mOnReorderingAllowedListener = () -> {
        mAnimationStateHandler.setHeadsUpGoingAwayAnimationsAllowed(false);
        if (NotificationThrottleHun.isEnabled()) {
            mAvalancheController.setEnableAtRuntime(true);
        }
        for (NotificationEntry entry : mEntriesToRemoveWhenReorderingAllowed) {
            if (isHeadsUpEntry(entry.getKey())) {
                // Maybe the heads-up was removed already
@@ -586,6 +592,7 @@ public class HeadsUpManagerPhone extends BaseHeadsUpManager implements
                @androidx.annotation.Nullable Runnable removeRunnable) {
            super.setEntry(entry, removeRunnable);

            if (NotificationThrottleHun.isEnabled()) {
                if (!mVisualStabilityProvider.isReorderingAllowed()
                        // We don't want to allow reordering while pulsing, but headsup need to
                        // time out anyway
@@ -594,11 +601,20 @@ public class HeadsUpManagerPhone extends BaseHeadsUpManager implements
                    entry.setSeenInShade(true);
                }
            }
        }

        @Override
        protected Runnable createRemoveRunnable(NotificationEntry entry) {
            return () -> {
                if (mTrackingHeadsUp) {
                if (!NotificationThrottleHun.isEnabled()
                        && !mVisualStabilityProvider.isReorderingAllowed()
                        // We don't want to allow reordering while pulsing, but headsup need to
                        // time out anyway
                        && !entry.showingPulsing()) {
                    mEntriesToRemoveWhenReorderingAllowed.add(entry);
                    mVisualStabilityProvider.addTemporaryReorderingAllowedListener(
                            mOnReorderingAllowedListener);
                } else if (mTrackingHeadsUp) {
                    mEntriesToRemoveAfterExpand.add(entry);
                } else if (mVisualStabilityProvider.isReorderingAllowed()
                        || entry.showingPulsing()) {
@@ -614,6 +630,11 @@ public class HeadsUpManagerPhone extends BaseHeadsUpManager implements
            if (mEntriesToRemoveAfterExpand.contains(mEntry)) {
                mEntriesToRemoveAfterExpand.remove(mEntry);
            }
            if (!NotificationThrottleHun.isEnabled()) {
                if (mEntriesToRemoveWhenReorderingAllowed.contains(mEntry)) {
                    mEntriesToRemoveWhenReorderingAllowed.remove(mEntry);
                }
            }
        }

        @Override
+2 −1
Original line number Diff line number Diff line
@@ -91,6 +91,7 @@ import com.android.systemui.statusbar.notification.footer.shared.FooterViewRefac
import com.android.systemui.statusbar.notification.footer.ui.view.FooterView;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
import com.android.systemui.statusbar.notification.row.ExpandableView;
import com.android.systemui.statusbar.notification.shared.NotificationThrottleHun;
import com.android.systemui.statusbar.notification.shared.NotificationsHeadsUpRefactor;
import com.android.systemui.statusbar.phone.KeyguardBypassController;
import com.android.systemui.statusbar.phone.ScreenOffAnimationController;
@@ -1196,7 +1197,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
    }

    @Test
    @EnableFlags(NotificationsHeadsUpRefactor.FLAG_NAME)
    @EnableFlags(NotificationThrottleHun.FLAG_NAME)
    public void testGenerateHeadsUpAnimation_isSeenInShade_noAnimation() {
        // GIVEN NSSL is ready for HUN animations
        Consumer<Boolean> headsUpAnimatingAwayListener = mock(BooleanConsumer.class);