| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package com.android.wm.shell.bubbles; |
| 18 |
|
| 19 |
import com.android.internal.annotations.VisibleForTesting; |
| 20 |
import com.android.internal.logging.UiEvent; |
| 21 |
import com.android.internal.logging.UiEventLogger; |
| 22 |
import com.android.internal.util.FrameworkStatsLog; |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
public class BubbleLogger { |
| 30 |
|
| 31 |
private final UiEventLogger mUiEventLogger; |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
@VisibleForTesting |
| 37 |
public enum Event implements UiEventLogger.UiEventEnum { |
| 38 |
|
| 39 |
@UiEvent(doc = "User dismissed the bubble via gesture, add bubble to overflow.") |
| 40 |
BUBBLE_OVERFLOW_ADD_USER_GESTURE(483), |
| 41 |
|
| 42 |
@UiEvent(doc = "No more space in top row, add bubble to overflow.") |
| 43 |
BUBBLE_OVERFLOW_ADD_AGED(484), |
| 44 |
|
| 45 |
@UiEvent(doc = "No more space in overflow, remove bubble from overflow") |
| 46 |
BUBBLE_OVERFLOW_REMOVE_MAX_REACHED(485), |
| 47 |
|
| 48 |
@UiEvent(doc = "Notification canceled, remove bubble from overflow.") |
| 49 |
BUBBLE_OVERFLOW_REMOVE_CANCEL(486), |
| 50 |
|
| 51 |
@UiEvent(doc = "Notification group canceled, remove bubble for child notif from overflow.") |
| 52 |
BUBBLE_OVERFLOW_REMOVE_GROUP_CANCEL(487), |
| 53 |
|
| 54 |
@UiEvent(doc = "Notification no longer bubble, remove bubble from overflow.") |
| 55 |
BUBBLE_OVERFLOW_REMOVE_NO_LONGER_BUBBLE(488), |
| 56 |
|
| 57 |
@UiEvent(doc = "User tapped overflow bubble. Promote bubble back to top row.") |
| 58 |
BUBBLE_OVERFLOW_REMOVE_BACK_TO_STACK(489), |
| 59 |
|
| 60 |
@UiEvent(doc = "User blocked notification from bubbling, remove bubble from overflow.") |
| 61 |
BUBBLE_OVERFLOW_REMOVE_BLOCKED(490), |
| 62 |
|
| 63 |
@UiEvent(doc = "User selected the overflow.") |
| 64 |
BUBBLE_OVERFLOW_SELECTED(600), |
| 65 |
|
| 66 |
@UiEvent(doc = "Restore bubble to overflow after phone reboot.") |
| 67 |
BUBBLE_OVERFLOW_RECOVER(691); |
| 68 |
|
| 69 |
private final int mId; |
| 70 |
|
| 71 |
Event(int id) { |
| 72 |
mId = id; |
| 73 |
} |
| 74 |
|
| 75 |
@Override |
| 76 |
public int getId() { |
| 77 |
return mId; |
| 78 |
} |
| 79 |
} |
| 80 |
|
| 81 |
public BubbleLogger(UiEventLogger uiEventLogger) { |
| 82 |
mUiEventLogger = uiEventLogger; |
| 83 |
} |
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
public void log(Bubble b, UiEventLogger.UiEventEnum e) { |
| 90 |
mUiEventLogger.logWithInstanceId(e, b.getAppUid(), b.getPackageName(), b.getInstanceId()); |
| 91 |
} |
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
public void logOverflowRemove(Bubble b, @Bubbles.DismissReason int r) { |
| 98 |
if (r == Bubbles.DISMISS_NOTIF_CANCEL) { |
| 99 |
log(b, BubbleLogger.Event.BUBBLE_OVERFLOW_REMOVE_CANCEL); |
| 100 |
} else if (r == Bubbles.DISMISS_GROUP_CANCELLED) { |
| 101 |
log(b, BubbleLogger.Event.BUBBLE_OVERFLOW_REMOVE_GROUP_CANCEL); |
| 102 |
} else if (r == Bubbles.DISMISS_NO_LONGER_BUBBLE) { |
| 103 |
log(b, BubbleLogger.Event.BUBBLE_OVERFLOW_REMOVE_NO_LONGER_BUBBLE); |
| 104 |
} else if (r == Bubbles.DISMISS_BLOCKED) { |
| 105 |
log(b, BubbleLogger.Event.BUBBLE_OVERFLOW_REMOVE_BLOCKED); |
| 106 |
} |
| 107 |
} |
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
public void logOverflowAdd(Bubble b, @Bubbles.DismissReason int r) { |
| 114 |
if (r == Bubbles.DISMISS_AGED) { |
| 115 |
log(b, Event.BUBBLE_OVERFLOW_ADD_AGED); |
| 116 |
} else if (r == Bubbles.DISMISS_USER_GESTURE) { |
| 117 |
log(b, Event.BUBBLE_OVERFLOW_ADD_USER_GESTURE); |
| 118 |
} else if (r == Bubbles.DISMISS_RELOAD_FROM_DISK) { |
| 119 |
log(b, Event.BUBBLE_OVERFLOW_RECOVER); |
| 120 |
} |
| 121 |
} |
| 122 |
|
| 123 |
void logStackUiChanged(String packageName, int action, int bubbleCount, float normalX, |
| 124 |
float normalY) { |
| 125 |
FrameworkStatsLog.write(FrameworkStatsLog.BUBBLE_UI_CHANGED, |
| 126 |
packageName, |
| 127 |
null , |
| 128 |
0 , |
| 129 |
0 , |
| 130 |
bubbleCount, |
| 131 |
action, |
| 132 |
normalX, |
| 133 |
normalY, |
| 134 |
false , |
| 135 |
false , |
| 136 |
false ); |
| 137 |
} |
| 138 |
|
| 139 |
void logShowOverflow(String packageName, int currentUserId) { |
| 140 |
mUiEventLogger.log(BubbleLogger.Event.BUBBLE_OVERFLOW_SELECTED, currentUserId, |
| 141 |
packageName); |
| 142 |
} |
| 143 |
|
| 144 |
void logBubbleUiChanged(Bubble bubble, String packageName, int action, int bubbleCount, |
| 145 |
float normalX, float normalY, int index) { |
| 146 |
FrameworkStatsLog.write(FrameworkStatsLog.BUBBLE_UI_CHANGED, |
| 147 |
packageName, |
| 148 |
bubble.getChannelId() , |
| 149 |
bubble.getNotificationId() , |
| 150 |
index, |
| 151 |
bubbleCount, |
| 152 |
action, |
| 153 |
normalX, |
| 154 |
normalY, |
| 155 |
bubble.showInShade() , |
| 156 |
false , |
| 157 |
false ); |
| 158 |
} |
| 159 |
} |