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

Commit 8f2e18fe authored by Lyn Han's avatar Lyn Han
Browse files

Fix classified sms not showing under promotions

Fixes: 397427011
Test: ConversationCoordinatorTest
Flag: android.service.notification.notification_classification
Change-Id: I82aa0e4902a5f445082e0163d1b21499cb0b742d
parent c57d5aa8
Loading
Loading
Loading
Loading
+39 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.systemui.statusbar.notification.collection.coordinator

import android.app.Flags
import android.app.NotificationChannel
import android.app.NotificationChannel.SYSTEM_RESERVED_IDS
import android.app.NotificationManager.IMPORTANCE_DEFAULT
import android.app.NotificationManager.IMPORTANCE_HIGH
import android.app.NotificationManager.IMPORTANCE_LOW
@@ -123,6 +124,14 @@ class ConversationCoordinatorTest : SysuiTestCase() {
        assertFalse(sectioner.isInSection(NotificationEntryBuilder().build()))
    }

    @Test
    fun testPrioritySectioner_doesNotClaim_classifiedConversation() {
        val sectioner = coordinator.priorityPeopleSectioner
        for (id in SYSTEM_RESERVED_IDS) {
            assertFalse(sectioner.isInSection(makeClassifiedConversation(id)))
        }
    }

    @Test
    fun testPromotesImportantConversations() {
        assertTrue(promoter.shouldPromoteToTopLevel(makeEntryOfPeopleType(TYPE_IMPORTANT_PERSON)))
@@ -165,6 +174,14 @@ class ConversationCoordinatorTest : SysuiTestCase() {
        verify(conversationIconManager).setUnimportantConversations(eq(listOf(summary.key)))
    }

    @Test
    fun testAlertingSectioner_doesNotClaim_classifiedConversation() {
        val sectioner = coordinator.peopleAlertingSectioner
        for (id in SYSTEM_RESERVED_IDS) {
            assertFalse(sectioner.isInSection(makeClassifiedConversation(id)))
        }
    }

    @Test
    fun testInAlertingPeopleSectionWhenTheImportanceIsAtLeastDefault() {
        // GIVEN
@@ -184,6 +201,15 @@ class ConversationCoordinatorTest : SysuiTestCase() {
        assertThat(peopleAlertingSectioner.isInSection(silentEntry)).isTrue()
    }

    @Test
    @DisableFlags(Flags.FLAG_SORT_SECTION_BY_TIME)
    fun testSilentSectioner_doesNotClaim_classifiedConversation() {
        val sectioner = coordinator.peopleSilentSectioner
        for (id in SYSTEM_RESERVED_IDS) {
            assertFalse(sectioner.isInSection(makeClassifiedConversation(id)))
        }
    }

    @Test
    @DisableFlags(Flags.FLAG_SORT_SECTION_BY_TIME)
    fun testInSilentPeopleSectionWhenTheImportanceIsLowerThanDefault() {
@@ -280,4 +306,17 @@ class ConversationCoordinatorTest : SysuiTestCase() {
        assertEquals(type, peopleNotificationIdentifier.getPeopleNotificationType(entry))
        return entry
    }

    private fun makeClassifiedConversation(channelId: String): NotificationEntry {
        val channel = NotificationChannel(channelId, channelId, IMPORTANCE_LOW)
        val entry =
            NotificationEntryBuilder()
                .updateRanking {
                    it.setIsConversation(true)
                    it.setShortcutInfo(mock())
                    it.setChannel(channel)
                }
                .build()
        return entry
    }
}
+9 −4
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.systemui.statusbar.notification.collection.coordinator

import android.app.NotificationChannel.SYSTEM_RESERVED_IDS
import com.android.systemui.statusbar.notification.collection.GroupEntry
import com.android.systemui.statusbar.notification.collection.PipelineEntry
import com.android.systemui.statusbar.notification.collection.NotifPipeline
@@ -89,6 +90,7 @@ class ConversationCoordinator @Inject constructor(
            object : NotifSectioner("Priority People", BUCKET_PRIORITY_PEOPLE) {
                override fun isInSection(entry: PipelineEntry): Boolean {
                    return getPeopleType(entry) == TYPE_IMPORTANT_PERSON
                            && entry.representativeEntry?.channel?.id !in SYSTEM_RESERVED_IDS
                }
            }

@@ -96,10 +98,12 @@ class ConversationCoordinator @Inject constructor(
    val peopleAlertingSectioner = object : NotifSectioner("People(alerting)", BUCKET_PEOPLE) {
        override fun isInSection(entry: PipelineEntry): Boolean  {
            if (SortBySectionTimeFlag.isEnabled) {
                return highPriorityProvider.isHighPriorityConversation(entry)
                        || isConversation(entry)
                return (highPriorityProvider.isHighPriorityConversation(entry)
                        || isConversation(entry))
                        && entry.representativeEntry?.channel?.id !in SYSTEM_RESERVED_IDS
            } else {
                return highPriorityProvider.isHighPriorityConversation(entry)
                        && entry.representativeEntry?.channel?.id !in SYSTEM_RESERVED_IDS
            }
        }

@@ -111,11 +115,12 @@ class ConversationCoordinator @Inject constructor(
    }

    val peopleSilentSectioner = object : NotifSectioner("People(silent)", BUCKET_PEOPLE) {
        // Because the peopleAlertingSectioner is above this one, it will claim all conversations that are alerting.
        // All remaining conversations must be silent.
        // Because the peopleAlertingSectioner is above this one, it will claim all conversations
        // that are alerting. All remaining conversations must be silent.
        override fun isInSection(entry: PipelineEntry): Boolean {
            SortBySectionTimeFlag.assertInLegacyMode()
            return isConversation(entry)
                    && entry.representativeEntry?.channel?.id !in SYSTEM_RESERVED_IDS
        }

        override fun getComparator(): NotifComparator {