Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/policy/AvalancheControllerTest.kt +17 −0 Original line number Diff line number Diff line Loading @@ -179,6 +179,23 @@ class AvalancheControllerTest : SysuiTestCase() { assertThat(mAvalancheController.nextMap.containsKey(headsUpEntry)).isTrue() } @Test fun testDelete_untracked_runnableRuns() { val headsUpEntry = createHeadsUpEntry(id = 0) // None showing mAvalancheController.headsUpEntryShowing = null // Nothing is next mAvalancheController.clearNext() // Delete mAvalancheController.delete(headsUpEntry, runnableMock!!, "testLabel") // Runnable was run Mockito.verify(runnableMock, Mockito.times(1)).run() } @Test fun testDelete_isNext_removedFromNext_runnableNotRun() { // Entry is next Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/policy/HeadsUpManagerPhoneTest.kt +30 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import com.android.systemui.statusbar.StatusBarState import com.android.systemui.statusbar.notification.collection.NotificationEntry import com.android.systemui.statusbar.notification.collection.provider.VisualStabilityProvider import com.android.systemui.statusbar.notification.collection.render.GroupMembershipManager 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.phone.ConfigurationControllerImpl Loading @@ -42,6 +43,7 @@ import com.android.systemui.testKosmos import com.android.systemui.util.concurrency.DelayableExecutor import com.android.systemui.util.concurrency.mockExecutorHandler import com.android.systemui.util.kotlin.JavaAdapter import com.android.systemui.util.mockito.mock import com.android.systemui.util.settings.GlobalSettings import com.android.systemui.util.time.SystemClock import junit.framework.Assert Loading Loading @@ -236,6 +238,34 @@ class HeadsUpManagerPhoneTest(flags: FlagsParameterization) : BaseHeadsUpManager Assert.assertTrue(hmp.isHeadsUpEntry(entry.key)) } @Test fun testShowNotification_reorderNotAllowed_notPulsing_seenInShadeTrue() { whenever(mVSProvider.isReorderingAllowed).thenReturn(false) val hmp = createHeadsUpManagerPhone() val notifEntry = HeadsUpManagerTestUtil.createEntry(/* id= */ 0, mContext) val row = mock<ExpandableNotificationRow>() whenever(row.showingPulsing()).thenReturn(false) notifEntry.row = row hmp.showNotification(notifEntry) Assert.assertTrue(notifEntry.isSeenInShade) } @Test fun testShowNotification_reorderAllowed_notPulsing_seenInShadeFalse() { whenever(mVSProvider.isReorderingAllowed).thenReturn(true) val hmp = createHeadsUpManagerPhone() val notifEntry = HeadsUpManagerTestUtil.createEntry(/* id= */ 0, mContext) val row = mock<ExpandableNotificationRow>() whenever(row.showingPulsing()).thenReturn(false) notifEntry.row = row hmp.showNotification(notifEntry) Assert.assertFalse(notifEntry.isSeenInShade) } @Test fun shouldHeadsUpBecomePinned_shadeNotExpanded_true() = testScope.runTest { Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java +10 −0 Original line number Diff line number Diff line Loading @@ -1005,6 +1005,16 @@ public final class NotificationEntry extends ListEntry implements NotificationRo mIsMarkedForUserTriggeredMovement = marked; } private boolean mSeenInShade = false; public void setSeenInShade(boolean seen) { mSeenInShade = seen; } public boolean isSeenInShade() { return mSeenInShade; } public void setIsHeadsUpEntry(boolean isHeadsUpEntry) { mIsHeadsUpEntry = isHeadsUpEntry; } Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/provider/VisualStabilityProvider.kt +14 −0 Original line number Diff line number Diff line Loading @@ -13,12 +13,18 @@ class VisualStabilityProvider @Inject constructor() { /** The subset of active listeners which are temporary (will be removed after called) */ private val temporaryListeners = ArraySet<OnReorderingAllowedListener>() private val banListeners = ListenerSet<OnReorderingBannedListener>() var isReorderingAllowed = true set(value) { if (field != value) { field = value if (value) { notifyReorderingAllowed() } else { banListeners.forEach { listener -> listener.onReorderingBanned() } } } } Loading @@ -38,6 +44,10 @@ class VisualStabilityProvider @Inject constructor() { allListeners.addIfAbsent(listener) } fun addPersistentReorderingBannedListener(listener: OnReorderingBannedListener) { banListeners.addIfAbsent(listener) } /** Add a listener which will be removed when it is called. */ fun addTemporaryReorderingAllowedListener(listener: OnReorderingAllowedListener) { // Only add to the temporary set if it was added to the global set Loading @@ -57,3 +67,7 @@ class VisualStabilityProvider @Inject constructor() { fun interface OnReorderingAllowedListener { fun onReorderingAllowed() } fun interface OnReorderingBannedListener { fun onReorderingBanned() } No newline at end of file packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java +12 −6 Original line number Diff line number Diff line Loading @@ -4862,14 +4862,20 @@ public class NotificationStackScrollLayout * @param isHeadsUp true for appear, false for disappear animations */ public void generateHeadsUpAnimation(ExpandableNotificationRow row, boolean isHeadsUp) { final boolean add = mAnimationsEnabled && (isHeadsUp || mHeadsUpGoingAwayAnimationsAllowed); final boolean closedAndSeenInShade = !mIsExpanded && row.getEntry() != null && row.getEntry().isSeenInShade(); final boolean addAnimation = mAnimationsEnabled && !closedAndSeenInShade && (isHeadsUp || mHeadsUpGoingAwayAnimationsAllowed); if (SPEW) { Log.v(TAG, "generateHeadsUpAnimation:" + " willAdd=" + add + " isHeadsUp=" + isHeadsUp + " row=" + row.getEntry().getKey()); } if (add) { + " addAnimation=" + addAnimation + (row.getEntry() == null ? " entry NULL " : " isSeenInShade=" + row.getEntry().isSeenInShade() + " row=" + row.getEntry().getKey()) + " mIsExpanded=" + mIsExpanded + " isHeadsUp=" + isHeadsUp); } if (addAnimation) { // If we're hiding a HUN we just started showing THIS FRAME, then remove that event, // and do not add the disappear event either. if (!isHeadsUp && mHeadsUpChangeAnimations.remove(new Pair<>(row, true))) { Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/policy/AvalancheControllerTest.kt +17 −0 Original line number Diff line number Diff line Loading @@ -179,6 +179,23 @@ class AvalancheControllerTest : SysuiTestCase() { assertThat(mAvalancheController.nextMap.containsKey(headsUpEntry)).isTrue() } @Test fun testDelete_untracked_runnableRuns() { val headsUpEntry = createHeadsUpEntry(id = 0) // None showing mAvalancheController.headsUpEntryShowing = null // Nothing is next mAvalancheController.clearNext() // Delete mAvalancheController.delete(headsUpEntry, runnableMock!!, "testLabel") // Runnable was run Mockito.verify(runnableMock, Mockito.times(1)).run() } @Test fun testDelete_isNext_removedFromNext_runnableNotRun() { // Entry is next Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/policy/HeadsUpManagerPhoneTest.kt +30 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import com.android.systemui.statusbar.StatusBarState import com.android.systemui.statusbar.notification.collection.NotificationEntry import com.android.systemui.statusbar.notification.collection.provider.VisualStabilityProvider import com.android.systemui.statusbar.notification.collection.render.GroupMembershipManager 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.phone.ConfigurationControllerImpl Loading @@ -42,6 +43,7 @@ import com.android.systemui.testKosmos import com.android.systemui.util.concurrency.DelayableExecutor import com.android.systemui.util.concurrency.mockExecutorHandler import com.android.systemui.util.kotlin.JavaAdapter import com.android.systemui.util.mockito.mock import com.android.systemui.util.settings.GlobalSettings import com.android.systemui.util.time.SystemClock import junit.framework.Assert Loading Loading @@ -236,6 +238,34 @@ class HeadsUpManagerPhoneTest(flags: FlagsParameterization) : BaseHeadsUpManager Assert.assertTrue(hmp.isHeadsUpEntry(entry.key)) } @Test fun testShowNotification_reorderNotAllowed_notPulsing_seenInShadeTrue() { whenever(mVSProvider.isReorderingAllowed).thenReturn(false) val hmp = createHeadsUpManagerPhone() val notifEntry = HeadsUpManagerTestUtil.createEntry(/* id= */ 0, mContext) val row = mock<ExpandableNotificationRow>() whenever(row.showingPulsing()).thenReturn(false) notifEntry.row = row hmp.showNotification(notifEntry) Assert.assertTrue(notifEntry.isSeenInShade) } @Test fun testShowNotification_reorderAllowed_notPulsing_seenInShadeFalse() { whenever(mVSProvider.isReorderingAllowed).thenReturn(true) val hmp = createHeadsUpManagerPhone() val notifEntry = HeadsUpManagerTestUtil.createEntry(/* id= */ 0, mContext) val row = mock<ExpandableNotificationRow>() whenever(row.showingPulsing()).thenReturn(false) notifEntry.row = row hmp.showNotification(notifEntry) Assert.assertFalse(notifEntry.isSeenInShade) } @Test fun shouldHeadsUpBecomePinned_shadeNotExpanded_true() = testScope.runTest { Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java +10 −0 Original line number Diff line number Diff line Loading @@ -1005,6 +1005,16 @@ public final class NotificationEntry extends ListEntry implements NotificationRo mIsMarkedForUserTriggeredMovement = marked; } private boolean mSeenInShade = false; public void setSeenInShade(boolean seen) { mSeenInShade = seen; } public boolean isSeenInShade() { return mSeenInShade; } public void setIsHeadsUpEntry(boolean isHeadsUpEntry) { mIsHeadsUpEntry = isHeadsUpEntry; } Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/provider/VisualStabilityProvider.kt +14 −0 Original line number Diff line number Diff line Loading @@ -13,12 +13,18 @@ class VisualStabilityProvider @Inject constructor() { /** The subset of active listeners which are temporary (will be removed after called) */ private val temporaryListeners = ArraySet<OnReorderingAllowedListener>() private val banListeners = ListenerSet<OnReorderingBannedListener>() var isReorderingAllowed = true set(value) { if (field != value) { field = value if (value) { notifyReorderingAllowed() } else { banListeners.forEach { listener -> listener.onReorderingBanned() } } } } Loading @@ -38,6 +44,10 @@ class VisualStabilityProvider @Inject constructor() { allListeners.addIfAbsent(listener) } fun addPersistentReorderingBannedListener(listener: OnReorderingBannedListener) { banListeners.addIfAbsent(listener) } /** Add a listener which will be removed when it is called. */ fun addTemporaryReorderingAllowedListener(listener: OnReorderingAllowedListener) { // Only add to the temporary set if it was added to the global set Loading @@ -57,3 +67,7 @@ class VisualStabilityProvider @Inject constructor() { fun interface OnReorderingAllowedListener { fun onReorderingAllowed() } fun interface OnReorderingBannedListener { fun onReorderingBanned() } No newline at end of file
packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java +12 −6 Original line number Diff line number Diff line Loading @@ -4862,14 +4862,20 @@ public class NotificationStackScrollLayout * @param isHeadsUp true for appear, false for disappear animations */ public void generateHeadsUpAnimation(ExpandableNotificationRow row, boolean isHeadsUp) { final boolean add = mAnimationsEnabled && (isHeadsUp || mHeadsUpGoingAwayAnimationsAllowed); final boolean closedAndSeenInShade = !mIsExpanded && row.getEntry() != null && row.getEntry().isSeenInShade(); final boolean addAnimation = mAnimationsEnabled && !closedAndSeenInShade && (isHeadsUp || mHeadsUpGoingAwayAnimationsAllowed); if (SPEW) { Log.v(TAG, "generateHeadsUpAnimation:" + " willAdd=" + add + " isHeadsUp=" + isHeadsUp + " row=" + row.getEntry().getKey()); } if (add) { + " addAnimation=" + addAnimation + (row.getEntry() == null ? " entry NULL " : " isSeenInShade=" + row.getEntry().isSeenInShade() + " row=" + row.getEntry().getKey()) + " mIsExpanded=" + mIsExpanded + " isHeadsUp=" + isHeadsUp); } if (addAnimation) { // If we're hiding a HUN we just started showing THIS FRAME, then remove that event, // and do not add the disappear event either. if (!isHeadsUp && mHeadsUpChangeAnimations.remove(new Pair<>(row, true))) { Loading