1 /*
2  * Copyright (C) 2023 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5  * except in compliance with the License. You may obtain a copy of the License at
6  *
7  *      http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software distributed under the
10  * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
11  * KIND, either express or implied. See the License for the specific language governing
12  * permissions and limitations under the License.
13  *
14  */
15 
16 package com.android.systemui.statusbar.notification.icon.ui.viewbinder
17 
18 import com.android.systemui.CoreStartable
19 import com.android.systemui.dagger.SysUISingleton
20 import com.android.systemui.statusbar.notification.shared.NotificationIconContainerRefactor
21 import com.android.systemui.util.asIndenting
22 import com.android.systemui.util.printCollection
23 import dagger.Binds
24 import dagger.multibindings.ClassKey
25 import dagger.multibindings.IntoMap
26 import java.io.PrintWriter
27 import javax.inject.Inject
28 
29 @SysUISingleton
30 class StatusBarIconViewBindingFailureTracker @Inject constructor() : CoreStartable {
31 
32     var aodFailures: Collection<String> = emptyList()
33     var statusBarFailures: Collection<String> = emptyList()
34     var shelfFailures: Collection<String> = emptyList()
35 
36     // TODO(b/310681665): Ideally we wouldn't need to implement CoreStartable at all, and could just
37     //  @Binds @IntoSet the Dumpable.
startnull38     override fun start() {
39         // no-op, we're just using this as a dumpable
40     }
41 
dumpnull42     override fun dump(pw: PrintWriter, args: Array<out String>) {
43         if (!NotificationIconContainerRefactor.isEnabled) return
44         pw.asIndenting().run {
45             printCollection("AOD Icon binding failures:", aodFailures)
46             printCollection("Status Bar Icon binding failures:", statusBarFailures)
47             printCollection("Shelf Icon binding failures:", shelfFailures)
48         }
49     }
50 
51     @dagger.Module
52     interface Module {
53         @Binds
54         @IntoMap
55         @ClassKey(StatusBarIconViewBindingFailureTracker::class)
bindStartablenull56         fun bindStartable(impl: StatusBarIconViewBindingFailureTracker): CoreStartable
57     }
58 }
59