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

Commit 45ca655e authored by Lyn Han's avatar Lyn Han Committed by Automerger Merge Worker
Browse files

Merge "Log overflow events" into rvc-dev am: d96d5625

Change-Id: I76d31c19186de259c7b4a56d9341827226d67b04
parents 23811891 d96d5625
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -54,6 +54,8 @@ import javax.inject.Singleton;
@Singleton
public class BubbleData {

    BubbleLogger mLogger = new BubbleLoggerImpl();

    private static final String TAG = TAG_WITH_CLASS_NAME ? "BubbleData" : TAG_BUBBLES;

    private static final Comparator<Bubble> BUBBLES_BY_SORT_KEY_DESCENDING =
@@ -206,6 +208,7 @@ public class BubbleData {
        if (DEBUG_BUBBLE_DATA) {
            Log.d(TAG, "promoteBubbleFromOverflow: " + bubble);
        }
        mLogger.log(bubble, BubbleLogger.Event.BUBBLE_OVERFLOW_REMOVE_BACK_TO_STACK);
        moveOverflowBubbleToPending(bubble);
        // Preserve new order for next repack, which sorts by last updated time.
        bubble.inflate(
@@ -422,6 +425,7 @@ public class BubbleData {
                if (DEBUG_BUBBLE_DATA) {
                    Log.d(TAG, "Cancel overflow bubble: " + b);
                }
                mLogger.logOverflowRemove(b, reason);
                mStateChange.bubbleRemoved(b, reason);
                mOverflowBubbles.remove(b);
            }
@@ -466,6 +470,7 @@ public class BubbleData {
        if (DEBUG_BUBBLE_DATA) {
            Log.d(TAG, "Overflowing: " + bubble);
        }
        mLogger.logOverflowAdd(bubble, reason);
        mOverflowBubbles.add(0, bubble);
        bubble.stopInflation();
        if (mOverflowBubbles.size() == mMaxOverflowBubbles + 1) {
@@ -475,6 +480,7 @@ public class BubbleData {
                Log.d(TAG, "Overflow full. Remove: " + oldest);
            }
            mStateChange.bubbleRemoved(oldest, BubbleController.DISMISS_OVERFLOW_MAX_REACHED);
            mLogger.log(bubble, BubbleLogger.Event.BUBBLE_OVERFLOW_REMOVE_MAX_REACHED);
            mOverflowBubbles.remove(oldest);
        }
    }
+89 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2020 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.bubbles;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.logging.UiEvent;
import com.android.internal.logging.UiEventLogger;

/**
 * Interface for handling bubble-specific logging.
 */
public interface BubbleLogger extends UiEventLogger {

    /**
     * Bubble UI event.
     */
    @VisibleForTesting
    enum Event implements UiEventLogger.UiEventEnum {

        @UiEvent(doc = "User dismissed the bubble via gesture, add bubble to overflow.")
        BUBBLE_OVERFLOW_ADD_USER_GESTURE(483),

        @UiEvent(doc = "No more space in top row, add bubble to overflow.")
        BUBBLE_OVERFLOW_ADD_AGED(484),

        @UiEvent(doc = "No more space in overflow, remove bubble from overflow")
        BUBBLE_OVERFLOW_REMOVE_MAX_REACHED(485),

        @UiEvent(doc = "Notification canceled, remove bubble from overflow.")
        BUBBLE_OVERFLOW_REMOVE_CANCEL(486),

        @UiEvent(doc = "Notification group canceled, remove bubble for child notif from overflow.")
        BUBBLE_OVERFLOW_REMOVE_GROUP_CANCEL(487),

        @UiEvent(doc = "Notification no longer bubble, remove bubble from overflow.")
        BUBBLE_OVERFLOW_REMOVE_NO_LONGER_BUBBLE(488),

        @UiEvent(doc = "User tapped overflow bubble. Promote bubble back to top row.")
        BUBBLE_OVERFLOW_REMOVE_BACK_TO_STACK(489),

        @UiEvent(doc = "User blocked notification from bubbling, remove bubble from overflow.")
        BUBBLE_OVERFLOW_REMOVE_BLOCKED(490);

        private final int mId;

        Event(int id) {
            mId = id;
        }

        @Override
        public int getId() {
            return mId;
        }
    }

    /**
     * @param b Bubble involved in this UI event
     * @param e UI event
     */
    void log(Bubble b, UiEventEnum e);

    /**
     *
     * @param b Bubble removed from overflow
     * @param r Reason that bubble was removed from overflow
     */
    void logOverflowRemove(Bubble b, @BubbleController.DismissReason int r);

    /**
     *
     * @param b Bubble added to overflow
     * @param r Reason that bubble was added to overflow
     */
    void logOverflowAdd(Bubble b, @BubbleController.DismissReason int r);
}
+65 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2020 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.bubbles;

import android.service.notification.StatusBarNotification;
import com.android.internal.logging.UiEventLoggerImpl;

/**
 * Implementation of UiEventLogger for logging bubble UI events.
 *
 * See UiEventReported atom in atoms.proto for more context.
 */
public class BubbleLoggerImpl extends UiEventLoggerImpl implements BubbleLogger {

    /**
     * @param b Bubble involved in this UI event
     * @param e UI event
     */
    public void log(Bubble b, UiEventEnum e) {
        StatusBarNotification sbn = b.getEntry().getSbn();
        logWithInstanceId(e, sbn.getUid(), sbn.getPackageName(), sbn.getInstanceId());
    }

    /**
     * @param b Bubble removed from overflow
     * @param r Reason that bubble was removed
     */
    public void logOverflowRemove(Bubble b, @BubbleController.DismissReason int r) {
        if (r == BubbleController.DISMISS_NOTIF_CANCEL) {
            log(b, BubbleLogger.Event.BUBBLE_OVERFLOW_REMOVE_CANCEL);
        } else if (r == BubbleController.DISMISS_GROUP_CANCELLED) {
            log(b, BubbleLogger.Event.BUBBLE_OVERFLOW_REMOVE_GROUP_CANCEL);
        } else if (r == BubbleController.DISMISS_NO_LONGER_BUBBLE) {
            log(b, BubbleLogger.Event.BUBBLE_OVERFLOW_REMOVE_NO_LONGER_BUBBLE);
        } else if (r == BubbleController.DISMISS_BLOCKED) {
            log(b, BubbleLogger.Event.BUBBLE_OVERFLOW_REMOVE_BLOCKED);
        }
    }

    /**
     * @param b Bubble added to overflow
     * @param r Reason that bubble was added to overflow
     */
    public void logOverflowAdd(Bubble b, @BubbleController.DismissReason int r) {
        if (r == BubbleController.DISMISS_AGED) {
            log(b, Event.BUBBLE_OVERFLOW_ADD_AGED);
        } else if (r == BubbleController.DISMISS_USER_GESTURE) {
            log(b, Event.BUBBLE_OVERFLOW_ADD_USER_GESTURE);
        }
    }
}
 No newline at end of file