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

Commit 938963a0 authored by Julia Reynolds's avatar Julia Reynolds Committed by Android (Google) Code Review
Browse files

Merge changes from topic "jr-expand-bundle" into main

* changes:
  Consolidate group expansion handling
  Revert^2 "Selectively autoexpand bundles"
parents 093b415a e6ff165b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -203,7 +203,7 @@ private fun ContentScope.BundleHeaderContent(

        ExpansionControl(
            collapsed = collapsed,
            numberToShow = viewModel.numberOfChildren,
            numberToShow = if (collapsed) viewModel.numberOfChildren else null,
            modifier =
                Modifier.padding(start = 8.dp, end = 16.dp).semantics(mergeDescendants = false) {
                    contentDescription = viewModel.numberOfChildrenContentDescription
+1 −7
Original line number Diff line number Diff line
@@ -87,13 +87,7 @@ class RowAlertTimeCoordinatorTest : SysuiTestCase() {
                }
            }
        val expectedTimesSet =
            mapOf(
                entry1 to 10L,
                entry2 to 20L,
                summary to 8L,
                child1 to 0L,
                child2 to 8L,
            )
            mapOf(entry1 to 10L, entry2 to 20L, summary to 8L, child1 to 0L, child2 to 8L)
        assertThat(actualTimesSet).containsExactlyEntriesIn(expectedTimesSet)
    }
}
+315 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 The Android Open Source Project
 * Copyright (C) 2025 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
