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.phone
18 
19 import android.app.PendingIntent
20 import com.android.systemui.log.dagger.NotifInteractionLog
21 import com.android.systemui.log.LogBuffer
22 import com.android.systemui.log.core.LogLevel.DEBUG
23 import com.android.systemui.log.core.LogLevel.ERROR
24 import com.android.systemui.log.core.LogLevel.INFO
25 import com.android.systemui.log.core.LogLevel.WARNING
26 import com.android.systemui.statusbar.notification.collection.NotificationEntry
27 import com.android.systemui.statusbar.notification.logKey
28 import javax.inject.Inject
29 
30 class StatusBarNotificationActivityStarterLogger @Inject constructor(
31     @NotifInteractionLog private val buffer: LogBuffer
32 ) {
33     fun logStartingActivityFromClick(entry: NotificationEntry) {
34         buffer.log(TAG, DEBUG, {
35             str1 = entry.logKey
36         }, {
37             "(1/5) onNotificationClicked: $str1"
38         })
39     }
40 
41     fun logHandleClickAfterKeyguardDismissed(entry: NotificationEntry) {
42         buffer.log(TAG, DEBUG, {
43             str1 = entry.logKey
44         }, {
45             "(2/5) handleNotificationClickAfterKeyguardDismissed: $str1"
46         })
47     }
48 
49     fun logHandleClickAfterPanelCollapsed(entry: NotificationEntry) {
50         buffer.log(TAG, DEBUG, {
51             str1 = entry.logKey
52         }, {
53             "(3/5) handleNotificationClickAfterPanelCollapsed: $str1"
54         })
55     }
56 
57     fun logStartNotificationIntent(entry: NotificationEntry) {
58         buffer.log(TAG, INFO, {
59             str1 = entry.logKey
60         }, {
61             "(4/5) startNotificationIntent: $str1"
62         })
63     }
64 
65     fun logSendPendingIntent(entry: NotificationEntry, pendingIntent: PendingIntent, result: Int) {
66         buffer.log(TAG, INFO, {
67             str1 = entry.logKey
68             str2 = pendingIntent.intent.toString()
69             int1 = result
70         }, {
71             "(5/5) Started intent $str2 for notification $str1 with result code $int1"
72         })
73     }
74 
75     fun logExpandingBubble(entry: NotificationEntry) {
76         buffer.log(TAG, DEBUG, {
77             str1 = entry.logKey
78         }, {
79             "Expanding bubble for $str1 (rather than firing intent)"
80         })
81     }
82 
83     fun logSendingIntentFailed(e: Exception) {
84         buffer.log(TAG, WARNING, {
85             str1 = e.toString()
86         }, {
87             "Sending contentIntentFailed: $str1"
88         })
89     }
90 
91     fun logNonClickableNotification(entry: NotificationEntry) {
92         buffer.log(TAG, ERROR, {
93             str1 = entry.logKey
94         }, {
95             "onNotificationClicked called for non-clickable notification! $str1"
96         })
97     }
98 
99     fun logFullScreenIntentSuppressedByVR(entry: NotificationEntry) {
100         buffer.log(TAG, DEBUG, {
101             str1 = entry.logKey
102         }, {
103             "No Fullscreen intent: suppressed by VR mode: $str1"
104         })
105     }
106 
107     fun logSendingFullScreenIntent(entry: NotificationEntry, pendingIntent: PendingIntent) {
108         buffer.log(TAG, INFO, {
109             str1 = entry.logKey
110             str2 = pendingIntent.intent.toString()
111         }, {
112             "Notification $str1 has fullScreenIntent; sending fullScreenIntent $str2"
113         })
114     }
115 }
116 
117 private const val TAG = "NotifActivityStarter"
118