1 /* 2 * Copyright (C) 2023 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.row 18 19 import com.android.systemui.log.LogBuffer 20 import com.android.systemui.log.core.LogLevel 21 import com.android.systemui.log.dagger.NotifInflationLog 22 import com.android.systemui.statusbar.notification.collection.NotificationEntry 23 import com.android.systemui.statusbar.notification.logKey 24 import com.android.systemui.statusbar.notification.row.NotificationRowContentBinder.FLAG_CONTENT_VIEW_ALL 25 import com.android.systemui.statusbar.notification.row.NotificationRowContentBinder.FLAG_CONTENT_VIEW_CONTRACTED 26 import com.android.systemui.statusbar.notification.row.NotificationRowContentBinder.FLAG_CONTENT_VIEW_EXPANDED 27 import com.android.systemui.statusbar.notification.row.NotificationRowContentBinder.FLAG_CONTENT_VIEW_HEADS_UP 28 import com.android.systemui.statusbar.notification.row.NotificationRowContentBinder.FLAG_CONTENT_VIEW_PUBLIC 29 import com.android.systemui.statusbar.notification.row.NotificationRowContentBinder.FLAG_CONTENT_VIEW_SINGLE_LINE 30 import com.android.systemui.statusbar.notification.row.NotificationRowContentBinder.FLAG_GROUP_SUMMARY_HEADER 31 import com.android.systemui.statusbar.notification.row.NotificationRowContentBinder.FLAG_LOW_PRIORITY_GROUP_SUMMARY_HEADER 32 import com.android.systemui.statusbar.notification.row.NotificationRowContentBinder.InflationFlag 33 import javax.inject.Inject 34 35 class NotificationRowContentBinderLogger 36 @Inject 37 constructor(@NotifInflationLog private val buffer: LogBuffer) { logNotBindingRowWasRemovednull38 fun logNotBindingRowWasRemoved(entry: NotificationEntry) { 39 buffer.log( 40 TAG, 41 LogLevel.INFO, 42 { str1 = entry.logKey }, 43 { "not inflating $str1: row was removed" } 44 ) 45 } 46 logBindingnull47 fun logBinding(entry: NotificationEntry, @InflationFlag flag: Int) { 48 buffer.log( 49 TAG, 50 LogLevel.DEBUG, 51 { 52 str1 = entry.logKey 53 int1 = flag 54 }, 55 { "binding views ${flagToString(int1)} for $str1" } 56 ) 57 } 58 logCancelBindAbortedTasknull59 fun logCancelBindAbortedTask(entry: NotificationEntry) { 60 buffer.log( 61 TAG, 62 LogLevel.INFO, 63 { str1 = entry.logKey }, 64 { "aborted task to cancel binding $str1" } 65 ) 66 } 67 logUnbindingnull68 fun logUnbinding(entry: NotificationEntry, @InflationFlag flag: Int) { 69 buffer.log( 70 TAG, 71 LogLevel.DEBUG, 72 { 73 str1 = entry.logKey 74 int1 = flag 75 }, 76 { "unbinding views ${flagToString(int1)} for $str1" } 77 ) 78 } 79 logAsyncTaskProgressnull80 fun logAsyncTaskProgress(entry: NotificationEntry, progress: String) { 81 buffer.log( 82 TAG, 83 LogLevel.DEBUG, 84 { 85 str1 = entry.logKey 86 str2 = progress 87 }, 88 { "async task for $str1: $str2" } 89 ) 90 } 91 logAsyncTaskExceptionnull92 fun logAsyncTaskException(entry: NotificationEntry, logContext: String, exception: Throwable) { 93 buffer.log( 94 TAG, 95 LogLevel.DEBUG, 96 { 97 str1 = entry.logKey 98 str2 = logContext 99 str3 = exception.stackTraceToString() 100 }, 101 { "async task for $str1 got exception $str2: $str3" } 102 ) 103 } 104 logInflateSingleLinenull105 fun logInflateSingleLine( 106 entry: NotificationEntry, 107 @InflationFlag inflationFlags: Int, 108 isConversation: Boolean 109 ) { 110 buffer.log( 111 TAG, 112 LogLevel.DEBUG, 113 { 114 str1 = entry.logKey 115 int1 = inflationFlags 116 bool1 = isConversation 117 }, 118 { 119 "inflateSingleLineView, inflationFlags: ${flagToString(int1)} for $str1, " + 120 "isConversation: $bool1" 121 } 122 ) 123 } 124 125 companion object { flagToStringnull126 fun flagToString(@InflationFlag flag: Int): String { 127 if (flag == 0) { 128 return "NONE" 129 } 130 if (flag == FLAG_CONTENT_VIEW_ALL) { 131 return "ALL" 132 } 133 134 var l = mutableListOf<String>() 135 if (flag and FLAG_CONTENT_VIEW_CONTRACTED != 0) { 136 l.add("CONTRACTED") 137 } 138 if (flag and FLAG_CONTENT_VIEW_EXPANDED != 0) { 139 l.add("EXPANDED") 140 } 141 if (flag and FLAG_CONTENT_VIEW_HEADS_UP != 0) { 142 l.add("HEADS_UP") 143 } 144 if (flag and FLAG_CONTENT_VIEW_PUBLIC != 0) { 145 l.add("PUBLIC") 146 } 147 if (flag and FLAG_CONTENT_VIEW_SINGLE_LINE != 0) { 148 l.add("SINGLE_LINE") 149 } 150 if (flag and FLAG_GROUP_SUMMARY_HEADER != 0) { 151 l.add("GROUP_SUMMARY_HEADER") 152 } 153 if (flag and FLAG_LOW_PRIORITY_GROUP_SUMMARY_HEADER != 0) { 154 l.add("LOW_PRIORITY_GROUP_SUMMARY_HEADER") 155 } 156 return l.joinToString("|") 157 } 158 } 159 } 160 161 private const val TAG = "NotificationRowContentBinder" 162