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

Commit e3d73be4 authored by Lyn Han's avatar Lyn Han Committed by Android (Google) Code Review
Browse files

Merge "Fix classified sms not showing under promotions" into main

parents 4eddb3d5 8f2e18fe
Loading
Loading
Loading
Loading
+39 −0
Original line number Original line Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.systemui.statusbar.notification.collection.coordinator


import android.app.Flags
import android.app.Flags
import android.app.NotificationChannel
import android.app.NotificationChannel
import android.app.NotificationChannel.SYSTEM_RESERVED_IDS
import android.app.NotificationManager.IMPORTANCE_DEFAULT
import android.app.NotificationManager.IMPORTANCE_DEFAULT
import android.app.NotificationManager.IMPORTANCE_HIGH
import android.app.NotificationManager.IMPORTANCE_HIGH
import android.app.NotificationManager.IMPORTANCE_LOW
import android.app.NotificationManager.IMPORTANCE_LOW
@@ -123,6 +124,14 @@ class ConversationCoordinatorTest : SysuiTestCase() {
        assertFalse(sectioner.isInSection(NotificationEntryBuilder().build()))
        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
    @Test
    fun testPromotesImportantConversations() {
    fun testPromotesImportantConversations() {
        assertTrue(promoter.shouldPromoteToTopLevel(makeEntryOfPeopleType(TYPE_IMPORTANT_PERSON)))
        assertTrue(promoter.shouldPromoteToTopLevel(makeEntryOfPeopleType(TYPE_IMPORTANT_PERSON)))
@@ -165,6 +174,14 @@ class ConversationCoordinatorTest : SysuiTestCase() {
        verify(conversationIconManager).setUnimportantConversations(eq(listOf(summary.key)))
        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
    @Test
    fun testInAlertingPeopleSectionWhenTheImportanceIsAtLeastDefault() {
    fun testInAlertingPeopleSectionWhenTheImportanceIsAtLeastDefault() {
        // GIVEN
        // GIVEN
@@ -184,6 +201,15 @@ class ConversationCoordinatorTest : SysuiTestCase() {
        assertThat(peopleAlertingSectioner.isInSection(silentEntry)).isTrue()
        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
    @Test
    @DisableFlags(Flags.FLAG_SORT_SECTION_BY_TIME)
    @DisableFlags(Flags.FLAG_SORT_SECTION_BY_TIME)
    fun testInSilentPeopleSectionWhenTheImportanceIsLowerThanDefault() {
    fun testInSilentPeopleSectionWhenTheImportanceIsLowerThanDefault() {
@@ -280,4 +306,17 @@ class ConversationCoordinatorTest : SysuiTestCase() {
        assertEquals(type, peopleNotificationIdentifier.getPeopleNotificationType(entry))
        assertEquals(type, peopleNotificationIdentifier.getPeopleNotificationType(entry))
        return 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 Original line Diff line number Diff line
@@ -16,6 +16,7 @@


package com.android.systemui.statusbar.notification.collection.coordinator
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.GroupEntry
import com.android.systemui.statusbar.notification.collection.PipelineEntry
import com.android.systemui.statusbar.notification.collection.PipelineEntry
import com.android.systemui.statusbar.notification.collection.NotifPipeline
import com.android.systemui.statusbar.notification.collection.NotifPipeline
@@ -89,6 +90,7 @@ class ConversationCoordinator @Inject constructor(
            object : NotifSectioner("Priority People", BUCKET_PRIORITY_PEOPLE) {
            object : NotifSectioner("Priority People", BUCKET_PRIORITY_PEOPLE) {
                override fun isInSection(entry: PipelineEntry): Boolean {
                override fun isInSection(entry: PipelineEntry): Boolean {
                    return getPeopleType(entry) == TYPE_IMPORTANT_PERSON
                    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) {
    val peopleAlertingSectioner = object : NotifSectioner("People(alerting)", BUCKET_PEOPLE) {
        override fun isInSection(entry: PipelineEntry): Boolean  {
        override fun isInSection(entry: PipelineEntry): Boolean  {
            if (SortBySectionTimeFlag.isEnabled) {
            if (SortBySectionTimeFlag.isEnabled) {
                return highPriorityProvider.isHighPriorityConversation(entry)
                return (highPriorityProvider.isHighPriorityConversation(entry)
                        || isConversation(entry)
                        || isConversation(entry))
                        && entry.representativeEntry?.channel?.id !in SYSTEM_RESERVED_IDS
            } else {
            } else {
                return highPriorityProvider.isHighPriorityConversation(entry)
                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) {
    val peopleSilentSectioner = object : NotifSectioner("People(silent)", BUCKET_PEOPLE) {
        // Because the peopleAlertingSectioner is above this one, it will claim all conversations that are alerting.
        // Because the peopleAlertingSectioner is above this one, it will claim all conversations
        // All remaining conversations must be silent.
        // that are alerting. All remaining conversations must be silent.
        override fun isInSection(entry: PipelineEntry): Boolean {
        override fun isInSection(entry: PipelineEntry): Boolean {
            SortBySectionTimeFlag.assertInLegacyMode()
            SortBySectionTimeFlag.assertInLegacyMode()
            return isConversation(entry)
            return isConversation(entry)
                    && entry.representativeEntry?.channel?.id !in SYSTEM_RESERVED_IDS
        }
        }


        override fun getComparator(): NotifComparator {
        override fun getComparator(): NotifComparator {