• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.app.NotificationChannel;
20 import android.app.NotificationChannelGroup;
21 
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 NotificationChannelLogger, which passes data through to StatsLog.
28  * This layer is as skinny as possible, to maximize code coverage of unit tests.  Nontrivial code
29  * should live in the interface so it can be tested.
30  */
31 public class NotificationChannelLoggerImpl implements NotificationChannelLogger {
32     UiEventLogger mUiEventLogger = new UiEventLoggerImpl();
33 
34     @Override
logNotificationChannel(NotificationChannelEvent event, NotificationChannel channel, int uid, String pkg, int oldImportance, int newImportance)35     public void logNotificationChannel(NotificationChannelEvent event,
36             NotificationChannel channel, int uid, String pkg,
37             int oldImportance, int newImportance) {
38         FrameworkStatsLog.write(FrameworkStatsLog.NOTIFICATION_CHANNEL_MODIFIED,
39                 /* int event_id*/ event.getId(),
40                 /* int uid*/ uid,
41                 /* String package_name */ pkg,
42                 /* int32 channel_id_hash */ NotificationChannelLogger.getIdHash(channel),
43                 /* int old_importance*/ oldImportance,
44                 /* int importance*/ newImportance);
45     }
46 
47     @Override
logNotificationChannelGroup(NotificationChannelEvent event, NotificationChannelGroup channelGroup, int uid, String pkg, boolean wasBlocked)48     public void logNotificationChannelGroup(NotificationChannelEvent event,
49             NotificationChannelGroup channelGroup, int uid, String pkg, boolean wasBlocked) {
50         FrameworkStatsLog.write(FrameworkStatsLog.NOTIFICATION_CHANNEL_MODIFIED,
51                 /* int event_id*/ event.getId(),
52                 /* int uid*/ uid,
53                 /* String package_name */ pkg,
54                 /* int32 channel_id_hash */ NotificationChannelLogger.getIdHash(channelGroup),
55                 /* int old_importance*/ NotificationChannelLogger.getImportance(wasBlocked),
56                 /* int importance*/ NotificationChannelLogger.getImportance(channelGroup));
57     }
58 
59     @Override
logAppEvent(NotificationChannelEvent event, int uid, String pkg)60     public void logAppEvent(NotificationChannelEvent event, int uid, String pkg) {
61         mUiEventLogger.log(event, uid, pkg);
62     }
63 }
64