@@ -23,11 +23,16 @@ import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.statusbar.notification.AssistantFeedbackController
import com.android.systemui.statusbar.notification.FeedbackIcon
import com.android.systemui.statusbar.notification.collection.BundleEntry
import com.android.systemui.statusbar.notification.collection.BundleSpec
import com.android.systemui.statusbar.notification.collection.InternalNotificationsApi
import com.android.systemui.statusbar.notification.collection.NotifPipeline
import com.android.systemui.statusbar.notification.collection.NotificationEntry
import com.android.systemui.statusbar.notification.collection.buildNotificationEntry
import com.android.systemui.statusbar.notification.collection.listbuilder.NotifSection
import com.android.systemui.statusbar.notification.collection.listbuilder.OnAfterRenderBundleEntryListener
import com.android.systemui.statusbar.notification.collection.listbuilder.OnAfterRenderEntryListener
import com.android.systemui.statusbar.notification.collection.listbuilder.OnAfterRenderListListener
import com.android.systemui.statusbar.notification.collection.listbuilder.OnBeforeRenderListListener
import com.android.systemui.statusbar.notification.collection.notifCollection
import com.android.systemui.statusbar.notification.collection.provider.SectionStyleProvider
@@ -41,6 +46,7 @@ import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.Mock
import org.mockito.Mockito.mock
import org.mockito.Mockito.verify
import org.mockito.Mockito.`when` as whenever
import org.mockito.MockitoAnnotations.initMocks
@@ -53,10 +59,14 @@ class RowAppearanceCoordinatorTest : SysuiTestCase() {
    private lateinit var coordinator: RowAppearanceCoordinator
    private lateinit var beforeRenderListListener: OnBeforeRenderListListener
    private lateinit var afterRenderEntryListener: OnAfterRenderEntryListener
    private lateinit var afterRenderBundleEntryListener: OnAfterRenderBundleEntryListener
    private lateinit var afterRenderListListener: OnAfterRenderListListener

    private lateinit var entry1: NotificationEntry
    private lateinit var entry2: NotificationEntry
    private lateinit var entry3: NotificationEntry
    private lateinit var entry4: NotificationEntry
    private lateinit var bundleEntry: BundleEntry

    @Mock private lateinit var pipeline: NotifPipeline
    @Mock private lateinit var assistantFeedbackController: AssistantFeedbackController
@@ -68,12 +78,18 @@ class RowAppearanceCoordinatorTest : SysuiTestCase() {
    @Mock private lateinit var controller1: NotifRowController
    @Mock private lateinit var controller2: NotifRowController
    @Mock private lateinit var controller3: NotifRowController
    @Mock private lateinit var controllerBundle: NotifRowController

    @Before
    fun setUp() {
        initMocks(this)
        coordinator = RowAppearanceCoordinator(
            mContext, assistantFeedbackController, sectionStyleProvider, kosmos.notifCollection)
        coordinator =
            RowAppearanceCoordinator(
                mContext,
                assistantFeedbackController,
                sectionStyleProvider,
                kosmos.notifCollection,
            )
        coordinator.attach(pipeline)
        beforeRenderListListener = withArgCaptor {
            verify(pipeline).addOnBeforeRenderListListener(capture())
@@ -81,6 +97,12 @@ class RowAppearanceCoordinatorTest : SysuiTestCase() {
        afterRenderEntryListener = withArgCaptor {
            verify(pipeline).addOnAfterRenderEntryListener(capture())
        }
        afterRenderBundleEntryListener = withArgCaptor {
            verify(pipeline).addOnAfterRenderBundleEntryListener(capture())
        }
        afterRenderListListener = withArgCaptor {
            verify(pipeline).addOnAfterRenderListListener(capture())
        }
        whenever(assistantFeedbackController.getFeedbackIcon(any())).thenReturn(FeedbackIcon(1, 2))
        entry1 = kosmos.buildNotificationEntry { setSection(section1) }
        entry2 = kosmos.buildNotificationEntry { setSection(section2) }
@@ -89,6 +111,12 @@ class RowAppearanceCoordinatorTest : SysuiTestCase() {
                setChannel(NotificationChannel(NotificationChannel.RECS_ID, "recs", 2))
                setSection(section2)
            }
        entry4 =
            kosmos.buildNotificationEntry {
                setChannel(NotificationChannel(NotificationChannel.RECS_ID, "recs", 2))
                setSection(section2)
            }
        bundleEntry = BundleEntry(BundleSpec.RECOMMENDED)
    }

    @Test
@@ -115,28 +143,56 @@ class RowAppearanceCoordinatorTest : SysuiTestCase() {

    @Test
    @EnableFlags(NotificationBundleUi.FLAG_NAME)
    fun testSetSystemExpanded_Bundled_NotInGroup() {
    fun testSetSystemExpanded_Bundled_NotInGroup_singleBundle() {
        whenever(sectionStyleProvider.isMinimizedSection(eq(section3))).thenReturn(false)
        beforeRenderListListener.onBeforeRenderList(listOf(entry3))
        afterRenderEntryListener.onAfterRenderEntry(entry3, controller3)
        verify(controller3).setSystemExpanded(eq(true))
        verify(controller3).setSystemExpanded(eq(false))
    }

    @Test
    @EnableFlags(NotificationBundleUi.FLAG_NAME)
    fun testSetSystemExpanded_Bundled_NotInGroup_multipleBundles() {
        whenever(sectionStyleProvider.isMinimizedSection(eq(section3))).thenReturn(false)
        beforeRenderListListener.onBeforeRenderList(listOf(entry3))
        afterRenderListListener.onAfterRenderList(
            listOf(entry3, bundleEntry, mock(BundleEntry::class.java))
        )
        afterRenderEntryListener.onAfterRenderEntry(entry3, controller3)
        verify(controller3).setSystemExpanded(true)
    }

    @Test
    @EnableFlags(NotificationBundleUi.FLAG_NAME)
    fun testSetSystemExpanded_Bundled_SingleNotifInGroup() {
    fun testSetSystemExpanded_Bundled_SingleNotifInGroup_multipleBundles() {
        entry3.sbn.overrideGroupKey = "bundled"
        whenever(sectionStyleProvider.isMinimizedSection(eq(section3))).thenReturn(false)
        whenever(kosmos.notifCollection.isOnlyChildInGroup(entry3)).thenReturn(true)

        beforeRenderListListener.onBeforeRenderList(listOf(entry3))
        afterRenderListListener.onAfterRenderList(
            listOf(entry3, bundleEntry, mock(BundleEntry::class.java))
        )
        afterRenderEntryListener.onAfterRenderEntry(entry3, controller3)
        verify(controller3).setSystemExpanded(eq(true))
    }

    @Test
    @EnableFlags(NotificationBundleUi.FLAG_NAME)
    fun testSetSystemExpanded_Bundled_NotMultiChildGroup() {
    fun testSetSystemExpanded_Bundled_SingleNotifInGroup_SingleBundle() {
        entry3.sbn.overrideGroupKey = "bundled"
        whenever(sectionStyleProvider.isMinimizedSection(eq(section3))).thenReturn(false)
        whenever(kosmos.notifCollection.isOnlyChildInGroup(entry3)).thenReturn(true)

        beforeRenderListListener.onBeforeRenderList(listOf(entry3))
        afterRenderListListener.onAfterRenderList(listOf(entry3, bundleEntry))
        afterRenderEntryListener.onAfterRenderEntry(entry3, controller3)
        verify(controller3).setSystemExpanded(false)
    }

    @Test
    @EnableFlags(NotificationBundleUi.FLAG_NAME)
    fun testSetSystemExpanded_Bundled_MultiChildGroup() {
        entry3.sbn.overrideGroupKey = "bundled"
        whenever(sectionStyleProvider.isMinimizedSection(eq(section3))).thenReturn(false)
        whenever(kosmos.notifCollection.isOnlyChildInGroup(entry3)).thenReturn(false)
@@ -146,6 +202,111 @@ class RowAppearanceCoordinatorTest : SysuiTestCase() {
        verify(controller3).setSystemExpanded(eq(false))
    }

    @Test
    @EnableFlags(NotificationBundleUi.FLAG_NAME)
    @OptIn(InternalNotificationsApi::class)
    fun testSetSystemExpanded_SingleBundle_SingleNotifInGroup() {
        bundleEntry.addChild(entry3)
        entry3.sbn.overrideGroupKey = "bundled"
        whenever(sectionStyleProvider.isMinimizedSection(eq(section3))).thenReturn(false)
        whenever(kosmos.notifCollection.isOnlyChildInGroup(entry3)).thenReturn(true)

        beforeRenderListListener.onBeforeRenderList(listOf(entry3, bundleEntry))
        afterRenderListListener.onAfterRenderList(listOf(entry3, bundleEntry))
        afterRenderBundleEntryListener.onAfterRenderEntry(bundleEntry, controllerBundle)
        verify(controllerBundle).setSystemExpanded(true)
    }

    @Test
    @EnableFlags(NotificationBundleUi.FLAG_NAME)
    @OptIn(InternalNotificationsApi::class)
    fun testSetSystemExpanded_SingleBundle_MultiChildGroup() {
        bundleEntry.addChild(entry3)
        entry3.sbn.overrideGroupKey = "bundled"
        whenever(sectionStyleProvider.isMinimizedSection(eq(section3))).thenReturn(false)
        whenever(kosmos.notifCollection.isOnlyChildInGroup(entry3)).thenReturn(false)

        beforeRenderListListener.onBeforeRenderList(listOf(entry3, bundleEntry))
        afterRenderListListener.onAfterRenderList(listOf(entry3, bundleEntry))
        afterRenderBundleEntryListener.onAfterRenderEntry(bundleEntry, controllerBundle)
        verify(controllerBundle).setSystemExpanded(true)
    }

    @Test
    @EnableFlags(NotificationBundleUi.FLAG_NAME)
    @OptIn(InternalNotificationsApi::class)
    fun testSetSystemExpanded_SingleBundle_NotInGroup() {
        bundleEntry.addChild(entry3)

        beforeRenderListListener.onBeforeRenderList(listOf(entry3, bundleEntry))
        afterRenderListListener.onAfterRenderList(listOf(entry3, bundleEntry))
        afterRenderBundleEntryListener.onAfterRenderEntry(bundleEntry, controllerBundle)
        verify(controllerBundle).setSystemExpanded(true)
    }

    @Test
    @EnableFlags(NotificationBundleUi.FLAG_NAME)
    @OptIn(InternalNotificationsApi::class)
    fun testSetSystemExpanded_SingleBundle_MultipleChildren() {
        bundleEntry.addChild(entry3)
        bundleEntry.addChild(entry4)

        beforeRenderListListener.onBeforeRenderList(listOf(entry3, entry4, bundleEntry))
        afterRenderBundleEntryListener.onAfterRenderEntry(bundleEntry, controllerBundle)
        verify(controllerBundle).setSystemExpanded(false)
    }

    @Test
    @EnableFlags(NotificationBundleUi.FLAG_NAME)
    @OptIn(InternalNotificationsApi::class)
    fun testSetSystemExpanded_MultiBundle_SingleNotifInGroup() {
        bundleEntry.addChild(entry3)
        entry3.sbn.overrideGroupKey = "bundled"
        whenever(sectionStyleProvider.isMinimizedSection(eq(section3))).thenReturn(false)
        whenever(kosmos.notifCollection.isOnlyChildInGroup(entry3)).thenReturn(true)

        beforeRenderListListener.onBeforeRenderList(listOf(entry3, bundleEntry))
        afterRenderBundleEntryListener.onAfterRenderEntry(bundleEntry, controllerBundle)
        verify(controllerBundle).setSystemExpanded(false)
    }

    @Test
    @EnableFlags(NotificationBundleUi.FLAG_NAME)
    @OptIn(InternalNotificationsApi::class)
    fun testSetSystemExpanded_MultiBundle_MultiChildGroup() {
        bundleEntry.addChild(entry3)
        entry3.sbn.overrideGroupKey = "bundled"
        whenever(sectionStyleProvider.isMinimizedSection(eq(section3))).thenReturn(false)
        whenever(kosmos.notifCollection.isOnlyChildInGroup(entry3)).thenReturn(false)

        beforeRenderListListener.onBeforeRenderList(listOf(entry3, bundleEntry))
        afterRenderBundleEntryListener.onAfterRenderEntry(bundleEntry, controllerBundle)
        verify(controllerBundle).setSystemExpanded(false)
    }

    @Test
    @EnableFlags(NotificationBundleUi.FLAG_NAME)
    @OptIn(InternalNotificationsApi::class)
    fun testSetSystemExpanded_MultiBundle_NotInGroup() {
        bundleEntry.addChild(entry3)

        beforeRenderListListener.onBeforeRenderList(listOf(entry3, bundleEntry))
        afterRenderBundleEntryListener.onAfterRenderEntry(bundleEntry, controllerBundle)
        verify(controllerBundle).setSystemExpanded(false)
    }

    @Test
    @EnableFlags(NotificationBundleUi.FLAG_NAME)
    @OptIn(InternalNotificationsApi::class)
    fun testSetSystemExpanded_MultiBundle_MultipleChildren() {
        bundleEntry.addChild(entry3)
        bundleEntry.addChild(entry4)

        beforeRenderListListener.onBeforeRenderList(listOf(entry3, entry4, bundleEntry))
        afterRenderBundleEntryListener.onAfterRenderEntry(bundleEntry, controllerBundle)
        verify(controllerBundle).setSystemExpanded(false)
    }

    @Test
    fun testSetFeedbackIcon() {
        afterRenderEntryListener.onAfterRenderEntry(entry1, controller1)
+4 −2
Original line number Diff line number Diff line
@@ -198,7 +198,7 @@ class RenderStageManagerTest : SysuiTestCase() {
            notif(4),
            group(notif(5), notif(6), notif(7)),
            notif(8),
            bundle(group(notif(9)), notif(10))
            bundle(group(notif(9)), notif(10)),
        )

    private class FakeNotifViewRenderer : NotifViewRenderer {
@@ -208,6 +208,8 @@ class RenderStageManagerTest : SysuiTestCase() {

        override fun getRowController(entry: NotificationEntry): NotifRowController = mock()

        override fun getBundleController(entry: BundleEntry): NotifRowController = mock()

        override fun onDispatchComplete() {}
    }

+1 −11
Original line number Diff line number Diff line
@@ -52,7 +52,6 @@ import java.util.List;
@SmallTest
@RunWith(AndroidJUnit4.class)
@RunWithLooper
//@DisableFlags(AsyncGroupHeaderViewInflation.FLAG_NAME)
public class NotificationChildrenContainerTest extends SysuiTestCase {

    private ExpandableNotificationRow mGroup;
@@ -135,21 +134,12 @@ public class NotificationChildrenContainerTest extends SysuiTestCase {
        ComposeView headerView = new ComposeView(mContext);
        mChildrenContainer.setBundleHeaderView(headerView);
        mChildrenContainer.setBundleHeaderViewModel(mock(BundleHeaderViewModel.class));
        mChildrenContainer.getContainingNotification().expandNotification();
        mChildrenContainer.setChildrenExpanded(true);
        Assert.assertEquals(mChildrenContainer.getMaxAllowedVisibleChildren(),
                NotificationChildrenContainer.NUMBER_OF_CHILDREN_BUNDLE_EXPANDED);
    }

    @Test
    @EnableFlags(NotificationBundleUi.FLAG_NAME)
    public void testGetMaxAllowedVisibleChildren_bundle_userLocked() {
        ComposeView headerView = new ComposeView(mContext);
        mChildrenContainer.setBundleHeaderView(headerView);
        mChildrenContainer.setBundleHeaderViewModel(mock(BundleHeaderViewModel.class));
        mGroup.setUserLocked(true);
        Assert.assertEquals(mChildrenContainer.getMaxAllowedVisibleChildren(),
                NotificationChildrenContainer.NUMBER_OF_CHILDREN_BUNDLE_EXPANDED);
    }

    @Test
    public void testShowingAsLowPriority_lowPriority() {
Loading