diff options
| author | 2020-05-26 12:11:06 -0700 | |
|---|---|---|
| committer | 2020-05-27 17:28:13 -0700 | |
| commit | 9aee783ddee7c1b11938f67c25d69e328a8c05ea (patch) | |
| tree | 0b78986f1fa1340167d542f0339bef780bbdb1ce | |
| parent | 28c3a34faa0dc80f824d07f154b6fe122f38f291 (diff) | |
Log overflow events
Bug: 149133814
Test: adb shell cmd stats print-logs
Change-Id: Ife2aac90ae9ad0f8eb5ed7de5169a7bfb0818c33
3 files changed, 160 insertions, 0 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java index 65d5bebc625d..91f6fad749be 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java @@ -57,6 +57,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 = @@ -214,6 +216,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.markUpdatedAt(mTimeSource.currentTimeMillis()); @@ -440,6 +443,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); } @@ -482,6 +486,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) { @@ -491,6 +496,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); } } diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleLogger.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleLogger.java new file mode 100644 index 000000000000..1e6eb8c5c89b --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleLogger.java @@ -0,0 +1,89 @@ +/* + * 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); +} diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleLoggerImpl.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleLoggerImpl.java new file mode 100644 index 000000000000..0327cb4b2919 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleLoggerImpl.java @@ -0,0 +1,65 @@ +/* + * 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 |