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 import com.android.systemui.statusbar.notification.shared.NotificationsLiveDataStoreRefactor;
25 
26 import com.google.protobuf.nano.MessageNano;
27 
28 import java.util.Collections;
29 import java.util.List;
30 
31 /**
32  * Normal implementation of NotificationPanelLogger.
33  */
34 public class NotificationPanelLoggerImpl implements NotificationPanelLogger {
35 
36     @Override
logPanelShown(boolean isLockscreen, Notifications.NotificationList proto)37     public void logPanelShown(boolean isLockscreen, Notifications.NotificationList proto) {
38         SysUiStatsLog.write(SysUiStatsLog.NOTIFICATION_PANEL_REPORTED,
39                 /* event_id = */ NotificationPanelEvent.fromLockscreen(isLockscreen).getId(),
40                 /* num_notifications = */ proto.notifications.length,
41                 /* notifications = */ MessageNano.toByteArray(proto));
42     }
43 
44     @Override
logPanelShown(boolean isLockscreen, List<NotificationEntry> visibleNotifications)45     public void logPanelShown(boolean isLockscreen,
46             List<NotificationEntry> visibleNotifications) {
47         NotificationsLiveDataStoreRefactor.assertInLegacyMode();
48         final Notifications.NotificationList proto = NotificationPanelLogger.toNotificationProto(
49                 visibleNotifications);
50         SysUiStatsLog.write(SysUiStatsLog.NOTIFICATION_PANEL_REPORTED,
51                 /* event_id = */ NotificationPanelEvent.fromLockscreen(isLockscreen).getId(),
52                 /* num_notifications = */ proto.notifications.length,
53                 /* notifications = */ MessageNano.toByteArray(proto));
54     }
55 
56     @Override
logNotificationDrag(NotificationEntry draggedNotification)57     public void logNotificationDrag(NotificationEntry draggedNotification) {
58         final Notifications.NotificationList proto = NotificationPanelLogger.toNotificationProto(
59                 Collections.singletonList(draggedNotification));
60         SysUiStatsLog.write(SysUiStatsLog.NOTIFICATION_PANEL_REPORTED,
61                 /* event_id = */ NOTIFICATION_DRAG.getId(),
62                 /* num_notifications = */ proto.notifications.length,
63                 /* notifications = */ MessageNano.toByteArray(proto));
64     }
65 }
66