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