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.server.notification; 18 19 import android.annotation.Nullable; 20 21 import com.android.internal.logging.InstanceId; 22 import com.android.internal.logging.UiEventLogger; 23 import com.android.internal.logging.UiEventLoggerImpl; 24 import com.android.internal.util.FrameworkStatsLog; 25 26 /** 27 * Standard implementation of NotificationRecordLogger interface. 28 * @hide 29 */ 30 class NotificationRecordLoggerImpl implements NotificationRecordLogger { 31 32 private UiEventLogger mUiEventLogger = new UiEventLoggerImpl(); 33 34 @Override logNotificationPosted(NotificationReported nr)35 public void logNotificationPosted(NotificationReported nr) { 36 writeNotificationReportedAtom(nr); 37 } 38 39 @Override logNotificationAdjusted(@ullable NotificationRecord r, int position, int buzzBeepBlink, InstanceId groupId)40 public void logNotificationAdjusted(@Nullable NotificationRecord r, 41 int position, int buzzBeepBlink, 42 InstanceId groupId) { 43 NotificationRecordPair p = new NotificationRecordPair(r, null); 44 writeNotificationReportedAtom( 45 new NotificationReported(p, NotificationReportedEvent.NOTIFICATION_ADJUSTED, 46 position, buzzBeepBlink, groupId)); 47 } 48 writeNotificationReportedAtom( NotificationReported notificationReported)49 private void writeNotificationReportedAtom( 50 NotificationReported notificationReported) { 51 FrameworkStatsLog.write( 52 FrameworkStatsLog.NOTIFICATION_REPORTED, 53 notificationReported.event_id, 54 notificationReported.uid, 55 notificationReported.package_name, 56 notificationReported.instance_id, 57 notificationReported.notification_id_hash, 58 notificationReported.channel_id_hash, 59 notificationReported.group_id_hash, 60 notificationReported.group_instance_id, 61 notificationReported.is_group_summary, 62 notificationReported.category, 63 notificationReported.style, 64 notificationReported.num_people, 65 notificationReported.position, 66 notificationReported.importance, 67 notificationReported.alerting, 68 notificationReported.importance_source, 69 notificationReported.importance_initial, 70 notificationReported.importance_initial_source, 71 notificationReported.importance_asst, 72 notificationReported.assistant_hash, 73 notificationReported.assistant_ranking_score, 74 notificationReported.is_ongoing, 75 notificationReported.is_foreground_service, 76 notificationReported.timeout_millis, 77 notificationReported.is_non_dismissible, 78 notificationReported.post_duration_millis, 79 notificationReported.fsi_state, 80 notificationReported.is_locked, 81 notificationReported.age_in_minutes); 82 } 83 84 @Override log(UiEventLogger.UiEventEnum event, NotificationRecord r)85 public void log(UiEventLogger.UiEventEnum event, NotificationRecord r) { 86 if (r == null) { 87 return; 88 } 89 mUiEventLogger.logWithInstanceId(event, r.getUid(), r.getSbn().getPackageName(), 90 r.getSbn().getInstanceId()); 91 } 92 93 @Override log(UiEventLogger.UiEventEnum event)94 public void log(UiEventLogger.UiEventEnum event) { 95 mUiEventLogger.log(event); 96 } 97 } 98