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.events
18 
19 import com.android.systemui.dagger.SysUISingleton
20 import com.android.systemui.dagger.qualifiers.Application
21 import com.android.systemui.dagger.qualifiers.Main
22 import com.android.systemui.dump.DumpManager
23 import com.android.systemui.flags.FeatureFlags
24 import com.android.systemui.flags.Flags
25 import com.android.systemui.log.LogBuffer
26 import com.android.systemui.log.LogBufferFactory
27 import com.android.systemui.statusbar.window.StatusBarWindowController
28 import com.android.systemui.util.concurrency.DelayableExecutor
29 import com.android.systemui.util.time.SystemClock
30 import dagger.Module
31 import dagger.Provides
32 import kotlinx.coroutines.CoroutineScope
33 
34 @Module
35 interface StatusBarEventsModule {
36 
37     companion object {
38 
39         @Provides
40         @SysUISingleton
41         @SystemStatusAnimationSchedulerLog
42         fun provideSystemStatusAnimationSchedulerLogBuffer(factory: LogBufferFactory): LogBuffer {
43             return factory.create("SystemStatusAnimationSchedulerLog", 60)
44         }
45 
46         @Provides
47         @SysUISingleton
48         fun provideSystemStatusAnimationScheduler(
49                 featureFlags: FeatureFlags,
50                 coordinator: SystemEventCoordinator,
51                 chipAnimationController: SystemEventChipAnimationController,
52                 statusBarWindowController: StatusBarWindowController,
53                 dumpManager: DumpManager,
54                 systemClock: SystemClock,
55                 @Application coroutineScope: CoroutineScope,
56                 @Main executor: DelayableExecutor,
57                 logger: SystemStatusAnimationSchedulerLogger
58         ): SystemStatusAnimationScheduler {
59             return if (featureFlags.isEnabled(Flags.PLUG_IN_STATUS_BAR_CHIP)) {
60                 SystemStatusAnimationSchedulerImpl(
61                         coordinator,
62                         chipAnimationController,
63                         statusBarWindowController,
64                         dumpManager,
65                         systemClock,
66                         coroutineScope,
67                         logger
68                 )
69             } else {
70                 SystemStatusAnimationSchedulerLegacyImpl(
71                         coordinator,
72                         chipAnimationController,
73                         statusBarWindowController,
74                         dumpManager,
75                         systemClock,
76                         executor
77                 )
78             }
79         }
80     }
81 }
82 
83