• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 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.promoted
18 
19 import androidx.constraintlayout.widget.ConstraintSet
20 import com.android.systemui.keyguard.ui.view.layout.sections.AodPromotedNotificationSection
21 import com.android.systemui.log.LogBuffer
22 import com.android.systemui.log.core.LogLevel.ERROR
23 import com.android.systemui.log.core.LogLevel.INFO
24 import com.android.systemui.statusbar.notification.collection.NotificationEntry
25 import com.android.systemui.statusbar.notification.logKey
26 import com.android.systemui.statusbar.notification.promoted.shared.model.PromotedNotificationContentModels
27 import javax.inject.Inject
28 
29 @OptIn(ExperimentalStdlibApi::class)
30 class PromotedNotificationLogger
31 @Inject
32 constructor(@PromotedNotificationLog private val buffer: LogBuffer) {
logExtractionSkippednull33     fun logExtractionSkipped(entry: NotificationEntry, reason: String) {
34         buffer.log(
35             EXTRACTION_TAG,
36             INFO,
37             {
38                 str1 = entry.logKey
39                 str2 = reason
40             },
41             { "extraction skipped: $str2 for $str1" },
42         )
43     }
44 
logExtractionFailednull45     fun logExtractionFailed(entry: NotificationEntry, reason: String) {
46         buffer.log(
47             EXTRACTION_TAG,
48             ERROR,
49             {
50                 str1 = entry.logKey
51                 str2 = reason
52             },
53             { "extraction failed: $str2 for $str1" },
54         )
55     }
56 
logExtractionSucceedednull57     fun logExtractionSucceeded(
58         entry: NotificationEntry,
59         content: PromotedNotificationContentModels,
60     ) {
61         buffer.log(
62             EXTRACTION_TAG,
63             INFO,
64             {
65                 str1 = entry.logKey
66                 str2 = content.toRedactedString()
67             },
68             { "extraction succeeded: $str2 for $str1" },
69         )
70     }
71 
logBinderBindSkippednull72     fun logBinderBindSkipped(reason: String) {
73         buffer.log(
74             AOD_VIEW_BINDER_TAG,
75             INFO,
76             { str1 = reason },
77             { "binder skipped binding: $str1" },
78         )
79     }
80 
logBinderAttachednull81     fun logBinderAttached() {
82         buffer.log(AOD_VIEW_BINDER_TAG, INFO, "binder attached")
83     }
84 
logBinderDetachednull85     fun logBinderDetached() {
86         buffer.log(AOD_VIEW_BINDER_TAG, INFO, "binder detached")
87     }
88 
logBinderBoundNotificationnull89     fun logBinderBoundNotification() {
90         buffer.log(AOD_VIEW_BINDER_TAG, INFO, "binder bound notification")
91     }
92 
logBinderUnboundNotificationnull93     fun logBinderUnboundNotification() {
94         buffer.log(AOD_VIEW_BINDER_TAG, INFO, "binder unbound notification")
95     }
96 
logSectionCreatednull97     fun logSectionCreated(section: AodPromotedNotificationSection) {
98         buffer.log(
99             AOD_SECTION_TAG,
100             INFO,
101             "section ${System.identityHashCode(section).toHexString()} created",
102         )
103     }
104 
logSectionAddedViewsnull105     fun logSectionAddedViews(section: AodPromotedNotificationSection) {
106         buffer.log(
107             AOD_SECTION_TAG,
108             INFO,
109             "section ${System.identityHashCode(section).toHexString()} added views",
110         )
111     }
112 
logSectionBoundDatanull113     fun logSectionBoundData(section: AodPromotedNotificationSection) {
114         buffer.log(
115             AOD_SECTION_TAG,
116             INFO,
117             "section ${System.identityHashCode(section).toHexString()} bound data",
118         )
119     }
120 
logSectionAppliedConstraintsnull121     fun logSectionAppliedConstraints(section: AodPromotedNotificationSection) {
122         buffer.log(
123             AOD_SECTION_TAG,
124             INFO,
125             "section ${System.identityHashCode(section).toHexString()} applied constraints",
126         )
127     }
128 
logSectionRemovedViewsnull129     fun logSectionRemovedViews(section: AodPromotedNotificationSection) {
130         buffer.log(
131             AOD_SECTION_TAG,
132             INFO,
133             "section ${System.identityHashCode(section).toHexString()} removed views",
134         )
135     }
136 }
137 
138 private const val EXTRACTION_TAG = "PromotedNotificationContentExtractor"
139 private const val AOD_VIEW_BINDER_TAG = "AODPromotedNotificationViewBinder"
140 private const val AOD_SECTION_TAG = "AodPromotedNotificationSection"
141 
visibilityToStringnull142 private fun visibilityToString(visibility: Int): String {
143     return when (visibility) {
144         ConstraintSet.VISIBLE -> "VISIBLE"
145         ConstraintSet.INVISIBLE -> "INVISIBLE"
146         ConstraintSet.GONE -> "GONE"
147         else -> "UNKNOWN($visibility)"
148     }
149 }
150