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

Commit f83dbddd authored by Yuri Lin's avatar Yuri Lin Committed by Android (Google) Code Review
Browse files

Merge "Restore notifications when disabling a bundle from guts" into main

parents 6685a87e 81096c36
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
@@ -73,7 +73,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