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

Commit 81096c36 authored by Yuri Lin's avatar Yuri Lin
Browse files

Restore notifications when disabling a bundle from guts

Rather than dismissing them entirely, notifications that were previously bundled should be returned to their regular positions in the shade.

This change adds EntryAdapter.onBundleDisabled, which triggers onImportanceChanged for all the children in the bundle and any nested children in groups inside the bundle.

Bug: 417715201
Test: manual by disabling a bundle from guts and observing notifications
Flag: com.android.systemui.notification_bundle_ui
Change-Id: Ic0c4f11b2d23883b45a8c882eed99ed1265160fa
parent 9cc5bfd8
Loading
Loading
Loading
Loading
+56 −0
Original line number Diff line number Diff line
@@ -578,4 +578,60 @@ class NotificationEntryAdapterTest : SysuiTestCase() {
        underTest = factory.create(entry) as NotificationEntryAdapter
        assertThat(underTest.isBundled).isTrue()
    }

    @Test
    fun onBundleDisabled_individualNotification() {
        val notification: Notification =
            Notification.Builder(mContext, "")
                .setSmallIcon(R.drawable.ic_person)
                .addAction(Mockito.mock(Notification.Action::class.java))
                .build()

        val entry = NotificationEntryBuilder().setNotification(notification).build()
        underTest = factory.create(entry) as NotificationEntryAdapter

        underTest.onBundleDisabled()
        assertThat(underTest.isMarkedForUserTriggeredMovement).isTrue()
        verify(kosmos.mockVisualStabilityCoordinator)
            .temporarilyAllowSectionChanges(eq(entry), anyLong())
    }

    @Test
    fun onBundleDisabled_groupRoot() {
        val summaryRow: ExpandableNotificationRow = mock()
        val childRow: ExpandableNotificationRow = mock()
        val summary: Notification =
            Notification.Builder(mContext, "")
                .setSmallIcon(R.drawable.ic_person)
                .setGroupSummary(true)
                .setGroup("key")
                .build()

        val child: Notification =
            Notification.Builder(mContext, "")
                .setSmallIcon(R.drawable.ic_person)
                .addAction(Mockito.mock(Notification.Action::class.java))
                .setGroup("key")
                .build()

        val group = GroupEntryBuilder().setParent(GroupEntry.ROOT_ENTRY).build()

        val summaryEntry =
            NotificationEntryBuilder().setNotification(summary).setParent(group).build()
        group.setSummary(summaryEntry)
        summaryEntry.row = summaryRow

        val childEntry = NotificationEntryBuilder().setNotification(child).setParent(group).build()
        childEntry.row = childRow
        val childAdapter = factory.create(childEntry) as NotificationEntryAdapter
        whenever(childRow.entryAdapter).thenReturn(childAdapter)
        whenever(summaryRow.attachedChildren).thenReturn(listOf(childRow))

        underTest = factory.create(summaryEntry) as NotificationEntryAdapter
        underTest.onBundleDisabled()
        verify(kosmos.mockVisualStabilityCoordinator)
            .temporarilyAllowSectionChanges(eq(summaryEntry), anyLong())
        verify(kosmos.mockVisualStabilityCoordinator)
            .temporarilyAllowSectionChanges(eq(childEntry), anyLong())
    }
}
+0 −1
Original line number Diff line number Diff line
@@ -76,7 +76,6 @@ class BundleHeaderGutsViewModelTest : SysuiTestCase() {

        // Assert
        verify(mockDisableBundle).invoke()
        verify(mockOnDismissClicked).invoke()
        verify(mockCloseGuts, never()).invoke()
    }

+5 −0
Original line number Diff line number Diff line
@@ -252,6 +252,11 @@ class BundleEntryAdapter(
    override fun isBundle(): Boolean {
        return true
    }

    override fun onBundleDisabled() {
        // do nothing. it should not be possible for a bundle to be contained within a bundle
        Log.wtf(TAG, "onBundleDisabled() called")
    }
}

private const val TAG = "BundleEntryAdapter"
+5 −0
Original line number Diff line number Diff line
@@ -238,5 +238,10 @@ public interface EntryAdapter {
     * Returns whether this entry *is* a bundle.
     */
    boolean isBundle();

    /**
     * Processes when the bundle this entry is within is disabled.
     */
    void onBundleDisabled();
}
+9 −0
Original line number Diff line number Diff line
@@ -288,4 +288,13 @@ class NotificationEntryAdapter(
    override fun isBundle(): Boolean {
        return false
    }

    override fun onBundleDisabled() {
        markForUserTriggeredMovement(true)
        onImportanceChanged()

        if (isGroupRoot()) {
            row.attachedChildren?.forEach { it.entryAdapter.onBundleDisabled() }
        }
    }
}
Loading