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

Commit 40422db4 authored by Mady Mellor's avatar Mady Mellor
Browse files

Allow SysUI to update BubbleMetadata#FLAG_AUTO_EXPAND_BUBBLE

This flag should only really be applied to a notification bubble
one time. Once the bubble has auto-expanded (or if it was posted and
unable to auto-expand at that time due to something like DND), the
flag should be removed so we don't auto-expand it again.

We have a method that allows us to modify some specific flags on
BubbleMetadata. This CL updates that method to be more general and
work with any of the BubbleMetadata flags.

Bug: 226316876
Test: atest NotificationManagerServiceTest
Change-Id: Ib9653ed304f13ac88f489146d503f4de4fa29421
parent 3d790a16
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -88,7 +88,7 @@ interface IStatusBarService
            in int notificationLocation, boolean modifiedBeforeSending);
    void onNotificationSettingsViewed(String key);
    void onNotificationBubbleChanged(String key, boolean isBubble, int flags);
    void onBubbleNotificationSuppressionChanged(String key, boolean isNotifSuppressed, boolean isBubbleSuppressed);
    void onBubbleMetadataFlagChanged(String key, int flags);
    void hideCurrentInputMethodForBubbles();
    void grantInlineReplyUriPermission(String key, in Uri uri, in UserHandle user, String packageName);
    oneway void clearInlineReplyUriPermissions(String key);
+11 −7
Original line number Diff line number Diff line
@@ -71,7 +71,7 @@ public class Bubble implements BubbleViewProvider {
    private long mLastAccessed;

    @Nullable
    private Bubbles.SuppressionChangedListener mSuppressionListener;
    private Bubbles.BubbleMetadataFlagListener mBubbleMetadataFlagListener;

    /** Whether the bubble should show a dot for the notification indicating updated content. */
    private boolean mShowBubbleUpdateDot = true;
@@ -192,13 +192,13 @@ public class Bubble implements BubbleViewProvider {

    @VisibleForTesting(visibility = PRIVATE)
    public Bubble(@NonNull final BubbleEntry entry,
            @Nullable final Bubbles.SuppressionChangedListener listener,
            @Nullable final Bubbles.BubbleMetadataFlagListener listener,
            final Bubbles.PendingIntentCanceledListener intentCancelListener,
            Executor mainExecutor) {
        mKey = entry.getKey();
        mGroupKey = entry.getGroupKey();
        mLocusId = entry.getLocusId();
        mSuppressionListener = listener;
        mBubbleMetadataFlagListener = listener;
        mIntentCancelListener = intent -> {
            if (mIntent != null) {
                mIntent.unregisterCancelListener(mIntentCancelListener);
@@ -606,8 +606,8 @@ public class Bubble implements BubbleViewProvider {
            mFlags &= ~Notification.BubbleMetadata.FLAG_SUPPRESS_NOTIFICATION;
        }

        if (showInShade() != prevShowInShade && mSuppressionListener != null) {
            mSuppressionListener.onBubbleNotificationSuppressionChange(this);
        if (showInShade() != prevShowInShade && mBubbleMetadataFlagListener != null) {
            mBubbleMetadataFlagListener.onBubbleMetadataFlagChanged(this);
        }
    }

@@ -626,8 +626,8 @@ public class Bubble implements BubbleViewProvider {
        } else {
            mFlags &= ~Notification.BubbleMetadata.FLAG_SUPPRESS_BUBBLE;
        }
        if (prevSuppressed != suppressBubble && mSuppressionListener != null) {
            mSuppressionListener.onBubbleNotificationSuppressionChange(this);
        if (prevSuppressed != suppressBubble && mBubbleMetadataFlagListener != null) {
            mBubbleMetadataFlagListener.onBubbleMetadataFlagChanged(this);
        }
    }

@@ -799,6 +799,10 @@ public class Bubble implements BubbleViewProvider {
        return (mFlags & option) != 0;
    }

    public int getFlags() {
        return mFlags;
    }

    @Override
    public String toString() {
        return "Bubble{" + mKey + '}';
+3 −4
Original line number Diff line number Diff line
@@ -323,7 +323,7 @@ public class BubbleController {

    public void initialize() {
        mBubbleData.setListener(mBubbleDataListener);
        mBubbleData.setSuppressionChangedListener(this::onBubbleNotificationSuppressionChanged);
        mBubbleData.setSuppressionChangedListener(this::onBubbleMetadataFlagChanged);

        mBubbleData.setPendingIntentCancelledListener(bubble -> {
            if (bubble.getBubbleIntent() == null) {
@@ -554,11 +554,10 @@ public class BubbleController {
    }

    @VisibleForTesting
    public void onBubbleNotificationSuppressionChanged(Bubble bubble) {
    public void onBubbleMetadataFlagChanged(Bubble bubble) {
        // Make sure NoMan knows suppression state so that anyone querying it can tell.
        try {
            mBarService.onBubbleNotificationSuppressionChanged(bubble.getKey(),
                    !bubble.showInShade(), bubble.isSuppressed());
            mBarService.onBubbleMetadataFlagChanged(bubble.getKey(), bubble.getFlags());
        } catch (RemoteException e) {
            // Bad things have happened
        }
+4 −5
Original line number Diff line number Diff line
@@ -159,7 +159,7 @@ public class BubbleData {
    private Listener mListener;

    @Nullable
    private Bubbles.SuppressionChangedListener mSuppressionListener;
    private Bubbles.BubbleMetadataFlagListener mBubbleMetadataFlagListener;
    private Bubbles.PendingIntentCanceledListener mCancelledListener;

    /**
@@ -190,9 +190,8 @@ public class BubbleData {
        mMaxOverflowBubbles = mContext.getResources().getInteger(R.integer.bubbles_max_overflow);
    }

    public void setSuppressionChangedListener(
            Bubbles.SuppressionChangedListener listener) {
        mSuppressionListener = listener;
    public void setSuppressionChangedListener(Bubbles.BubbleMetadataFlagListener listener) {
        mBubbleMetadataFlagListener = listener;
    }

    public void setPendingIntentCancelledListener(
@@ -311,7 +310,7 @@ public class BubbleData {
                bubbleToReturn = mPendingBubbles.get(key);
            } else if (entry != null) {
                // New bubble
                bubbleToReturn = new Bubble(entry, mSuppressionListener, mCancelledListener,
                bubbleToReturn = new Bubble(entry, mBubbleMetadataFlagListener, mCancelledListener,
                        mMainExecutor);
            } else {
                // Persisted bubble being promoted
+4 −4
Original line number Diff line number Diff line
@@ -263,10 +263,10 @@ public interface Bubbles {
        void onBubbleExpandChanged(boolean isExpanding, String key);
    }

    /** Listener to be notified when the flags for notification or bubble suppression changes.*/
    interface SuppressionChangedListener {
        /** Called when the notification suppression state of a bubble changes. */
        void onBubbleNotificationSuppressionChange(Bubble bubble);
    /** Listener to be notified when the flags on BubbleMetadata have changed. */
    interface BubbleMetadataFlagListener {
        /** Called when the flags on BubbleMetadata have changed for the provided bubble. */
        void onBubbleMetadataFlagChanged(Bubble bubble);
    }

    /** Listener to be notified when a pending intent has been canceled for a bubble. */
Loading