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

Commit fbe9702f authored by Chloris Kuo's avatar Chloris Kuo
Browse files

Notification text change should not be interruptive during post time

Rename NLS#Ranking.visuallyInterruptive and source from isTextChanged

Bug: 201087764

Test: atest NotificationManagerServiceTest, NotificationRecordTest,
NotificationListenerServiceTest, BubblesTest, BubbleDataTest,
NewNotiPipelineBubblesTest

Change-Id: I5949183704c3747084c83af7737a5212ede48fc0
parent 22314d89
Loading
Loading
Loading
Loading
+9 −9
Original line number Diff line number Diff line
@@ -1699,7 +1699,7 @@ public abstract class NotificationListenerService extends Service {
        private ArrayList<Notification.Action> mSmartActions;
        private ArrayList<CharSequence> mSmartReplies;
        private boolean mCanBubble;
        private boolean mVisuallyInterruptive;
        private boolean mIsTextChanged;
        private boolean mIsConversation;
        private ShortcutInfo mShortcutInfo;
        private @RankingAdjustment int mRankingAdjustment;
@@ -1736,7 +1736,7 @@ public abstract class NotificationListenerService extends Service {
            out.writeTypedList(mSmartActions, flags);
            out.writeCharSequenceList(mSmartReplies);
            out.writeBoolean(mCanBubble);
            out.writeBoolean(mVisuallyInterruptive);
            out.writeBoolean(mIsTextChanged);
            out.writeBoolean(mIsConversation);
            out.writeParcelable(mShortcutInfo, flags);
            out.writeInt(mRankingAdjustment);
@@ -1774,7 +1774,7 @@ public abstract class NotificationListenerService extends Service {
            mSmartActions = in.createTypedArrayList(Notification.Action.CREATOR);
            mSmartReplies = in.readCharSequenceList();
            mCanBubble = in.readBoolean();
            mVisuallyInterruptive = in.readBoolean();
            mIsTextChanged = in.readBoolean();
            mIsConversation = in.readBoolean();
            mShortcutInfo = in.readParcelable(cl);
            mRankingAdjustment = in.readInt();
@@ -1977,8 +1977,8 @@ public abstract class NotificationListenerService extends Service {
        }

        /** @hide */
        public boolean visuallyInterruptive() {
            return mVisuallyInterruptive;
        public boolean isTextChanged() {
            return mIsTextChanged;
        }

        /** @hide */
@@ -2033,7 +2033,7 @@ public abstract class NotificationListenerService extends Service {
                int userSentiment, boolean hidden, long lastAudiblyAlertedMs,
                boolean noisy, ArrayList<Notification.Action> smartActions,
                ArrayList<CharSequence> smartReplies, boolean canBubble,
                boolean visuallyInterruptive, boolean isConversation, ShortcutInfo shortcutInfo,
                boolean isTextChanged, boolean isConversation, ShortcutInfo shortcutInfo,
                int rankingAdjustment, boolean isBubble) {
            mKey = key;
            mRank = rank;
@@ -2055,7 +2055,7 @@ public abstract class NotificationListenerService extends Service {
            mSmartActions = smartActions;
            mSmartReplies = smartReplies;
            mCanBubble = canBubble;
            mVisuallyInterruptive = visuallyInterruptive;
            mIsTextChanged = isTextChanged;
            mIsConversation = isConversation;
            mShortcutInfo = shortcutInfo;
            mRankingAdjustment = rankingAdjustment;
@@ -2096,7 +2096,7 @@ public abstract class NotificationListenerService extends Service {
                    other.mSmartActions,
                    other.mSmartReplies,
                    other.mCanBubble,
                    other.mVisuallyInterruptive,
                    other.mIsTextChanged,
                    other.mIsConversation,
                    other.mShortcutInfo,
                    other.mRankingAdjustment,
@@ -2153,7 +2153,7 @@ public abstract class NotificationListenerService extends Service {
                        == (other.mSmartActions == null ? 0 : other.mSmartActions.size()))
                    && Objects.equals(mSmartReplies, other.mSmartReplies)
                    && Objects.equals(mCanBubble, other.mCanBubble)
                    && Objects.equals(mVisuallyInterruptive, other.mVisuallyInterruptive)
                    && Objects.equals(mIsTextChanged, other.mIsTextChanged)
                    && Objects.equals(mIsConversation, other.mIsConversation)
                    // Shortcutinfo doesn't have equals either; use id
                    &&  Objects.equals((mShortcutInfo == null ? 0 : mShortcutInfo.getId()),
+7 −7
Original line number Diff line number Diff line
@@ -121,7 +121,7 @@ public class Bubble implements BubbleViewProvider {
    @Nullable
    private Icon mIcon;
    private boolean mIsBubble;
    private boolean mIsVisuallyInterruptive;
    private boolean mIsTextChanged;
    private boolean mIsClearable;
    private boolean mShouldSuppressNotificationDot;
    private boolean mShouldSuppressNotificationList;
@@ -342,12 +342,12 @@ public class Bubble implements BubbleViewProvider {
    }

    /**
     * Sets whether this bubble is considered visually interruptive. This method is purely for
     * Sets whether this bubble is considered text changed. This method is purely for
     * testing.
     */
    @VisibleForTesting
    void setVisuallyInterruptiveForTest(boolean visuallyInterruptive) {
        mIsVisuallyInterruptive = visuallyInterruptive;
    void setTextChangedForTest(boolean textChanged) {
        mIsTextChanged = textChanged;
    }

    /**
@@ -454,7 +454,7 @@ public class Bubble implements BubbleViewProvider {
        mFlyoutMessage = extractFlyoutMessage(entry);
        if (entry.getRanking() != null) {
            mShortcutInfo = entry.getRanking().getConversationShortcutInfo();
            mIsVisuallyInterruptive = entry.getRanking().visuallyInterruptive();
            mIsTextChanged = entry.getRanking().isTextChanged();
            if (entry.getRanking().getChannel() != null) {
                mIsImportantConversation =
                        entry.getRanking().getChannel().isImportantConversation();
@@ -495,8 +495,8 @@ public class Bubble implements BubbleViewProvider {
        return mIcon;
    }

    boolean isVisuallyInterruptive() {
        return mIsVisuallyInterruptive;
    boolean isTextChanged() {
        return mIsTextChanged;
    }

    /**
+1 −1
Original line number Diff line number Diff line
@@ -939,7 +939,7 @@ public class BubbleController {
    public void updateBubble(BubbleEntry notif, boolean suppressFlyout, boolean showInShade) {
        // If this is an interruptive notif, mark that it's interrupted
        mSysuiProxy.setNotificationInterruption(notif.getKey());
        if (!notif.getRanking().visuallyInterruptive()
        if (!notif.getRanking().isTextChanged()
                && (notif.getBubbleMetadata() != null
                    && !notif.getBubbleMetadata().getAutoExpandBubble())
                && mBubbleData.hasOverflowBubbleWithKey(notif.getKey())) {
+1 −1
Original line number Diff line number Diff line
@@ -323,7 +323,7 @@ public class BubbleData {
        }
        mPendingBubbles.remove(bubble.getKey()); // No longer pending once we're here
        Bubble prevBubble = getBubbleInStackWithKey(bubble.getKey());
        suppressFlyout |= !bubble.isVisuallyInterruptive();
        suppressFlyout |= !bubble.isTextChanged();

        if (prevBubble == null) {
            // Create a new bubble
+4 −4
Original line number Diff line number Diff line
@@ -131,7 +131,7 @@ public class BubbleDataTest extends ShellTestCase {

        NotificationListenerService.Ranking ranking =
                mock(NotificationListenerService.Ranking.class);
        when(ranking.visuallyInterruptive()).thenReturn(true);
        when(ranking.isTextChanged()).thenReturn(true);
        mEntryInterruptive = createBubbleEntry(1, "interruptive", "package.d", ranking);
        mBubbleInterruptive = new Bubble(mEntryInterruptive, mSuppressionListener, null,
                mMainExecutor);
@@ -1014,15 +1014,15 @@ public class BubbleDataTest extends ShellTestCase {
    }

    private void sendUpdatedEntryAtTime(BubbleEntry entry, long postTime) {
        sendUpdatedEntryAtTime(entry, postTime, true /* visuallyInterruptive */);
        sendUpdatedEntryAtTime(entry, postTime, true /* isTextChanged */);
    }

    private void sendUpdatedEntryAtTime(BubbleEntry entry, long postTime,
            boolean visuallyInterruptive) {
            boolean textChanged) {
        setPostTime(entry, postTime);
        // BubbleController calls this:
        Bubble b = mBubbleData.getOrCreateBubble(entry, null /* persistedBubble */);
        b.setVisuallyInterruptiveForTest(visuallyInterruptive);
        b.setTextChangedForTest(textChanged);
        // And then this
        mBubbleData.notificationEntryUpdated(b, false /* suppressFlyout*/,
                true /* showInShade */);
Loading