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.car.keyguard;
18 
19 import android.app.IActivityTaskManager;
20 import android.app.trust.TrustManager;
21 import android.content.Context;
22 import android.os.PowerManager;
23 
24 import com.android.internal.jank.InteractionJankMonitor;
25 import com.android.internal.logging.UiEventLogger;
26 import com.android.internal.widget.LockPatternUtils;
27 import com.android.keyguard.KeyguardDisplayManager;
28 import com.android.keyguard.KeyguardUpdateMonitor;
29 import com.android.keyguard.KeyguardViewController;
30 import com.android.keyguard.ViewMediatorCallback;
31 import com.android.keyguard.dagger.KeyguardQsUserSwitchComponent;
32 import com.android.keyguard.dagger.KeyguardStatusBarViewComponent;
33 import com.android.keyguard.dagger.KeyguardStatusViewComponent;
34 import com.android.keyguard.dagger.KeyguardUserSwitcherComponent;
35 import com.android.keyguard.mediator.ScreenOnCoordinator;
36 import com.android.systemui.CoreStartable;
37 import com.android.systemui.animation.ActivityTransitionAnimator;
38 import com.android.systemui.broadcast.BroadcastDispatcher;
39 import com.android.systemui.classifier.FalsingCollector;
40 import com.android.systemui.classifier.FalsingModule;
41 import com.android.systemui.communal.ui.viewmodel.CommunalTransitionViewModel;
42 import com.android.systemui.dagger.SysUISingleton;
43 import com.android.systemui.dagger.qualifiers.Main;
44 import com.android.systemui.dagger.qualifiers.UiBackground;
45 import com.android.systemui.dreams.DreamOverlayStateController;
46 import com.android.systemui.dreams.ui.viewmodel.DreamViewModel;
47 import com.android.systemui.dump.DumpManager;
48 import com.android.systemui.flags.FeatureFlags;
49 import com.android.systemui.flags.SystemPropertiesHelper;
50 import com.android.systemui.keyguard.DismissCallbackRegistry;
51 import com.android.systemui.keyguard.KeyguardUnlockAnimationController;
52 import com.android.systemui.keyguard.KeyguardViewMediator;
53 import com.android.systemui.keyguard.WindowManagerLockscreenVisibilityManager;
54 import com.android.systemui.keyguard.WindowManagerOcclusionManager;
55 import com.android.systemui.keyguard.dagger.KeyguardFaceAuthNotSupportedModule;
56 import com.android.systemui.keyguard.data.repository.KeyguardRepositoryModule;
57 import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor;
58 import com.android.systemui.log.SessionTracker;
59 import com.android.systemui.navigationbar.NavigationModeController;
60 import com.android.systemui.settings.UserTracker;
61 import com.android.systemui.shade.ShadeController;
62 import com.android.systemui.statusbar.NotificationShadeDepthController;
63 import com.android.systemui.statusbar.NotificationShadeWindowController;
64 import com.android.systemui.statusbar.SysuiStatusBarStateController;
65 import com.android.systemui.statusbar.phone.DozeParameters;
66 import com.android.systemui.statusbar.phone.ScreenOffAnimationController;
67 import com.android.systemui.statusbar.phone.ScrimController;
68 import com.android.systemui.statusbar.policy.KeyguardStateController;
69 import com.android.systemui.statusbar.policy.UserSwitcherController;
70 import com.android.systemui.user.domain.interactor.SelectedUserInteractor;
71 import com.android.systemui.util.DeviceConfigProxy;
72 import com.android.systemui.util.kotlin.JavaAdapter;
73 import com.android.systemui.util.settings.SecureSettings;
74 import com.android.systemui.util.settings.SystemSettings;
75 import com.android.systemui.util.time.SystemClock;
76 import com.android.systemui.wallpapers.data.repository.WallpaperRepository;
77 import com.android.wm.shell.keyguard.KeyguardTransitions;
78 
79 import dagger.Binds;
80 import dagger.Lazy;
81 import dagger.Module;
82 import dagger.Provides;
83 import dagger.multibindings.ClassKey;
84 import dagger.multibindings.IntoMap;
85 
86 import java.util.concurrent.Executor;
87 
88 import kotlinx.coroutines.CoroutineDispatcher;
89 
90 /**
91  * Dagger Module providing keyguard.
92  */
93 @Module(subcomponents = {
94         KeyguardQsUserSwitchComponent.class,
95         KeyguardStatusBarViewComponent.class,
96         KeyguardStatusViewComponent.class,
97         KeyguardUserSwitcherComponent.class},
98         includes = {
99                 FalsingModule.class,
100                 KeyguardFaceAuthNotSupportedModule.class,
101                 KeyguardRepositoryModule.class,
102         })
103 public interface CarKeyguardModule {
104 
105     /**
106      * Provides our instance of CarKeyguardViewMediator
107      */
108     @Provides
109     @SysUISingleton
newKeyguardViewMediator( Context context, UiEventLogger uiEventLogger, SessionTracker sessionTracker, UserTracker userTracker, FalsingCollector falsingCollector, LockPatternUtils lockPatternUtils, BroadcastDispatcher broadcastDispatcher, Lazy<KeyguardViewController> statusBarKeyguardViewManagerLazy, DismissCallbackRegistry dismissCallbackRegistry, KeyguardUpdateMonitor updateMonitor, DumpManager dumpManager, PowerManager powerManager, TrustManager trustManager, UserSwitcherController userSwitcherController, @UiBackground Executor uiBgExecutor, DeviceConfigProxy deviceConfig, NavigationModeController navigationModeController, KeyguardDisplayManager keyguardDisplayManager, DozeParameters dozeParameters, SysuiStatusBarStateController statusBarStateController, KeyguardStateController keyguardStateController, Lazy<KeyguardUnlockAnimationController> keyguardUnlockAnimationController, ScreenOffAnimationController screenOffAnimationController, Lazy<NotificationShadeDepthController> notificationShadeDepthController, ScreenOnCoordinator screenOnCoordinator, KeyguardTransitions keyguardTransitions, InteractionJankMonitor interactionJankMonitor, DreamOverlayStateController dreamOverlayStateController, JavaAdapter javaAdapter, WallpaperRepository wallpaperRepository, Lazy<ShadeController> shadeController, Lazy<NotificationShadeWindowController> notificationShadeWindowController, Lazy<ActivityTransitionAnimator> activityTransitionAnimator, Lazy<ScrimController> scrimControllerLazy, IActivityTaskManager activityTaskManagerService, FeatureFlags featureFlags, SecureSettings secureSettings, SystemSettings systemSettings, SystemClock systemClock, @Main CoroutineDispatcher mainDispatcher, Lazy<DreamViewModel> dreamViewModel, Lazy<CommunalTransitionViewModel> communalTransitionViewModel, SystemPropertiesHelper systemPropertiesHelper, Lazy<WindowManagerLockscreenVisibilityManager> wmLockscreenVisibilityManager, SelectedUserInteractor selectedUserInteractor, KeyguardInteractor keyguardInteractor, WindowManagerOcclusionManager wmOcclusionManager)110     static KeyguardViewMediator newKeyguardViewMediator(
111             Context context,
112             UiEventLogger uiEventLogger,
113             SessionTracker sessionTracker,
114             UserTracker userTracker,
115             FalsingCollector falsingCollector,
116             LockPatternUtils lockPatternUtils,
117             BroadcastDispatcher broadcastDispatcher,
118             Lazy<KeyguardViewController> statusBarKeyguardViewManagerLazy,
119             DismissCallbackRegistry dismissCallbackRegistry,
120             KeyguardUpdateMonitor updateMonitor,
121             DumpManager dumpManager,
122             PowerManager powerManager,
123             TrustManager trustManager,
124             UserSwitcherController userSwitcherController,
125             @UiBackground Executor uiBgExecutor,
126             DeviceConfigProxy deviceConfig,
127             NavigationModeController navigationModeController,
128             KeyguardDisplayManager keyguardDisplayManager,
129             DozeParameters dozeParameters,
130             SysuiStatusBarStateController statusBarStateController,
131             KeyguardStateController keyguardStateController,
132             Lazy<KeyguardUnlockAnimationController> keyguardUnlockAnimationController,
133             ScreenOffAnimationController screenOffAnimationController,
134             Lazy<NotificationShadeDepthController> notificationShadeDepthController,
135             ScreenOnCoordinator screenOnCoordinator,
136             KeyguardTransitions keyguardTransitions,
137             InteractionJankMonitor interactionJankMonitor,
138             DreamOverlayStateController dreamOverlayStateController,
139             JavaAdapter javaAdapter,
140             WallpaperRepository wallpaperRepository,
141             Lazy<ShadeController> shadeController,
142             Lazy<NotificationShadeWindowController> notificationShadeWindowController,
143             Lazy<ActivityTransitionAnimator> activityTransitionAnimator,
144             Lazy<ScrimController> scrimControllerLazy,
145             IActivityTaskManager activityTaskManagerService,
146             FeatureFlags featureFlags,
147             SecureSettings secureSettings,
148             SystemSettings systemSettings,
149             SystemClock systemClock,
150             @Main CoroutineDispatcher mainDispatcher,
151             Lazy<DreamViewModel> dreamViewModel,
152             Lazy<CommunalTransitionViewModel> communalTransitionViewModel,
153             SystemPropertiesHelper systemPropertiesHelper,
154             Lazy<WindowManagerLockscreenVisibilityManager> wmLockscreenVisibilityManager,
155             SelectedUserInteractor selectedUserInteractor,
156             KeyguardInteractor keyguardInteractor,
157             WindowManagerOcclusionManager wmOcclusionManager) {
158         return new CarKeyguardViewMediator(
159                 context,
160                 uiEventLogger,
161                 sessionTracker,
162                 userTracker,
163                 falsingCollector,
164                 lockPatternUtils,
165                 broadcastDispatcher,
166                 statusBarKeyguardViewManagerLazy,
167                 dismissCallbackRegistry,
168                 updateMonitor,
169                 dumpManager,
170                 uiBgExecutor,
171                 powerManager,
172                 trustManager,
173                 userSwitcherController,
174                 deviceConfig,
175                 navigationModeController,
176                 keyguardDisplayManager,
177                 dozeParameters,
178                 statusBarStateController,
179                 keyguardStateController,
180                 keyguardUnlockAnimationController,
181                 screenOffAnimationController,
182                 notificationShadeDepthController,
183                 screenOnCoordinator,
184                 keyguardTransitions,
185                 interactionJankMonitor,
186                 dreamOverlayStateController,
187                 javaAdapter,
188                 wallpaperRepository,
189                 shadeController,
190                 notificationShadeWindowController,
191                 activityTransitionAnimator,
192                 scrimControllerLazy,
193                 activityTaskManagerService,
194                 featureFlags,
195                 secureSettings,
196                 systemSettings,
197                 systemClock,
198                 mainDispatcher,
199                 dreamViewModel,
200                 communalTransitionViewModel,
201                 systemPropertiesHelper,
202                 wmLockscreenVisibilityManager,
203                 selectedUserInteractor,
204                 keyguardInteractor,
205                 wmOcclusionManager);
206     }
207 
208     /** */
209     @Provides
providesViewMediatorCallback(KeyguardViewMediator viewMediator)210     static ViewMediatorCallback providesViewMediatorCallback(KeyguardViewMediator viewMediator) {
211         return viewMediator.getViewMediatorCallback();
212     }
213 
214     /** Binds {@link KeyguardUpdateMonitor} as a {@link CoreStartable}. */
215     @Binds
216     @IntoMap
217     @ClassKey(KeyguardUpdateMonitor.class)
bindsKeyguardUpdateMonitor(KeyguardUpdateMonitor keyguardUpdateMonitor)218     CoreStartable bindsKeyguardUpdateMonitor(KeyguardUpdateMonitor keyguardUpdateMonitor);
219 }
220