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

Commit 43ce3698 authored by Mady Mellor's avatar Mady Mellor Committed by Automerger Merge Worker
Browse files

Merge changes Ieb77b211,Iad01b8f3,Ib9653ed3 into tm-dev am: e8ee9cd8

parents c3e479b2 e8ee9cd8
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -88,7 +88,7 @@ interface IStatusBarService
            in int notificationLocation, boolean modifiedBeforeSending);
            in int notificationLocation, boolean modifiedBeforeSending);
    void onNotificationSettingsViewed(String key);
    void onNotificationSettingsViewed(String key);
    void onNotificationBubbleChanged(String key, boolean isBubble, int flags);
    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 hideCurrentInputMethodForBubbles();
    void grantInlineReplyUriPermission(String key, in Uri uri, in UserHandle user, String packageName);
    void grantInlineReplyUriPermission(String key, in Uri uri, in UserHandle user, String packageName);
    oneway void clearInlineReplyUriPermissions(String key);
    oneway void clearInlineReplyUriPermissions(String key);
+17 −8
Original line number Original line Diff line number Diff line
@@ -71,7 +71,7 @@ public class Bubble implements BubbleViewProvider {
    private long mLastAccessed;
    private long mLastAccessed;


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


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


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


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


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


@@ -771,12 +771,17 @@ public class Bubble implements BubbleViewProvider {
        return isEnabled(Notification.BubbleMetadata.FLAG_AUTO_EXPAND_BUBBLE);
        return isEnabled(Notification.BubbleMetadata.FLAG_AUTO_EXPAND_BUBBLE);
    }
    }


    void setShouldAutoExpand(boolean shouldAutoExpand) {
    @VisibleForTesting
    public void setShouldAutoExpand(boolean shouldAutoExpand) {
        boolean prevAutoExpand = shouldAutoExpand();
        if (shouldAutoExpand) {
        if (shouldAutoExpand) {
            enable(Notification.BubbleMetadata.FLAG_AUTO_EXPAND_BUBBLE);
            enable(Notification.BubbleMetadata.FLAG_AUTO_EXPAND_BUBBLE);
        } else {
        } else {
            disable(Notification.BubbleMetadata.FLAG_AUTO_EXPAND_BUBBLE);
            disable(Notification.BubbleMetadata.FLAG_AUTO_EXPAND_BUBBLE);
        }
        }
        if (prevAutoExpand != shouldAutoExpand && mBubbleMetadataFlagListener != null) {
            mBubbleMetadataFlagListener.onBubbleMetadataFlagChanged(this);
        }
    }
    }


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


    public int getFlags() {
        return mFlags;
    }

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


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


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


    @VisibleForTesting
    @VisibleForTesting
    public void onBubbleNotificationSuppressionChanged(Bubble bubble) {
    public void onBubbleMetadataFlagChanged(Bubble bubble) {
        // Make sure NoMan knows suppression state so that anyone querying it can tell.
        // Make sure NoMan knows suppression state so that anyone querying it can tell.
        try {
        try {
            mBarService.onBubbleNotificationSuppressionChanged(bubble.getKey(),
            mBarService.onBubbleMetadataFlagChanged(bubble.getKey(), bubble.getFlags());
                    !bubble.showInShade(), bubble.isSuppressed());
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            // Bad things have happened
            // Bad things have happened
        }
        }
@@ -1038,9 +1037,17 @@ public class BubbleController {
            }
            }
        } else {
        } else {
            Bubble bubble = mBubbleData.getOrCreateBubble(notif, null /* persistedBubble */);
            Bubble bubble = mBubbleData.getOrCreateBubble(notif, null /* persistedBubble */);
            if (notif.shouldSuppressNotificationList()) {
                // If we're suppressing notifs for DND, we don't want the bubbles to randomly
                // expand when DND turns off so flip the flag.
                if (bubble.shouldAutoExpand()) {
                    bubble.setShouldAutoExpand(false);
                }
            } else {
                inflateAndAdd(bubble, suppressFlyout, showInShade);
                inflateAndAdd(bubble, suppressFlyout, showInShade);
            }
            }
        }
        }
    }


    void inflateAndAdd(Bubble bubble, boolean suppressFlyout, boolean showInShade) {
    void inflateAndAdd(Bubble bubble, boolean suppressFlyout, boolean showInShade) {
        // Lazy init stack view when a bubble is created
        // Lazy init stack view when a bubble is created
@@ -1070,7 +1077,8 @@ public class BubbleController {
        }
        }
    }
    }


    private void onEntryUpdated(BubbleEntry entry, boolean shouldBubbleUp) {
    @VisibleForTesting
    public void onEntryUpdated(BubbleEntry entry, boolean shouldBubbleUp) {
        // shouldBubbleUp checks canBubble & for bubble metadata
        // shouldBubbleUp checks canBubble & for bubble metadata
        boolean shouldBubble = shouldBubbleUp && canLaunchInTaskView(mContext, entry);
        boolean shouldBubble = shouldBubbleUp && canLaunchInTaskView(mContext, entry);
        if (!shouldBubble && mBubbleData.hasAnyBubbleWithKey(entry.getKey())) {
        if (!shouldBubble && mBubbleData.hasAnyBubbleWithKey(entry.getKey())) {
@@ -1096,7 +1104,8 @@ public class BubbleController {
        }
        }
    }
    }


    private void onRankingUpdated(RankingMap rankingMap,
    @VisibleForTesting
    public void onRankingUpdated(RankingMap rankingMap,
            HashMap<String, Pair<BubbleEntry, Boolean>> entryDataByKey) {
            HashMap<String, Pair<BubbleEntry, Boolean>> entryDataByKey) {
        if (mTmpRanking == null) {
        if (mTmpRanking == null) {
            mTmpRanking = new NotificationListenerService.Ranking();
            mTmpRanking = new NotificationListenerService.Ranking();
@@ -1107,19 +1116,22 @@ public class BubbleController {
            Pair<BubbleEntry, Boolean> entryData = entryDataByKey.get(key);
            Pair<BubbleEntry, Boolean> entryData = entryDataByKey.get(key);
            BubbleEntry entry = entryData.first;
            BubbleEntry entry = entryData.first;
            boolean shouldBubbleUp = entryData.second;
            boolean shouldBubbleUp = entryData.second;

            if (entry != null && !isCurrentProfile(
            if (entry != null && !isCurrentProfile(
                    entry.getStatusBarNotification().getUser().getIdentifier())) {
                    entry.getStatusBarNotification().getUser().getIdentifier())) {
                return;
                return;
            }
            }

            if (entry != null && (entry.shouldSuppressNotificationList()
                    || entry.getRanking().isSuspended())) {
                shouldBubbleUp = false;
            }
            rankingMap.getRanking(key, mTmpRanking);
            rankingMap.getRanking(key, mTmpRanking);
            boolean isActiveBubble = mBubbleData.hasAnyBubbleWithKey(key);
            boolean isActiveOrInOverflow = mBubbleData.hasAnyBubbleWithKey(key);
            if (isActiveBubble && !mTmpRanking.canBubble()) {
            boolean isActive = mBubbleData.hasBubbleInStackWithKey(key);
            if (isActiveOrInOverflow && !mTmpRanking.canBubble()) {
                // If this entry is no longer allowed to bubble, dismiss with the BLOCKED reason.
                // If this entry is no longer allowed to bubble, dismiss with the BLOCKED reason.
                // This means that the app or channel's ability to bubble has been revoked.
                // This means that the app or channel's ability to bubble has been revoked.
                mBubbleData.dismissBubbleWithKey(key, DISMISS_BLOCKED);
                mBubbleData.dismissBubbleWithKey(key, DISMISS_BLOCKED);
            } else if (isActiveBubble && (!shouldBubbleUp || entry.getRanking().isSuspended())) {
            } else if (isActiveOrInOverflow && !shouldBubbleUp) {
                // If this entry is allowed to bubble, but cannot currently bubble up or is
                // If this entry is allowed to bubble, but cannot currently bubble up or is
                // suspended, dismiss it. This happens when DND is enabled and configured to hide
                // suspended, dismiss it. This happens when DND is enabled and configured to hide
                // bubbles, or focus mode is enabled and the app is designated as distracting.
                // bubbles, or focus mode is enabled and the app is designated as distracting.
@@ -1127,9 +1139,9 @@ public class BubbleController {
                // notification, so that the bubble will be re-created if shouldBubbleUp returns
                // notification, so that the bubble will be re-created if shouldBubbleUp returns
                // true.
                // true.
                mBubbleData.dismissBubbleWithKey(key, DISMISS_NO_BUBBLE_UP);
                mBubbleData.dismissBubbleWithKey(key, DISMISS_NO_BUBBLE_UP);
            } else if (entry != null && mTmpRanking.isBubble() && !isActiveBubble) {
            } else if (entry != null && mTmpRanking.isBubble() && !isActive) {
                entry.setFlagBubble(true);
                entry.setFlagBubble(true);
                onEntryUpdated(entry, shouldBubbleUp && !entry.getRanking().isSuspended());
                onEntryUpdated(entry, shouldBubbleUp);
            }
            }
        }
        }
    }
    }
+20 −5
Original line number Original line Diff line number Diff line
@@ -159,7 +159,7 @@ public class BubbleData {
    private Listener mListener;
    private Listener mListener;


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


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


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


    public void setPendingIntentCancelledListener(
    public void setPendingIntentCancelledListener(
@@ -311,7 +310,7 @@ public class BubbleData {
                bubbleToReturn = mPendingBubbles.get(key);
                bubbleToReturn = mPendingBubbles.get(key);
            } else if (entry != null) {
            } else if (entry != null) {
                // New bubble
                // New bubble
                bubbleToReturn = new Bubble(entry, mSuppressionListener, mCancelledListener,
                bubbleToReturn = new Bubble(entry, mBubbleMetadataFlagListener, mCancelledListener,
                        mMainExecutor);
                        mMainExecutor);
            } else {
            } else {
                // Persisted bubble being promoted
                // Persisted bubble being promoted
@@ -1058,6 +1057,22 @@ public class BubbleData {
        return null;
        return null;
    }
    }


    /**
     * Get a pending bubble with given notification <code>key</code>
     *
     * @param key notification key
     * @return bubble that matches or null
     */
    @VisibleForTesting(visibility = PRIVATE)
    public Bubble getPendingBubbleWithKey(String key) {
        for (Bubble b : mPendingBubbles.values()) {
            if (b.getKey().equals(key)) {
                return b;
            }
        }
        return null;
    }

    @VisibleForTesting(visibility = PRIVATE)
    @VisibleForTesting(visibility = PRIVATE)
    void setTimeSource(TimeSource timeSource) {
    void setTimeSource(TimeSource timeSource) {
        mTimeSource = timeSource;
        mTimeSource = timeSource;
+4 −4
Original line number Original line Diff line number Diff line
@@ -263,10 +263,10 @@ public interface Bubbles {
        void onBubbleExpandChanged(boolean isExpanding, String key);
        void onBubbleExpandChanged(boolean isExpanding, String key);
    }
    }


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


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