1 /* 2 * Copyright (C) 2020 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.systemui.bubbles; 18 19 import com.android.internal.logging.UiEventLoggerImpl; 20 21 /** 22 * Implementation of UiEventLogger for logging bubble UI events. 23 * 24 * See UiEventReported atom in atoms.proto for more context. 25 */ 26 public class BubbleLoggerImpl extends UiEventLoggerImpl implements BubbleLogger { 27 28 /** 29 * @param b Bubble involved in this UI event 30 * @param e UI event 31 */ log(Bubble b, UiEventEnum e)32 public void log(Bubble b, UiEventEnum e) { 33 if (b.getInstanceId() == null) { 34 // Added from persistence -- TODO log this with specific event? 35 return; 36 } 37 logWithInstanceId(e, b.getAppUid(), b.getPackageName(), b.getInstanceId()); 38 } 39 40 /** 41 * @param b Bubble removed from overflow 42 * @param r Reason that bubble was removed 43 */ logOverflowRemove(Bubble b, @BubbleController.DismissReason int r)44 public void logOverflowRemove(Bubble b, @BubbleController.DismissReason int r) { 45 if (r == BubbleController.DISMISS_NOTIF_CANCEL) { 46 log(b, BubbleLogger.Event.BUBBLE_OVERFLOW_REMOVE_CANCEL); 47 } else if (r == BubbleController.DISMISS_GROUP_CANCELLED) { 48 log(b, BubbleLogger.Event.BUBBLE_OVERFLOW_REMOVE_GROUP_CANCEL); 49 } else if (r == BubbleController.DISMISS_NO_LONGER_BUBBLE) { 50 log(b, BubbleLogger.Event.BUBBLE_OVERFLOW_REMOVE_NO_LONGER_BUBBLE); 51 } else if (r == BubbleController.DISMISS_BLOCKED) { 52 log(b, BubbleLogger.Event.BUBBLE_OVERFLOW_REMOVE_BLOCKED); 53 } 54 } 55 56 /** 57 * @param b Bubble added to overflow 58 * @param r Reason that bubble was added to overflow 59 */ logOverflowAdd(Bubble b, @BubbleController.DismissReason int r)60 public void logOverflowAdd(Bubble b, @BubbleController.DismissReason int r) { 61 if (r == BubbleController.DISMISS_AGED) { 62 log(b, Event.BUBBLE_OVERFLOW_ADD_AGED); 63 } else if (r == BubbleController.DISMISS_USER_GESTURE) { 64 log(b, Event.BUBBLE_OVERFLOW_ADD_USER_GESTURE); 65 } 66 } 67 }