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

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

Merge "Remove sort_section_by_time flag" into main

parents f62f086c 4614342d
Loading
Loading
Loading
Loading
+12 −32
Original line number Diff line number Diff line
@@ -2774,12 +2774,9 @@ public class Notification implements Parcelable
    public Notification()
    {
        this.when = System.currentTimeMillis();
        if (Flags.sortSectionByTime()) {
        creationTime = when;
        extras.putBoolean(EXTRA_SHOW_WHEN, true);
        } else {
            this.creationTime = System.currentTimeMillis();
        }
        this.priority = PRIORITY_DEFAULT;
    }
@@ -2790,10 +2787,9 @@ public class Notification implements Parcelable
    public Notification(Context context, int icon, CharSequence tickerText, long when,
            CharSequence contentTitle, CharSequence contentText, Intent contentIntent)
    {
        if (Flags.sortSectionByTime()) {
        creationTime = when;
        extras.putBoolean(EXTRA_SHOW_WHEN, true);
        }
        new Builder(context)
                .setWhen(when)
                .setSmallIcon(icon)
@@ -2823,12 +2819,8 @@ public class Notification implements Parcelable
        this.icon = icon;
        this.tickerText = tickerText;
        this.when = when;
        if (Flags.sortSectionByTime()) {
        creationTime = when;
        extras.putBoolean(EXTRA_SHOW_WHEN, true);
        } else {
            this.creationTime = System.currentTimeMillis();
        }
    }
    /**
@@ -7657,10 +7649,6 @@ public class Notification implements Parcelable
                mN.extras.putAll(saveExtras);
            }
            if (!Flags.sortSectionByTime()) {
                mN.creationTime = System.currentTimeMillis();
            }
            // lazy stuff from mContext; see comment in Builder(Context, Notification)
            Notification.addFieldsFromContext(mContext, mN);
@@ -8258,11 +8246,9 @@ public class Notification implements Parcelable
     * @hide
     */
    public long getWhen() {
        if (Flags.sortSectionByTime()) {
        if (when == 0) {
            return creationTime;
        }
        }
        return when;
    }
