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.statusbar.notification.logging;
18 
19 import static com.android.systemui.statusbar.notification.logging.NotificationPanelLogger.NotificationPanelEvent.NOTIFICATION_DRAG;
20 
21 import com.android.systemui.shared.system.SysUiStatsLog;
22 import com.android.systemui.statusbar.notification.collection.NotificationEntry;
23 import com.android.systemui.statusbar.notification.logging.nano.Notifications;
24 
25 import com.google.protobuf.nano.MessageNano;
26 
27 import java.util.Collections;
28 import java.util.List;
29 
30 /**
31  * Normal implementation of NotificationPanelLogger.
32  */
33 public class NotificationPanelLoggerImpl implements NotificationPanelLogger {
34     @Override
logPanelShown(boolean isLockscreen, List<NotificationEntry> visibleNotifications)35     public void logPanelShown(boolean isLockscreen,
36             List<NotificationEntry> visibleNotifications) {
37         final Notifications.NotificationList proto = NotificationPanelLogger.toNotificationProto(
38                 visibleNotifications);
39         SysUiStatsLog.write(SysUiStatsLog.NOTIFICATION_PANEL_REPORTED,
40                 /* int event_id */ NotificationPanelEvent.fromLockscreen(isLockscreen).getId(),
41                 /* int num_notifications*/ proto.notifications.length,
42                 /* byte[] notifications*/ MessageNano.toByteArray(proto));
43     }
44 
45     @Override
logNotificationDrag(NotificationEntry draggedNotification)46     public void logNotificationDrag(NotificationEntry draggedNotification) {
47         final Notifications.NotificationList proto = NotificationPanelLogger.toNotificationProto(
48                 Collections.singletonList(draggedNotification));
49         SysUiStatsLog.write(SysUiStatsLog.NOTIFICATION_PANEL_REPORTED,
50                 /* int event_id */ NOTIFICATION_DRAG.getId(),
51                 /* int num_notifications*/ proto.notifications.length,
52                 /* byte[] notifications*/ MessageNano.toByteArray(proto));
53     }
54 }
55