• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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.pipeline.dagger
18 
19 import android.net.wifi.WifiManager
20 import com.android.systemui.CoreStartable
21 import com.android.systemui.dagger.SysUISingleton
22 import com.android.systemui.log.LogBufferFactory
23 import com.android.systemui.log.table.TableLogBuffer
24 import com.android.systemui.log.table.TableLogBufferFactory
25 import com.android.systemui.plugins.log.LogBuffer
26 import com.android.systemui.statusbar.pipeline.airplane.data.repository.AirplaneModeRepository
27 import com.android.systemui.statusbar.pipeline.airplane.data.repository.AirplaneModeRepositoryImpl
28 import com.android.systemui.statusbar.pipeline.airplane.ui.viewmodel.AirplaneModeViewModel
29 import com.android.systemui.statusbar.pipeline.airplane.ui.viewmodel.AirplaneModeViewModelImpl
30 import com.android.systemui.statusbar.pipeline.mobile.data.repository.CarrierConfigCoreStartable
31 import com.android.systemui.statusbar.pipeline.mobile.data.repository.MobileConnectionsRepository
32 import com.android.systemui.statusbar.pipeline.mobile.data.repository.MobileRepositorySwitcher
33 import com.android.systemui.statusbar.pipeline.mobile.data.repository.UserSetupRepository
34 import com.android.systemui.statusbar.pipeline.mobile.data.repository.UserSetupRepositoryImpl
35 import com.android.systemui.statusbar.pipeline.mobile.domain.interactor.MobileIconsInteractor
36 import com.android.systemui.statusbar.pipeline.mobile.domain.interactor.MobileIconsInteractorImpl
37 import com.android.systemui.statusbar.pipeline.mobile.ui.MobileUiAdapter
38 import com.android.systemui.statusbar.pipeline.mobile.util.MobileMappingsProxy
39 import com.android.systemui.statusbar.pipeline.mobile.util.MobileMappingsProxyImpl
40 import com.android.systemui.statusbar.pipeline.shared.data.repository.ConnectivityRepository
41 import com.android.systemui.statusbar.pipeline.shared.data.repository.ConnectivityRepositoryImpl
42 import com.android.systemui.statusbar.pipeline.wifi.data.repository.RealWifiRepository
43 import com.android.systemui.statusbar.pipeline.wifi.data.repository.WifiRepository
44 import com.android.systemui.statusbar.pipeline.wifi.data.repository.WifiRepositorySwitcher
45 import com.android.systemui.statusbar.pipeline.wifi.data.repository.prod.DisabledWifiRepository
46 import com.android.systemui.statusbar.pipeline.wifi.data.repository.prod.WifiRepositoryImpl
47 import com.android.systemui.statusbar.pipeline.wifi.domain.interactor.WifiInteractor
48 import com.android.systemui.statusbar.pipeline.wifi.domain.interactor.WifiInteractorImpl
49 import dagger.Binds
50 import dagger.Module
51 import dagger.Provides
52 import dagger.multibindings.ClassKey
53 import dagger.multibindings.IntoMap
54 
55 @Module
56 abstract class StatusBarPipelineModule {
57     @Binds
airplaneModeRepositorynull58     abstract fun airplaneModeRepository(impl: AirplaneModeRepositoryImpl): AirplaneModeRepository
59 
60     @Binds
61     abstract fun airplaneModeViewModel(impl: AirplaneModeViewModelImpl): AirplaneModeViewModel
62 
63     @Binds
64     abstract fun connectivityRepository(impl: ConnectivityRepositoryImpl): ConnectivityRepository
65 
66     @Binds abstract fun wifiRepository(impl: WifiRepositorySwitcher): WifiRepository
67 
68     @Binds
69     abstract fun wifiInteractor(impl: WifiInteractorImpl): WifiInteractor
70 
71     @Binds
72     abstract fun mobileConnectionsRepository(
73         impl: MobileRepositorySwitcher
74     ): MobileConnectionsRepository
75 
76     @Binds abstract fun userSetupRepository(impl: UserSetupRepositoryImpl): UserSetupRepository
77 
78     @Binds abstract fun mobileMappingsProxy(impl: MobileMappingsProxyImpl): MobileMappingsProxy
79 
80     @Binds
81     abstract fun mobileIconsInteractor(impl: MobileIconsInteractorImpl): MobileIconsInteractor
82 
83     @Binds
84     @IntoMap
85     @ClassKey(MobileUiAdapter::class)
86     abstract fun bindFeature(impl: MobileUiAdapter): CoreStartable
87 
88     @Binds
89     @IntoMap
90     @ClassKey(CarrierConfigCoreStartable::class)
91     abstract fun bindCarrierConfigStartable(impl: CarrierConfigCoreStartable): CoreStartable
92 
93     companion object {
94         @Provides
95         @SysUISingleton
96         fun provideRealWifiRepository(
97             wifiManager: WifiManager?,
98             disabledWifiRepository: DisabledWifiRepository,
99             wifiRepositoryImplFactory: WifiRepositoryImpl.Factory,
100         ): RealWifiRepository {
101             // If we have a null [WifiManager], then the wifi repository should be permanently
102             // disabled.
103             return if (wifiManager == null) {
104                 disabledWifiRepository
105             } else {
106                 wifiRepositoryImplFactory.create(wifiManager)
107             }
108         }
109 
110         @Provides
111         @SysUISingleton
112         @WifiInputLog
113         fun provideWifiInputLogBuffer(factory: LogBufferFactory): LogBuffer {
114             return factory.create("WifiInputLog", 50)
115         }
116 
117         @Provides
118         @SysUISingleton
119         @WifiTableLog
120         fun provideWifiTableLogBuffer(factory: TableLogBufferFactory): TableLogBuffer {
121             return factory.create("WifiTableLog", 100)
122         }
123 
124         @Provides
125         @SysUISingleton
126         @AirplaneTableLog
127         fun provideAirplaneTableLogBuffer(factory: TableLogBufferFactory): TableLogBuffer {
128             return factory.create("AirplaneTableLog", 30)
129         }
130 
131         @Provides
132         @SysUISingleton
133         @SharedConnectivityInputLog
134         fun provideSharedConnectivityTableLogBuffer(factory: LogBufferFactory): LogBuffer {
135             return factory.create("SharedConnectivityInputLog", 30)
136         }
137 
138         @Provides
139         @SysUISingleton
140         @MobileSummaryLog
141         fun provideMobileSummaryLogBuffer(factory: TableLogBufferFactory): TableLogBuffer {
142             return factory.create("MobileSummaryLog", 100)
143         }
144 
145         @Provides
146         @SysUISingleton
147         @MobileInputLog
148         fun provideMobileInputLogBuffer(factory: LogBufferFactory): LogBuffer {
149             return factory.create("MobileInputLog", 100)
150         }
151 
152         @Provides
153         @SysUISingleton
154         @MobileViewLog
155         fun provideMobileViewLogBuffer(factory: LogBufferFactory): LogBuffer {
156             return factory.create("MobileViewLog", 100)
157         }
158 
159         @Provides
160         @SysUISingleton
161         @VerboseMobileViewLog
162         fun provideVerboseMobileViewLogBuffer(factory: LogBufferFactory): LogBuffer {
163             return factory.create("VerboseMobileViewLog", 100)
164         }
165     }
166 }
167