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

Commit 076abc38 authored by Lyn Han's avatar Lyn Han
Browse files

Fix missing notifs after swipe

Sometimes, when you swipe away a notification in the shade and
that notification has a bubble, the shade does not update to fill
the blank space.

How this happened:
- ShadeListBuilder depends on BubbleCoordinator's NotifFilter to
  tell it which notifications to filter out
- BubbleCoordinator checks BubbleController's CachedState to see
  which notifications to suppress
- BubbleController's
    CachedState #updateBubbleSuppressedState (and
    #onBubbleMetadataFlagChanged upstream) did not run because
- In Bubble #setSuppressNotification
    mBubbleMetadataFlagListener is null, since it was never set
    by the Bubble constructor when loading bubbles from disk
    (unlike the Bubble constructor used for new bubbles)

This change
- sets BubbleMetadataFlagListener on bubbles loaded
  from disk so that their CachedStates update after their
  notifications are swiped away from the shade.
- removes @Nullable annotation from BubbleMetadataFlagListener
  param and var declarations
- adds dumpsys log so we can check it doesn't happen again.

Fixes: 237897866

Test: have some BubbleChat bubbles, reboot phone
=> send messages from same chats to bring back same bubbles
=> swipe away shade notifications for these chats
=> see that notifs below move up to fill blank space

Change-Id: Id61814fdc5fee87197f5ca48ae0bc469b713fab5
parent 28636f87
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -170,7 +170,8 @@ public class Bubble implements BubbleViewProvider {
    @VisibleForTesting(visibility = PRIVATE)
    public Bubble(@NonNull final String key, @NonNull final ShortcutInfo shortcutInfo,
            final int desiredHeight, final int desiredHeightResId, @Nullable final String title,
            int taskId, @Nullable final String locus, Executor mainExecutor) {
            int taskId, @Nullable final String locus, Executor mainExecutor,
            final Bubbles.BubbleMetadataFlagListener listener) {
        Objects.requireNonNull(key);
        Objects.requireNonNull(shortcutInfo);
        mMetadataShortcutId = shortcutInfo.getId();
@@ -188,11 +189,12 @@ public class Bubble implements BubbleViewProvider {
        mShowBubbleUpdateDot = false;
        mMainExecutor = mainExecutor;
        mTaskId = taskId;
        mBubbleMetadataFlagListener = listener;
    }

    @VisibleForTesting(visibility = PRIVATE)
    public Bubble(@NonNull final BubbleEntry entry,
            @Nullable final Bubbles.BubbleMetadataFlagListener listener,
            final Bubbles.BubbleMetadataFlagListener listener,
            final Bubbles.PendingIntentCanceledListener intentCancelListener,
            Executor mainExecutor) {
        mKey = entry.getKey();
@@ -830,6 +832,7 @@ public class Bubble implements BubbleViewProvider {
        pw.print("  desiredHeight: "); pw.println(getDesiredHeightString());
        pw.print("  suppressNotif: "); pw.println(shouldSuppressNotification());
        pw.print("  autoExpand:    "); pw.println(shouldAutoExpand());
        pw.print("  bubbleMetadataFlagListener null: " + (mBubbleMetadataFlagListener == null));
        if (mExpandedView != null) {
            mExpandedView.dump(pw);
        }
+1 −0
Original line number Diff line number Diff line
@@ -309,6 +309,7 @@ public class BubbleController implements ConfigurationChangeListener {
    protected void onInit() {
        mBubbleData.setListener(mBubbleDataListener);
        mBubbleData.setSuppressionChangedListener(this::onBubbleMetadataFlagChanged);
        mDataRepository.setSuppressionChangedListener(this::onBubbleMetadataFlagChanged);

        mBubbleData.setPendingIntentCancelledListener(bubble -> {
            if (bubble.getBubbleIntent() == null) {
+0 −1
Original line number Diff line number Diff line
@@ -158,7 +158,6 @@ public class BubbleData {
    @Nullable
    private Listener mListener;

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

+10 −1
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.content.pm.LauncherApps.ShortcutQuery.FLAG_MATCH_PINNED_BY_ANY_LA
import android.content.pm.UserInfo
import android.os.UserHandle
import android.util.Log
import com.android.wm.shell.bubbles.Bubbles.BubbleMetadataFlagListener
import com.android.wm.shell.bubbles.storage.BubbleEntity
import com.android.wm.shell.bubbles.storage.BubblePersistentRepository
import com.android.wm.shell.bubbles.storage.BubbleVolatileRepository
@@ -47,6 +48,13 @@ internal class BubbleDataRepository(
    private val ioScope = CoroutineScope(Dispatchers.IO)
    private var job: Job? = null

    // For use in Bubble construction.
    private lateinit var bubbleMetadataFlagListener: BubbleMetadataFlagListener

    fun setSuppressionChangedListener(listener: BubbleMetadataFlagListener) {
        bubbleMetadataFlagListener = listener
    }

    /**
     * Adds the bubble in memory, then persists the snapshot after adding the bubble to disk
     * asynchronously.
@@ -197,7 +205,8 @@ internal class BubbleDataRepository(
                                entity.title,
                                entity.taskId,
                                entity.locus,
                                mainExecutor
                                mainExecutor,
                                bubbleMetadataFlagListener
                        )
                    }
        }