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

Commit c13216f4 authored by Mady Mellor's avatar Mady Mellor
Browse files

Migrate Bubbles to ProtoLog

Previously most of bubbles logging required you to rebuild and
flip flags in BubbleDebugConfig. Additionally, some of the logs were
a bit spammy and unhelpful.

This CL attempts to clean the logging up, add some additional logging,
and migrate most of the non-error related logs to ProtoLog.

I think there might still be some logs to prune / add but this should
be more useful than it was before.

Test: make && adb shell dumpsys activity service SystemUIService WMShell protolog enable-text WM_SHELL_BUBBLES
      and observe the logs
Bug: 323591549
Change-Id: If528dc0adcf5910fd62a4229777cfd391a2f7307
parent 74f4fa70
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -19,6 +19,7 @@ import static android.app.ActivityTaskManager.INVALID_TASK_ID;
import static android.os.AsyncTask.Status.FINISHED;
import static android.os.AsyncTask.Status.FINISHED;


import static com.android.internal.annotations.VisibleForTesting.Visibility.PRIVATE;
import static com.android.internal.annotations.VisibleForTesting.Visibility.PRIVATE;
import static com.android.wm.shell.protolog.ShellProtoLogGroup.WM_SHELL_BUBBLES;


import android.annotation.DimenRes;
import android.annotation.DimenRes;
import android.annotation.Hide;
import android.annotation.Hide;
@@ -47,6 +48,7 @@ import android.util.Log;