@@ -8271,22 +8257,16 @@ public class Notification implements Parcelable
     * @hide
     */
    public boolean showsTime() {
        if (Flags.sortSectionByTime()) {
        return extras.getBoolean(EXTRA_SHOW_WHEN);
    }
        return when != 0 && extras.getBoolean(EXTRA_SHOW_WHEN);
    }
    /**
     * @return true if the notification will show a chronometer; false otherwise
     * @hide
     */
    public boolean showsChronometer() {
        if (Flags.sortSectionByTime()) {
        return extras.getBoolean(EXTRA_SHOW_CHRONOMETER);
    }
        return when != 0 && extras.getBoolean(EXTRA_SHOW_CHRONOMETER);
    }
    /**
     * @return true if the notification has image
+6 −3
Original line number Diff line number Diff line
@@ -99,10 +99,13 @@ flag {
}

flag {
  name: "sort_section_by_time"
  name: "evenly_divided_call_style_action_layout"
  namespace: "systemui"
  description: "Changes notification sort order to be by time within a section"
  bug: "330193582"
  description: "Evenly divides horizontal space for action buttons in CallStyle notifications."
  bug: "268733030"
  metadata {
    purpose: PURPOSE_BUGFIX
  }
}

flag {
+0 −12
Original line number Diff line number Diff line
@@ -2397,12 +2397,6 @@ public class NotificationTest {
                .setWhen(0)
                .build();

        mSetFlagsRule.disableFlags(Flags.FLAG_SORT_SECTION_BY_TIME);

        assertThat(n.getWhen()).isEqualTo(0);

        mSetFlagsRule.enableFlags(Flags.FLAG_SORT_SECTION_BY_TIME);

        assertThat(n.getWhen()).isEqualTo(n.creationTime);
    }

@@ -2412,12 +2406,6 @@ public class NotificationTest {
                .setWhen(9)
                .build();

        mSetFlagsRule.disableFlags(Flags.FLAG_SORT_SECTION_BY_TIME);

        assertThat(n.getWhen()).isEqualTo(9);

        mSetFlagsRule.enableFlags(Flags.FLAG_SORT_SECTION_BY_TIME);

        assertThat(n.getWhen()).isEqualTo(9);
    }

+0 −1
Original line number Diff line number Diff line
@@ -83,7 +83,6 @@ class SectionStyleProviderTest : SysuiTestCase() {
    }

    @Test
    @EnableFlags(Flags.FLAG_SORT_SECTION_BY_TIME)
    fun testIsSilent_silentPeople() {
        val listEntry = fakeNotification(peopleMixedSectioner)
        whenever(highPriorityProvider.isHighPriorityConversation(listEntry)).thenReturn(false)
+0 −60
Original line number Diff line number Diff line
@@ -33,7 +33,6 @@ import com.android.systemui.statusbar.notification.collection.GroupEntryBuilder
import com.android.systemui.statusbar.notification.collection.NotifPipeline
import com.android.systemui.statusbar.notification.collection.NotificationEntry
import com.android.systemui.statusbar.notification.collection.NotificationEntryBuilder
import com.android.systemui.statusbar.notification.collection.SortBySectionTimeFlag
import com.android.systemui.statusbar.notification.collection.listbuilder.NotifSection
import com.android.systemui.statusbar.notification.collection.listbuilder.OnBeforeRenderListListener
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifComparator
@@ -76,7 +75,6 @@ class ConversationCoordinatorTest : SysuiTestCase() {
    // captured listeners and pluggables:
    private lateinit var promoter: NotifPromoter
    private lateinit var peopleAlertingSectioner: NotifSectioner
    private lateinit var peopleSilentSectioner: NotifSectioner
    private lateinit var peopleComparator: NotifComparator
    private lateinit var beforeRenderListListener: OnBeforeRenderListListener

@@ -111,9 +109,6 @@ class ConversationCoordinatorTest : SysuiTestCase() {
        }

        peopleAlertingSectioner = coordinator.peopleAlertingSectioner
        peopleSilentSectioner = coordinator.peopleSilentSectioner
        if (!SortBySectionTimeFlag.isEnabled)
            peopleComparator = peopleAlertingSectioner.comparator!!

        peopleAlertingSection = NotifSection(peopleAlertingSectioner, 0)
    }
@@ -196,7 +191,6 @@ class ConversationCoordinatorTest : SysuiTestCase() {
    }

    @Test
    @EnableFlags(Flags.FLAG_SORT_SECTION_BY_TIME)
    fun testInAlertingPeopleSectionWhenTheImportanceIsLowerThanDefault() {
        // GIVEN
        val silentEntry = makeEntryOfPeopleType(TYPE_PERSON) { setImportance(IMPORTANCE_LOW) }
@@ -205,29 +199,6 @@ class ConversationCoordinatorTest : SysuiTestCase() {
        assertThat(peopleAlertingSectioner.isInSection(silentEntry)).isTrue()
    }

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

    @Test
    @DisableFlags(Flags.FLAG_SORT_SECTION_BY_TIME)
    fun testInSilentPeopleSectionWhenTheImportanceIsLowerThanDefault() {
        // GIVEN
        val silentEntry = makeEntryOfPeopleType(TYPE_PERSON) { setImportance(IMPORTANCE_LOW) }

        // THEN put silent people notifications in this section
        assertThat(peopleSilentSectioner.isInSection(silentEntry)).isTrue()
        // People Alerting sectioning happens before the silent one.
        // It claims high important conversations and rest of conversations will be considered as
        // silent.
        assertThat(peopleAlertingSectioner.isInSection(silentEntry)).isFalse()
    }

    @Test
    fun testNotInPeopleSection() {
        // GIVEN
@@ -235,10 +206,6 @@ class ConversationCoordinatorTest : SysuiTestCase() {
        val importantEntry =
            makeEntryOfPeopleType(TYPE_NON_PERSON) { setImportance(IMPORTANCE_HIGH) }

        // THEN - only put people notification either silent or alerting
        if (!SortBySectionTimeFlag.isEnabled) {
            assertThat(peopleSilentSectioner.isInSection(entry)).isFalse()
        }
        assertThat(peopleAlertingSectioner.isInSection(importantEntry)).isFalse()
    }

@@ -261,33 +228,6 @@ class ConversationCoordinatorTest : SysuiTestCase() {
    }

    @Test
    @DisableFlags(Flags.FLAG_SORT_SECTION_BY_TIME)
    fun testComparatorPutsImportantPeopleFirst() {
        val entryA =
            makeEntryOfPeopleType(TYPE_IMPORTANT_PERSON) {
                setSection(peopleAlertingSection).setTag("A")
            }
        val entryB =
            makeEntryOfPeopleType(TYPE_PERSON) { setSection(peopleAlertingSection).setTag("B") }

        // only put people notifications in this section
        assertThat(peopleComparator.compare(entryA, entryB)).isEqualTo(-1)
    }

    @Test
    @DisableFlags(Flags.FLAG_SORT_SECTION_BY_TIME)
    fun testComparatorEquatesPeopleWithSameType() {
        val entryA =
            makeEntryOfPeopleType(TYPE_PERSON) { setSection(peopleAlertingSection).setTag("A") }
        val entryB =
            makeEntryOfPeopleType(TYPE_PERSON) { setSection(peopleAlertingSection).setTag("B") }

        // only put people notifications in this section
        assertThat(peopleComparator.compare(entryA, entryB)).isEqualTo(0)
    }

    @Test
    @EnableFlags(Flags.FLAG_SORT_SECTION_BY_TIME)
    fun testNoSecondarySortForConversations() {
        assertThat(peopleAlertingSectioner.comparator).isNull()
    }
Loading