import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.logging.InstanceId;
import com.android.internal.logging.InstanceId;
import com.android.internal.protolog.common.ProtoLog;
import com.android.launcher3.icons.BubbleIconFactory;
import com.android.launcher3.icons.BubbleIconFactory;
import com.android.wm.shell.bubbles.bar.BubbleBarExpandedView;
import com.android.wm.shell.bubbles.bar.BubbleBarExpandedView;
import com.android.wm.shell.bubbles.bar.BubbleBarLayerView;
import com.android.wm.shell.bubbles.bar.BubbleBarLayerView;
@@ -466,6 +468,7 @@ public class Bubble implements BubbleViewProvider {
     * Call when all the views should be removed/cleaned up.
     * Call when all the views should be removed/cleaned up.
     */
     */
    public void cleanupViews() {
    public void cleanupViews() {
        ProtoLog.d(WM_SHELL_BUBBLES, "Bubble#cleanupViews=%s", getKey());
        cleanupViews(true);
        cleanupViews(true);
    }
    }


+40 −23
Original line number Original line Diff line number Diff line
@@ -23,7 +23,6 @@ import static android.view.View.INVISIBLE;
import static android.view.View.VISIBLE;
import static android.view.View.VISIBLE;
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;


import static com.android.wm.shell.bubbles.BubbleDebugConfig.DEBUG_BUBBLE_CONTROLLER;
import static com.android.wm.shell.bubbles.BubbleDebugConfig.TAG_BUBBLES;
import static com.android.wm.shell.bubbles.BubbleDebugConfig.TAG_BUBBLES;
import static com.android.wm.shell.bubbles.BubbleDebugConfig.TAG_WITH_CLASS_NAME;
import static com.android.wm.shell.bubbles.BubbleDebugConfig.TAG_WITH_CLASS_NAME;
import static com.android.wm.shell.bubbles.Bubbles.DISMISS_BLOCKED;
import static com.android.wm.shell.bubbles.Bubbles.DISMISS_BLOCKED;
@@ -435,6 +434,9 @@ public class BubbleController implements ConfigurationChangeListener,
                    boolean homeTaskVisible, boolean clearedTask, boolean wasVisible) {
                    boolean homeTaskVisible, boolean clearedTask, boolean wasVisible) {
                for (Bubble b : mBubbleData.getBubbles()) {
                for (Bubble b : mBubbleData.getBubbles()) {
                    if (task.taskId == b.getTaskId()) {
                    if (task.taskId == b.getTaskId()) {
                        ProtoLog.d(WM_SHELL_BUBBLES,
                                "onActivityRestartAttempt - taskId=%d selecting matching bubble=%s",
                                task.taskId, b.getKey());
                        mBubbleData.setSelectedBubble(b);
                        mBubbleData.setSelectedBubble(b);
                        mBubbleData.setExpanded(true);
                        mBubbleData.setExpanded(true);
                        return;
                        return;
@@ -442,6 +444,9 @@ public class BubbleController implements ConfigurationChangeListener,
                }
                }
                for (Bubble b : mBubbleData.getOverflowBubbles()) {
                for (Bubble b : mBubbleData.getOverflowBubbles()) {
                    if (task.taskId == b.getTaskId()) {
                    if (task.taskId == b.getTaskId()) {
                        ProtoLog.d(WM_SHELL_BUBBLES, "onActivityRestartAttempt - taskId=%d "
                                        + "selecting matching overflow bubble=%s",
                                task.taskId, b.getKey());
                        promoteBubbleFromOverflow(b);
                        promoteBubbleFromOverflow(b);
                        mBubbleData.setExpanded(true);
                        mBubbleData.setExpanded(true);
                        return;
                        return;
@@ -581,10 +586,15 @@ public class BubbleController implements ConfigurationChangeListener,
            // Hide the stack temporarily if the status bar has been made invisible, and the stack
            // Hide the stack temporarily if the status bar has been made invisible, and the stack
            // is collapsed. An expanded stack should remain visible until collapsed.
            // is collapsed. An expanded stack should remain visible until collapsed.
            mStackView.setTemporarilyInvisible(!visible && !isStackExpanded());
            mStackView.setTemporarilyInvisible(!visible && !isStackExpanded());
            ProtoLog.d(WM_SHELL_BUBBLES, "onStatusBarVisibilityChanged=%b stackExpanded=%b",
                    visible, isStackExpanded());
        }
        }
    }
    }


    private void onZenStateChanged() {
    private void onZenStateChanged() {
        if (hasBubbles()) {
            ProtoLog.d(WM_SHELL_BUBBLES, "onZenStateChanged");
        }
        for (Bubble b : mBubbleData.getBubbles()) {
        for (Bubble b : mBubbleData.getBubbles()) {
            b.setShowDot(b.showInShade());
            b.setShowDot(b.showInShade());
        }
        }
@@ -593,9 +603,10 @@ public class BubbleController implements ConfigurationChangeListener,
    @VisibleForTesting
    @VisibleForTesting
    public void onStatusBarStateChanged(boolean isShade) {
    public void onStatusBarStateChanged(boolean isShade) {
        boolean didChange = mIsStatusBarShade != isShade;
        boolean didChange = mIsStatusBarShade != isShade;
        if (DEBUG_BUBBLE_CONTROLLER) {
        ProtoLog.d(WM_SHELL_BUBBLES, "onStatusBarStateChanged "
            Log.d(TAG, "onStatusBarStateChanged isShade=" + isShade + " didChange=" + didChange);
                        + "isShade=%b didChange=%b mNotifEntryToExpandOnShadeUnlock=%s",
        }
                isShade, didChange, (mNotifEntryToExpandOnShadeUnlock != null
                        ? mNotifEntryToExpandOnShadeUnlock.getKey() : "null"));
        mIsStatusBarShade = isShade;
        mIsStatusBarShade = isShade;
        if (!mIsStatusBarShade && didChange) {
        if (!mIsStatusBarShade && didChange) {
            // Only collapse stack on change
            // Only collapse stack on change
@@ -611,6 +622,8 @@ public class BubbleController implements ConfigurationChangeListener,


    @VisibleForTesting
    @VisibleForTesting
    public void onBubbleMetadataFlagChanged(Bubble bubble) {
    public void onBubbleMetadataFlagChanged(Bubble bubble) {
        ProtoLog.d(WM_SHELL_BUBBLES, "onBubbleMetadataFlagChanged=%s flags=%d",
                bubble.getKey(), bubble.getFlags());
        // 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.onBubbleMetadataFlagChanged(bubble.getKey(), bubble.getFlags());
            mBarService.onBubbleMetadataFlagChanged(bubble.getKey(), bubble.getFlags());
@@ -623,6 +636,8 @@ public class BubbleController implements ConfigurationChangeListener,
    /** Called when the current user changes. */
    /** Called when the current user changes. */
    @VisibleForTesting
    @VisibleForTesting
    public void onUserChanged(int newUserId) {
    public void onUserChanged(int newUserId) {
        ProtoLog.d(WM_SHELL_BUBBLES, "onUserChanged currentUser=%d newUser=%d",
                mCurrentUserId, newUserId);
        saveBubbles(mCurrentUserId);
        saveBubbles(mCurrentUserId);
        mCurrentUserId = newUserId;
        mCurrentUserId = newUserId;


@@ -825,6 +840,7 @@ public class BubbleController implements ConfigurationChangeListener,
     */
     */
    void updateWindowFlagsForBackpress(boolean interceptBack) {
    void updateWindowFlagsForBackpress(boolean interceptBack) {
        if (mAddedToWindowManager) {
        if (mAddedToWindowManager) {
            ProtoLog.d(WM_SHELL_BUBBLES, "updateFlagsForBackPress interceptBack=%b", interceptBack);
            mWmLayoutParams.flags = interceptBack
            mWmLayoutParams.flags = interceptBack
                    ? 0
                    ? 0
                    : WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                    : WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
@@ -1014,8 +1030,9 @@ public class BubbleController implements ConfigurationChangeListener,
    }
    }


    private void onNotificationPanelExpandedChanged(boolean expanded) {
    private void onNotificationPanelExpandedChanged(boolean expanded) {
        ProtoLog.d(WM_SHELL_BUBBLES, "onNotificationPanelExpandedChanged: expanded=%b", expanded);
        if (mStackView != null && mStackView.isExpanded()) {
        if (mStackView != null && mStackView.isExpanded()) {
            ProtoLog.d(WM_SHELL_BUBBLES,
                    "onNotificationPanelExpandedChanged expanded=%b", expanded);
            if (expanded) {
            if (expanded) {
                mStackView.stopMonitoringSwipeUpGesture();
                mStackView.stopMonitoringSwipeUpGesture();
            } else {
            } else {
@@ -1096,6 +1113,7 @@ public class BubbleController implements ConfigurationChangeListener,
    /** Promote the provided bubble from the overflow view. */
    /** Promote the provided bubble from the overflow view. */
    public void promoteBubbleFromOverflow(Bubble bubble) {
    public void promoteBubbleFromOverflow(Bubble bubble) {
        mLogger.log(bubble, BubbleLogger.Event.BUBBLE_OVERFLOW_REMOVE_BACK_TO_STACK);
        mLogger.log(bubble, BubbleLogger.Event.BUBBLE_OVERFLOW_REMOVE_BACK_TO_STACK);
        ProtoLog.d(WM_SHELL_BUBBLES, "promoteBubbleFromOverflow=%s", bubble.getKey());
        bubble.setInflateSynchronously(mInflateSynchronously);
        bubble.setInflateSynchronously(mInflateSynchronously);
        bubble.setShouldAutoExpand(true);
        bubble.setShouldAutoExpand(true);
        bubble.markAsAccessedAt(System.currentTimeMillis());
        bubble.markAsAccessedAt(System.currentTimeMillis());
@@ -1211,11 +1229,8 @@ public class BubbleController implements ConfigurationChangeListener,
            // Skip update, but store it in user bubbles so it gets restored after user switch
            // Skip update, but store it in user bubbles so it gets restored after user switch
            mSavedUserBubbleData.get(bubbleUserId, new UserBubbleData()).add(notif.getKey(),
            mSavedUserBubbleData.get(bubbleUserId, new UserBubbleData()).add(notif.getKey(),
                    true /* shownInShade */);
                    true /* shownInShade */);
            if (DEBUG_BUBBLE_CONTROLLER) {
            Log.w(TAG, "updateBubble, ignore update for non-active user=" + bubbleUserId
                Log.d(TAG,
                    + " currentUser=" + mCurrentUserId);
                        "Ignore update to bubble for not active user. Bubble userId=" + bubbleUserId
                                + " current userId=" + mCurrentUserId);
            }
        }
        }
    }
    }


@@ -1769,18 +1784,19 @@ public class BubbleController implements ConfigurationChangeListener,


        @Override
        @Override
        public void applyUpdate(BubbleData.Update update) {
        public void applyUpdate(BubbleData.Update update) {
            if (DEBUG_BUBBLE_CONTROLLER) {
            ProtoLog.d(WM_SHELL_BUBBLES, "mBubbleDataListener#applyUpdate:"
                Log.d(TAG, "applyUpdate:" + " bubbleAdded=" + (update.addedBubble != null)
                    + " added=%s removed=%b updated=%s orderChanged=%b expansionChanged=%b"
                        + " bubbleRemoved="
                    + " expanded=%b selectionChanged=%b selected=%s"
                        + (update.removedBubbles != null && update.removedBubbles.size() > 0)
                    + " suppressed=%s unsupressed=%s shouldShowEducation=%b",
                        + " bubbleUpdated=" + (update.updatedBubble != null)
                    update.addedBubble != null ? update.addedBubble.getKey() : "null",
                        + " orderChanged=" + update.orderChanged
                    update.removedBubbles.isEmpty(),
                        + " expandedChanged=" + update.expandedChanged
                    update.updatedBubble != null ? update.updatedBubble.getKey() : "null",
                        + " selectionChanged=" + update.selectionChanged
                    update.orderChanged, update.expandedChanged, update.expanded,
                        + " suppressed=" + (update.suppressedBubble != null)
                    update.selectionChanged,
                        + " unsuppressed=" + (update.unsuppressedBubble != null)
                    update.selectedBubble != null ? update.selectedBubble.getKey() : "null",
                        + " shouldShowEducation=" + update.shouldShowEducation);
                    update.suppressedBubble != null ? update.suppressedBubble.getKey() : "null",
            }
                    update.unsuppressedBubble != null ? update.unsuppressedBubble.getKey() : "null",
                    update.shouldShowEducation);


            ensureBubbleViewsAndWindowCreated();
            ensureBubbleViewsAndWindowCreated();


@@ -1974,7 +1990,8 @@ public class BubbleController implements ConfigurationChangeListener,
        if (mStackView == null && mLayerView == null) {
        if (mStackView == null && mLayerView == null) {
            return;
            return;
        }
        }

        ProtoLog.v(WM_SHELL_BUBBLES, "updateBubbleViews mIsStatusBarShade=%s hasBubbles=%s",
                mIsStatusBarShade, hasBubbles());
        if (!mIsStatusBarShade) {
        if (!mIsStatusBarShade) {
            // Bubbles don't appear when the device is locked.
            // Bubbles don't appear when the device is locked.
            if (mStackView != null) {
            if (mStackView != null) {
+25 −62
Original line number Original line Diff line number Diff line
@@ -16,10 +16,9 @@
package com.android.wm.shell.bubbles;
package com.android.wm.shell.bubbles;


import static com.android.internal.annotations.VisibleForTesting.Visibility.PRIVATE;
import static com.android.internal.annotations.VisibleForTesting.Visibility.PRIVATE;
import static com.android.wm.shell.bubbles.Bubble.KEY_APP_BUBBLE;
import static com.android.wm.shell.bubbles.BubbleDebugConfig.DEBUG_BUBBLE_DATA;
import static com.android.wm.shell.bubbles.BubbleDebugConfig.TAG_BUBBLES;
import static com.android.wm.shell.bubbles.BubbleDebugConfig.TAG_BUBBLES;
import static com.android.wm.shell.bubbles.BubbleDebugConfig.TAG_WITH_CLASS_NAME;
import static com.android.wm.shell.bubbles.BubbleDebugConfig.TAG_WITH_CLASS_NAME;
import static com.android.wm.shell.protolog.ShellProtoLogGroup.WM_SHELL_BUBBLES;


import android.annotation.NonNull;
import android.annotation.NonNull;
import android.app.PendingIntent;
import android.app.PendingIntent;
@@ -36,6 +35,7 @@ import android.view.View;
import androidx.annotation.Nullable;
import androidx.annotation.Nullable;


import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.protolog.common.ProtoLog;
import com.android.internal.util.FrameworkStatsLog;
import com.android.internal.util.FrameworkStatsLog;
import com.android.launcher3.icons.BubbleIconFactory;
import com.android.launcher3.icons.BubbleIconFactory;
import com.android.wm.shell.R;
import com.android.wm.shell.R;
@@ -333,9 +333,6 @@ public class BubbleData {
    }
    }


    public void setExpanded(boolean expanded) {
    public void setExpanded(boolean expanded) {
        if (DEBUG_BUBBLE_DATA) {
            Log.d(TAG, "setExpanded: " + expanded);
        }
        setExpandedInternal(expanded);
        setExpandedInternal(expanded);
        dispatchPendingChanges();
        dispatchPendingChanges();
    }
    }
@@ -347,9 +344,8 @@ public class BubbleData {
     * updated to have the correct state.
     * updated to have the correct state.
     */
     */
    public void setSelectedBubbleFromLauncher(BubbleViewProvider bubble) {
    public void setSelectedBubbleFromLauncher(BubbleViewProvider bubble) {
        if (DEBUG_BUBBLE_DATA) {
        ProtoLog.d(WM_SHELL_BUBBLES, "setSelectedBubbleFromLauncher=%s",
            Log.d(TAG, "setSelectedBubbleFromLauncher: " + bubble);
                (bubble != null ? bubble.getKey() : "null"));
        }
        mExpanded = true;
        mExpanded = true;
        if (Objects.equals(bubble, mSelectedBubble)) {
        if (Objects.equals(bubble, mSelectedBubble)) {
            return;
            return;
@@ -370,9 +366,6 @@ public class BubbleData {
    }
    }


    public void setSelectedBubble(BubbleViewProvider bubble) {
    public void setSelectedBubble(BubbleViewProvider bubble) {
        if (DEBUG_BUBBLE_DATA) {
            Log.d(TAG, "setSelectedBubble: " + bubble);
        }
        setSelectedBubbleInternal(bubble);
        setSelectedBubbleInternal(bubble);
        dispatchPendingChanges();
        dispatchPendingChanges();
    }
    }
@@ -430,12 +423,13 @@ public class BubbleData {
     * BubbleBarLayerView, BubbleIconFactory, boolean)
     * BubbleBarLayerView, BubbleIconFactory, boolean)
     */
     */
    void notificationEntryUpdated(Bubble bubble, boolean suppressFlyout, boolean showInShade) {
    void notificationEntryUpdated(Bubble bubble, boolean suppressFlyout, boolean showInShade) {
        if (DEBUG_BUBBLE_DATA) {
            Log.d(TAG, "notificationEntryUpdated: " + bubble);
        }
        mPendingBubbles.remove(bubble.getKey()); // No longer pending once we're here
        mPendingBubbles.remove(bubble.getKey()); // No longer pending once we're here
        Bubble prevBubble = getBubbleInStackWithKey(bubble.getKey());
        Bubble prevBubble = getBubbleInStackWithKey(bubble.getKey());
        suppressFlyout |= !bubble.isTextChanged();
        suppressFlyout |= !bubble.isTextChanged();
        ProtoLog.d(WM_SHELL_BUBBLES,
                "notifEntryUpdated=%s prevBubble=%b suppressFlyout=%b showInShade=%b autoExpand=%b",
                bubble.getKey(), (prevBubble != null), suppressFlyout, showInShade,
                bubble.shouldAutoExpand());


        if (prevBubble == null) {
        if (prevBubble == null) {
            // Create a new bubble
            // Create a new bubble
@@ -483,9 +477,6 @@ public class BubbleData {
     * Dismisses the bubble with the matching key, if it exists.
     * Dismisses the bubble with the matching key, if it exists.
     */
     */
    public void dismissBubbleWithKey(String key, @DismissReason int reason) {
    public void dismissBubbleWithKey(String key, @DismissReason int reason) {
        if (DEBUG_BUBBLE_DATA) {
            Log.d(TAG, "notificationEntryRemoved: key=" + key + " reason=" + reason);
        }
        doRemove(key, reason);
        doRemove(key, reason);
        dispatchPendingChanges();
        dispatchPendingChanges();
    }
    }
@@ -603,9 +594,7 @@ public class BubbleData {
    }
    }


    private void doAdd(Bubble bubble) {
    private void doAdd(Bubble bubble) {
        if (DEBUG_BUBBLE_DATA) {
        ProtoLog.d(WM_SHELL_BUBBLES, "doAdd=%s", bubble.getKey());
            Log.d(TAG, "doAdd: " + bubble);
        }
        mBubbles.add(0, bubble);
        mBubbles.add(0, bubble);
        mStateChange.addedBubble = bubble;
        mStateChange.addedBubble = bubble;
        // Adding the first bubble doesn't change the order
        // Adding the first bubble doesn't change the order
@@ -634,9 +623,7 @@ public class BubbleData {
    }
    }


    private void doUpdate(Bubble bubble, boolean reorder) {
    private void doUpdate(Bubble bubble, boolean reorder) {
        if (DEBUG_BUBBLE_DATA) {
        ProtoLog.d(WM_SHELL_BUBBLES, "BubbleData - doUpdate=%s", bubble.getKey());
            Log.d(TAG, "doUpdate: " + bubble);
        }
        mStateChange.updatedBubble = bubble;
        mStateChange.updatedBubble = bubble;
        if (!isExpanded() && reorder) {
        if (!isExpanded() && reorder) {
            int prevPos = mBubbles.indexOf(bubble);
            int prevPos = mBubbles.indexOf(bubble);
@@ -663,9 +650,6 @@ public class BubbleData {
    }
    }


    private void doRemove(String key, @DismissReason int reason) {
    private void doRemove(String key, @DismissReason int reason) {
        if (DEBUG_BUBBLE_DATA || (key != null && key.contains(KEY_APP_BUBBLE))) {
            Log.d(TAG, "doRemove: " + key + " reason: " + reason);
        }
        //  If it was pending remove it
        //  If it was pending remove it
        if (mPendingBubbles.containsKey(key)) {
        if (mPendingBubbles.containsKey(key)) {
            mPendingBubbles.remove(key);
            mPendingBubbles.remove(key);
@@ -686,9 +670,7 @@ public class BubbleData {
                    && shouldRemoveHiddenBubble) {
                    && shouldRemoveHiddenBubble) {


                Bubble b = getOverflowBubbleWithKey(key);
                Bubble b = getOverflowBubbleWithKey(key);
                if (DEBUG_BUBBLE_DATA) {
                ProtoLog.d(WM_SHELL_BUBBLES, "doRemove - cancel overflow bubble=%s", key);
                    Log.d(TAG, "Cancel overflow bubble: " + b);
                }
                if (b != null) {
                if (b != null) {
                    b.stopInflation();
                    b.stopInflation();
                }
                }
@@ -699,9 +681,7 @@ public class BubbleData {
            }
            }
            if (hasSuppressedBubbleWithKey(key) && shouldRemoveHiddenBubble) {
            if (hasSuppressedBubbleWithKey(key) && shouldRemoveHiddenBubble) {
                Bubble b = getSuppressedBubbleWithKey(key);
                Bubble b = getSuppressedBubbleWithKey(key);
                if (DEBUG_BUBBLE_DATA) {
                ProtoLog.d(WM_SHELL_BUBBLES, "doRemove - cancel suppressed bubble=%s", key);
                    Log.d(TAG, "Cancel suppressed bubble: " + b);
                }
                if (b != null) {
                if (b != null) {
                    mSuppressedBubbles.remove(b.getLocusId());
                    mSuppressedBubbles.remove(b.getLocusId());
                    b.stopInflation();
                    b.stopInflation();
@@ -711,6 +691,7 @@ public class BubbleData {
            return;
            return;
        }
        }
        Bubble bubbleToRemove = mBubbles.get(indexToRemove);
        Bubble bubbleToRemove = mBubbles.get(indexToRemove);
        ProtoLog.d(WM_SHELL_BUBBLES, "doRemove=%s", bubbleToRemove.getKey());
        bubbleToRemove.stopInflation();
        bubbleToRemove.stopInflation();
        overflowBubble(reason, bubbleToRemove);
        overflowBubble(reason, bubbleToRemove);


@@ -744,17 +725,12 @@ public class BubbleData {
        }
        }
        // Move selection to the new bubble at the same position.
        // Move selection to the new bubble at the same position.
        int newIndex = Math.min(indexOfSelected, mBubbles.size() - 1);
        int newIndex = Math.min(indexOfSelected, mBubbles.size() - 1);
        if (DEBUG_BUBBLE_DATA) {
            Log.d(TAG, "setNewSelectedIndex: " + indexOfSelected);
        }
        BubbleViewProvider newSelected = mBubbles.get(newIndex);
        BubbleViewProvider newSelected = mBubbles.get(newIndex);
        setSelectedBubbleInternal(newSelected);
        setSelectedBubbleInternal(newSelected);
    }
    }


    private void doSuppress(Bubble bubble) {
    private void doSuppress(Bubble bubble) {
        if (DEBUG_BUBBLE_DATA) {
        ProtoLog.d(WM_SHELL_BUBBLES, "doSuppress=%s", bubble.getKey());
            Log.d(TAG, "doSuppressed: " + bubble);
        }
        mStateChange.suppressedBubble = bubble;
        mStateChange.suppressedBubble = bubble;
        bubble.setSuppressBubble(true);
        bubble.setSuppressBubble(true);


@@ -777,9 +753,7 @@ public class BubbleData {
    }
    }


    private void doUnsuppress(Bubble bubble) {
    private void doUnsuppress(Bubble bubble) {
        if (DEBUG_BUBBLE_DATA) {
        ProtoLog.d(WM_SHELL_BUBBLES, "doUnsuppress=%s", bubble.getKey());
            Log.d(TAG, "doUnsuppressed: " + bubble);
        }
        bubble.setSuppressBubble(false);
        bubble.setSuppressBubble(false);
        mStateChange.unsuppressedBubble = bubble;
        mStateChange.unsuppressedBubble = bubble;
        mBubbles.add(bubble);
        mBubbles.add(bubble);
@@ -801,9 +775,7 @@ public class BubbleData {
                || reason == Bubbles.DISMISS_RELOAD_FROM_DISK)) {
                || reason == Bubbles.DISMISS_RELOAD_FROM_DISK)) {
            return;
            return;
        }
        }
        if (DEBUG_BUBBLE_DATA) {
        ProtoLog.d(WM_SHELL_BUBBLES, "overflowBubble=%s", bubble.getKey());
            Log.d(TAG, "Overflowing: " + bubble);
        }
        mLogger.logOverflowAdd(bubble, reason);
        mLogger.logOverflowAdd(bubble, reason);
        mOverflowBubbles.remove(bubble);
        mOverflowBubbles.remove(bubble);
        mOverflowBubbles.add(0, bubble);
        mOverflowBubbles.add(0, bubble);
@@ -812,9 +784,7 @@ public class BubbleData {
        if (mOverflowBubbles.size() == mMaxOverflowBubbles + 1) {
        if (mOverflowBubbles.size() == mMaxOverflowBubbles + 1) {
            // Remove oldest bubble.
            // Remove oldest bubble.
            Bubble oldest = mOverflowBubbles.get(mOverflowBubbles.size() - 1);
            Bubble oldest = mOverflowBubbles.get(mOverflowBubbles.size() - 1);
            if (DEBUG_BUBBLE_DATA) {
            ProtoLog.d(WM_SHELL_BUBBLES, "overflow full, remove=%s", oldest.getKey());
                Log.d(TAG, "Overflow full. Remove: " + oldest);
            }
            mStateChange.bubbleRemoved(oldest, Bubbles.DISMISS_OVERFLOW_MAX_REACHED);
            mStateChange.bubbleRemoved(oldest, Bubbles.DISMISS_OVERFLOW_MAX_REACHED);
            mLogger.log(bubble, BubbleLogger.Event.BUBBLE_OVERFLOW_REMOVE_MAX_REACHED);
            mLogger.log(bubble, BubbleLogger.Event.BUBBLE_OVERFLOW_REMOVE_MAX_REACHED);
            mOverflowBubbles.remove(oldest);
            mOverflowBubbles.remove(oldest);
@@ -823,9 +793,7 @@ public class BubbleData {
    }
    }


    public void dismissAll(@DismissReason int reason) {
    public void dismissAll(@DismissReason int reason) {
        if (DEBUG_BUBBLE_DATA) {
        ProtoLog.d(WM_SHELL_BUBBLES, "dismissAll reason=%d", reason);
            Log.d(TAG, "dismissAll: reason=" + reason);
        }
        if (mBubbles.isEmpty() && mSuppressedBubbles.isEmpty()) {
        if (mBubbles.isEmpty() && mSuppressedBubbles.isEmpty()) {
            return;
            return;
        }
        }
@@ -851,9 +819,10 @@ public class BubbleData {
     * @param visible whether the task with the locusId is visible or not.
     * @param visible whether the task with the locusId is visible or not.
     */
     */
    public void onLocusVisibilityChanged(int taskId, LocusId locusId, boolean visible) {
    public void onLocusVisibilityChanged(int taskId, LocusId locusId, boolean visible) {
        if (DEBUG_BUBBLE_DATA) {
        if (locusId == null) return;
            Log.d(TAG, "onLocusVisibilityChanged: " + locusId + " visible=" + visible);

        }
        ProtoLog.d(WM_SHELL_BUBBLES, "onLocusVisibilityChanged=%s visible=%b taskId=%d",
                locusId.getId(), visible, taskId);


        Bubble matchingBubble = getBubbleInStackWithLocusId(locusId);
        Bubble matchingBubble = getBubbleInStackWithLocusId(locusId);
        // Don't add the locus if it's from a bubble'd activity, we only suppress for non-bubbled.
        // Don't add the locus if it's from a bubble'd activity, we only suppress for non-bubbled.
@@ -910,9 +879,8 @@ public class BubbleData {
     * @param bubble the new selected bubble
     * @param bubble the new selected bubble
     */
     */
    private void setSelectedBubbleInternal(@Nullable BubbleViewProvider bubble) {
    private void setSelectedBubbleInternal(@Nullable BubbleViewProvider bubble) {
        if (DEBUG_BUBBLE_DATA) {
        ProtoLog.d(WM_SHELL_BUBBLES, "setSelectedBubbleInternal=%s",
            Log.d(TAG, "setSelectedBubbleInternal: " + bubble);
                (bubble != null ? bubble.getKey() : "null"));
        }
        if (Objects.equals(bubble, mSelectedBubble)) {
        if (Objects.equals(bubble, mSelectedBubble)) {
            return;
            return;
        }
        }
@@ -969,12 +937,10 @@ public class BubbleData {
     * @param shouldExpand the new requested state
     * @param shouldExpand the new requested state
     */
     */
    private void setExpandedInternal(boolean shouldExpand) {
    private void setExpandedInternal(boolean shouldExpand) {
        if (DEBUG_BUBBLE_DATA) {
            Log.d(TAG, "setExpandedInternal: shouldExpand=" + shouldExpand);
        }
        if (mExpanded == shouldExpand) {
        if (mExpanded == shouldExpand) {
            return;
            return;
        }
        }
        ProtoLog.d(WM_SHELL_BUBBLES, "setExpandedInternal=%b", shouldExpand);
        if (shouldExpand) {
        if (shouldExpand) {
            if (mBubbles.isEmpty() && !mShowingOverflow) {
            if (mBubbles.isEmpty() && !mShowingOverflow) {
                Log.e(TAG, "Attempt to expand stack when empty!");
                Log.e(TAG, "Attempt to expand stack when empty!");
@@ -1026,9 +992,6 @@ public class BubbleData {
     * @return true if the position of any bubbles changed as a result
     * @return true if the position of any bubbles changed as a result
     */
     */
    private boolean repackAll() {
    private boolean repackAll() {
        if (DEBUG_BUBBLE_DATA) {
            Log.d(TAG, "repackAll()");
        }
        if (mBubbles.isEmpty()) {
        if (mBubbles.isEmpty()) {
            return false;
            return false;
        }
        }
+0 −10
Original line number Original line Diff line number Diff line
@@ -37,17 +37,7 @@ public class BubbleDebugConfig {


    // Default log tag for the Bubbles package.
    // Default log tag for the Bubbles package.
    public static final String TAG_BUBBLES = "Bubbles";
    public static final String TAG_BUBBLES = "Bubbles";

    static final boolean DEBUG_BUBBLE_CONTROLLER = false;
    static final boolean DEBUG_BUBBLE_DATA = false;
    static final boolean DEBUG_BUBBLE_STACK_VIEW = false;
    static final boolean DEBUG_BUBBLE_EXPANDED_VIEW = false;
    static final boolean DEBUG_EXPERIMENTS = true;
    static final boolean DEBUG_OVERFLOW = false;
    public static final boolean DEBUG_USER_EDUCATION = false;
    public static final boolean DEBUG_USER_EDUCATION = false;
    static final boolean DEBUG_POSITIONER = false;
    public static final boolean DEBUG_COLLAPSE_ANIMATOR = false;
    public static boolean DEBUG_EXPANDED_VIEW_DRAGGING = false;


    private static final boolean FORCE_SHOW_USER_EDUCATION = false;
    private static final boolean FORCE_SHOW_USER_EDUCATION = false;
    private static final String FORCE_SHOW_USER_EDUCATION_SETTING =
    private static final String FORCE_SHOW_USER_EDUCATION_SETTING =
+12 −41
Original line number Original line Diff line number Diff line
@@ -23,10 +23,10 @@ import static android.content.Intent.FLAG_ACTIVITY_NEW_DOCUMENT;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;


import static com.android.wm.shell.bubbles.BubbleDebugConfig.DEBUG_BUBBLE_EXPANDED_VIEW;
import static com.android.wm.shell.bubbles.BubbleDebugConfig.TAG_BUBBLES;
import static com.android.wm.shell.bubbles.BubbleDebugConfig.TAG_BUBBLES;
import static com.android.wm.shell.bubbles.BubbleDebugConfig.TAG_WITH_CLASS_NAME;
import static com.android.wm.shell.bubbles.BubbleDebugConfig.TAG_WITH_CLASS_NAME;
import static com.android.wm.shell.bubbles.BubblePositioner.MAX_HEIGHT;
import static com.android.wm.shell.bubbles.BubblePositioner.MAX_HEIGHT;
import static com.android.wm.shell.protolog.ShellProtoLogGroup.WM_SHELL_BUBBLES;


import android.annotation.NonNull;
import android.annotation.NonNull;
import android.annotation.SuppressLint;
import android.annotation.SuppressLint;
@@ -67,6 +67,7 @@ import androidx.annotation.Nullable;


import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.policy.ScreenDecorationsUtils;
import com.android.internal.policy.ScreenDecorationsUtils;
import com.android.internal.protolog.common.ProtoLog;
import com.android.wm.shell.R;
import com.android.wm.shell.R;
import com.android.wm.shell.common.AlphaOptimizedButton;
import com.android.wm.shell.common.AlphaOptimizedButton;
import com.android.wm.shell.common.TriangleShape;
import com.android.wm.shell.common.TriangleShape;
@@ -199,13 +200,9 @@ public class BubbleExpandedView extends LinearLayout {


        @Override
        @Override
        public void onInitialized() {
        public void onInitialized() {
            if (DEBUG_BUBBLE_EXPANDED_VIEW) {
                Log.d(TAG, "onInitialized: destroyed=" + mDestroyed
                        + " initialized=" + mInitialized
                        + " bubble=" + getBubbleKey());
            }

            if (mDestroyed || mInitialized) {
            if (mDestroyed || mInitialized) {
                ProtoLog.d(WM_SHELL_BUBBLES, "onInitialized: destroyed=%b initialized=%b bubble=%s",
                        mDestroyed, mInitialized, getBubbleKey());
                return;
                return;
            }
            }


@@ -216,10 +213,8 @@ public class BubbleExpandedView extends LinearLayout {
            // TODO: I notice inconsistencies in lifecycle
            // TODO: I notice inconsistencies in lifecycle
            // Post to keep the lifecycle normal
            // Post to keep the lifecycle normal
            post(() -> {
            post(() -> {
                if (DEBUG_BUBBLE_EXPANDED_VIEW) {
                ProtoLog.d(WM_SHELL_BUBBLES, "onInitialized: calling startActivity, bubble=%s",
                    Log.d(TAG, "onInitialized: calling startActivity, bubble="
                        getBubbleKey());
                            + getBubbleKey());
                }
                try {
                try {
                    Rect launchBounds = new Rect();
                    Rect launchBounds = new Rect();
                    mTaskView.getBoundsOnScreen(launchBounds);
                    mTaskView.getBoundsOnScreen(launchBounds);
@@ -279,10 +274,8 @@ public class BubbleExpandedView extends LinearLayout {


        @Override
        @Override
        public void onTaskCreated(int taskId, ComponentName name) {
        public void onTaskCreated(int taskId, ComponentName name) {
            if (DEBUG_BUBBLE_EXPANDED_VIEW) {
            ProtoLog.d(WM_SHELL_BUBBLES, "onTaskCreated: taskId=%d bubble=%s",
                Log.d(TAG, "onTaskCreated: taskId=" + taskId
                    taskId, getBubbleKey());
                        + " bubble=" + getBubbleKey());
            }
            // The taskId is saved to use for removeTask, preventing appearance in recent tasks.
            // The taskId is saved to use for removeTask, preventing appearance in recent tasks.
            mTaskId = taskId;
            mTaskId = taskId;


@@ -298,15 +291,15 @@ public class BubbleExpandedView extends LinearLayout {


        @Override
        @Override
        public void onTaskVisibilityChanged(int taskId, boolean visible) {
        public void onTaskVisibilityChanged(int taskId, boolean visible) {
            ProtoLog.d(WM_SHELL_BUBBLES, "onTaskVisibilityChanged=%b bubble=%s taskId=%d",
                    visible, getBubbleKey(), taskId);
            setContentVisibility(visible);
            setContentVisibility(visible);
        }
        }


        @Override
        @Override
        public void onTaskRemovalStarted(int taskId) {
        public void onTaskRemovalStarted(int taskId) {
            if (DEBUG_BUBBLE_EXPANDED_VIEW) {
            ProtoLog.d(WM_SHELL_BUBBLES, "onTaskRemovalStarted: taskId=%d bubble=%s",
                Log.d(TAG, "onTaskRemovalStarted: taskId=" + taskId
                    taskId, getBubbleKey());
                        + " bubble=" + getBubbleKey());
            }
            if (mBubble != null) {
            if (mBubble != null) {
                mController.removeBubble(mBubble.getKey(), Bubbles.DISMISS_TASK_FINISHED);
                mController.removeBubble(mBubble.getKey(), Bubbles.DISMISS_TASK_FINISHED);
            }
            }
@@ -644,9 +637,6 @@ public class BubbleExpandedView extends LinearLayout {
        super.onDetachedFromWindow();
        super.onDetachedFromWindow();
        mImeVisible = false;
        mImeVisible = false;
        mNeedsNewHeight = false;
        mNeedsNewHeight = false;
        if (DEBUG_BUBBLE_EXPANDED_VIEW) {
            Log.d(TAG, "onDetachedFromWindow: bubble=" + getBubbleKey());
        }
    }
    }


    /**
    /**
@@ -805,10 +795,6 @@ public class BubbleExpandedView extends LinearLayout {
     * and setting {@code false} actually means rendering the contents in transparent.
     * and setting {@code false} actually means rendering the contents in transparent.
     */
     */
    public void setContentVisibility(boolean visibility) {
    public void setContentVisibility(boolean visibility) {
        if (DEBUG_BUBBLE_EXPANDED_VIEW) {
            Log.d(TAG, "setContentVisibility: visibility=" + visibility
                    + " bubble=" + getBubbleKey());
        }
        mIsContentVisible = visibility;
        mIsContentVisible = visibility;
        if (mTaskView != null && !mIsAnimating) {
        if (mTaskView != null && !mIsAnimating) {
            mTaskView.setAlpha(visibility ? 1f : 0f);
            mTaskView.setAlpha(visibility ? 1f : 0f);
@@ -867,9 +853,6 @@ public class BubbleExpandedView extends LinearLayout {
     * Sets the bubble used to populate this view.
     * Sets the bubble used to populate this view.
     */
     */
    void update(Bubble bubble) {
    void update(Bubble bubble) {
        if (DEBUG_BUBBLE_EXPANDED_VIEW) {
            Log.d(TAG, "update: bubble=" + bubble);
        }
        if (mStackView == null) {
        if (mStackView == null) {
            Log.w(TAG, "Stack is null for bubble: " + bubble);
            Log.w(TAG, "Stack is null for bubble: " + bubble);
            return;
            return;
@@ -958,11 +941,6 @@ public class BubbleExpandedView extends LinearLayout {
                }
                }
                mNeedsNewHeight = false;
                mNeedsNewHeight = false;
            }
            }
            if (DEBUG_BUBBLE_EXPANDED_VIEW) {
                Log.d(TAG, "updateHeight: bubble=" + getBubbleKey()
                        + " height=" + height
                        + " mNeedsNewHeight=" + mNeedsNewHeight);
            }
        }
        }
    }
    }


@@ -974,10 +952,6 @@ public class BubbleExpandedView extends LinearLayout {
     *                                  waiting for layout.
     *                                  waiting for layout.
     */
     */
    public void updateView(int[] containerLocationOnScreen) {
    public void updateView(int[] containerLocationOnScreen) {
        if (DEBUG_BUBBLE_EXPANDED_VIEW) {
            Log.d(TAG, "updateView: bubble="
                    + getBubbleKey());
        }
        mExpandedViewContainerLocation = containerLocationOnScreen;
        mExpandedViewContainerLocation = containerLocationOnScreen;
        updateHeight();
        updateHeight();
        if (mTaskView != null
        if (mTaskView != null
@@ -1103,9 +1077,6 @@ public class BubbleExpandedView extends LinearLayout {


    /** Hide the task view. */
    /** Hide the task view. */
    public void cleanUpExpandedState() {
    public void cleanUpExpandedState() {
        if (DEBUG_BUBBLE_EXPANDED_VIEW) {
            Log.d(TAG, "cleanUpExpandedState: bubble=" + getBubbleKey() + " task=" + mTaskId);
        }
        if (mTaskView != null) {
        if (mTaskView != null) {
            mTaskView.setVisibility(GONE);
            mTaskView.setVisibility(GONE);
        }
        }
Loading