• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2019 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.phone.dagger;
18 
19 import android.annotation.Nullable;
20 import android.content.ContentResolver;
21 import android.os.Handler;
22 import android.view.LayoutInflater;
23 import android.view.ViewStub;
24 
25 import androidx.constraintlayout.motion.widget.MotionLayout;
26 
27 import com.android.keyguard.KeyguardUpdateMonitor;
28 import com.android.keyguard.LockIconView;
29 import com.android.systemui.R;
30 import com.android.systemui.battery.BatteryMeterView;
31 import com.android.systemui.battery.BatteryMeterViewController;
32 import com.android.systemui.biometrics.AuthRippleView;
33 import com.android.systemui.dagger.qualifiers.Main;
34 import com.android.systemui.dump.DumpManager;
35 import com.android.systemui.flags.FeatureFlags;
36 import com.android.systemui.plugins.statusbar.StatusBarStateController;
37 import com.android.systemui.privacy.OngoingPrivacyChip;
38 import com.android.systemui.settings.UserTracker;
39 import com.android.systemui.shade.CombinedShadeHeadersConstraintManager;
40 import com.android.systemui.shade.CombinedShadeHeadersConstraintManagerImpl;
41 import com.android.systemui.shade.NotificationPanelView;
42 import com.android.systemui.shade.NotificationPanelViewController;
43 import com.android.systemui.shade.NotificationShadeWindowView;
44 import com.android.systemui.shade.NotificationsQuickSettingsContainer;
45 import com.android.systemui.shade.ShadeExpansionStateManager;
46 import com.android.systemui.statusbar.CommandQueue;
47 import com.android.systemui.statusbar.NotificationShelf;
48 import com.android.systemui.statusbar.NotificationShelfController;
49 import com.android.systemui.statusbar.OperatorNameViewController;
50 import com.android.systemui.statusbar.core.StatusBarInitializer.OnStatusBarViewInitializedListener;
51 import com.android.systemui.statusbar.events.SystemStatusAnimationScheduler;
52 import com.android.systemui.statusbar.notification.row.dagger.NotificationShelfComponent;
53 import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout;
54 import com.android.systemui.statusbar.phone.KeyguardBottomAreaView;
55 import com.android.systemui.statusbar.phone.LetterboxAppearanceCalculator;
56 import com.android.systemui.statusbar.phone.NotificationIconAreaController;
57 import com.android.systemui.statusbar.phone.StatusBarBoundsProvider;
58 import com.android.systemui.statusbar.phone.StatusBarHideIconsForBouncerManager;
59 import com.android.systemui.statusbar.phone.StatusBarIconController;
60 import com.android.systemui.statusbar.phone.StatusBarLocationPublisher;
61 import com.android.systemui.statusbar.phone.StatusIconContainer;
62 import com.android.systemui.statusbar.phone.SystemBarAttributesListener;
63 import com.android.systemui.statusbar.phone.TapAgainView;
64 import com.android.systemui.statusbar.phone.fragment.CollapsedStatusBarFragment;
65 import com.android.systemui.statusbar.phone.fragment.CollapsedStatusBarFragmentLogger;
66 import com.android.systemui.statusbar.phone.fragment.dagger.StatusBarFragmentComponent;
67 import com.android.systemui.statusbar.phone.ongoingcall.OngoingCallController;
68 import com.android.systemui.statusbar.policy.BatteryController;
69 import com.android.systemui.statusbar.policy.ConfigurationController;
70 import com.android.systemui.statusbar.policy.KeyguardStateController;
71 import com.android.systemui.statusbar.window.StatusBarWindowStateController;
72 import com.android.systemui.tuner.TunerService;
73 import com.android.systemui.util.CarrierConfigTracker;
74 import com.android.systemui.util.settings.SecureSettings;
75 
76 import java.util.concurrent.Executor;
77 
78 import javax.inject.Named;
79 
80 import dagger.Binds;
81 import dagger.Module;
82 import dagger.Provides;
83 import dagger.multibindings.IntoSet;
84 
85 @Module(subcomponents = StatusBarFragmentComponent.class)
86 public abstract class StatusBarViewModule {
87 
88     public static final String SHADE_HEADER = "large_screen_shade_header";
89     public static final String STATUS_BAR_FRAGMENT = "status_bar_fragment";
90 
91     /** */
92     @Provides
93     @CentralSurfacesComponent.CentralSurfacesScope
providesNotificationShadeWindowView( LayoutInflater layoutInflater)94     public static NotificationShadeWindowView providesNotificationShadeWindowView(
95             LayoutInflater layoutInflater) {
96         NotificationShadeWindowView notificationShadeWindowView = (NotificationShadeWindowView)
97                 layoutInflater.inflate(R.layout.super_notification_shade, /* root= */ null);
98         if (notificationShadeWindowView == null) {
99             throw new IllegalStateException(
100                     "R.layout.super_notification_shade could not be properly inflated");
101         }
102 
103         return notificationShadeWindowView;
104     }
105 
106     /** */
107     @Provides
108     @CentralSurfacesComponent.CentralSurfacesScope
providesNotificationStackScrollLayout( NotificationShadeWindowView notificationShadeWindowView)109     public static NotificationStackScrollLayout providesNotificationStackScrollLayout(
110             NotificationShadeWindowView notificationShadeWindowView) {
111         return notificationShadeWindowView.findViewById(R.id.notification_stack_scroller);
112     }
113 
114     /** */
115     @Provides
116     @CentralSurfacesComponent.CentralSurfacesScope
providesNotificationShelf(LayoutInflater layoutInflater, NotificationStackScrollLayout notificationStackScrollLayout)117     public static NotificationShelf providesNotificationShelf(LayoutInflater layoutInflater,
118             NotificationStackScrollLayout notificationStackScrollLayout) {
119         NotificationShelf view = (NotificationShelf) layoutInflater.inflate(
120                 R.layout.status_bar_notification_shelf, notificationStackScrollLayout, false);
121 
122         if (view == null) {
123             throw new IllegalStateException(
124                     "R.layout.status_bar_notification_shelf could not be properly inflated");
125         }
126         return view;
127     }
128 
129     /** */
130     @Provides
131     @CentralSurfacesComponent.CentralSurfacesScope
providesStatusBarWindowView( NotificationShelfComponent.Builder notificationShelfComponentBuilder, NotificationShelf notificationShelf)132     public static NotificationShelfController providesStatusBarWindowView(
133             NotificationShelfComponent.Builder notificationShelfComponentBuilder,
134             NotificationShelf notificationShelf) {
135         NotificationShelfComponent component = notificationShelfComponentBuilder
136                 .notificationShelf(notificationShelf)
137                 .build();
138         NotificationShelfController notificationShelfController =
139                 component.getNotificationShelfController();
140         notificationShelfController.init();
141 
142         return notificationShelfController;
143     }
144 
145     /** */
146     @Provides
147     @CentralSurfacesComponent.CentralSurfacesScope
getNotificationPanelView( NotificationShadeWindowView notificationShadeWindowView)148     public static NotificationPanelView getNotificationPanelView(
149             NotificationShadeWindowView notificationShadeWindowView) {
150         return notificationShadeWindowView.getNotificationPanelView();
151     }
152 
153     /** */
154     @Provides
155     @CentralSurfacesComponent.CentralSurfacesScope
getLockIconView( NotificationShadeWindowView notificationShadeWindowView)156     public static LockIconView getLockIconView(
157             NotificationShadeWindowView notificationShadeWindowView) {
158         return notificationShadeWindowView.findViewById(R.id.lock_icon_view);
159     }
160 
161     /** */
162     @Provides
163     @CentralSurfacesComponent.CentralSurfacesScope
164     @Nullable
getAuthRippleView( NotificationShadeWindowView notificationShadeWindowView)165     public static AuthRippleView getAuthRippleView(
166             NotificationShadeWindowView notificationShadeWindowView) {
167         return notificationShadeWindowView.findViewById(R.id.auth_ripple);
168     }
169 
170     /** */
171     @Provides
172     @Named(SHADE_HEADER)
173     @CentralSurfacesComponent.CentralSurfacesScope
getLargeScreenShadeHeaderBarView( NotificationShadeWindowView notificationShadeWindowView, FeatureFlags featureFlags)174     public static MotionLayout getLargeScreenShadeHeaderBarView(
175             NotificationShadeWindowView notificationShadeWindowView,
176             FeatureFlags featureFlags) {
177         ViewStub stub = notificationShadeWindowView.findViewById(R.id.qs_header_stub);
178         int layoutId = R.layout.combined_qs_header;
179         stub.setLayoutResource(layoutId);
180         MotionLayout v = (MotionLayout) stub.inflate();
181         return v;
182     }
183 
184     /** */
185     @Provides
186     @CentralSurfacesComponent.CentralSurfacesScope
187     public static CombinedShadeHeadersConstraintManager
provideCombinedShadeHeadersConstraintManager()188             provideCombinedShadeHeadersConstraintManager() {
189         return CombinedShadeHeadersConstraintManagerImpl.INSTANCE;
190     }
191 
192     /** */
193     @Provides
194     @CentralSurfacesComponent.CentralSurfacesScope
getSplitShadeOngoingPrivacyChip( @amedSHADE_HEADER) MotionLayout header)195     public static OngoingPrivacyChip getSplitShadeOngoingPrivacyChip(
196             @Named(SHADE_HEADER) MotionLayout header) {
197         return header.findViewById(R.id.privacy_chip);
198     }
199 
200     /** */
201     @Provides
202     @CentralSurfacesComponent.CentralSurfacesScope
providesStatusIconContainer( @amedSHADE_HEADER) MotionLayout header)203     static StatusIconContainer providesStatusIconContainer(
204             @Named(SHADE_HEADER) MotionLayout header) {
205         return header.findViewById(R.id.statusIcons);
206     }
207 
208     /** */
209     @Provides
210     @CentralSurfacesComponent.CentralSurfacesScope
211     @Named(SHADE_HEADER)
getBatteryMeterView(@amedSHADE_HEADER) MotionLayout view)212     static BatteryMeterView getBatteryMeterView(@Named(SHADE_HEADER) MotionLayout view) {
213         return view.findViewById(R.id.batteryRemainingIcon);
214     }
215 
216     @Provides
217     @CentralSurfacesComponent.CentralSurfacesScope
218     @Named(SHADE_HEADER)
getBatteryMeterViewController( @amedSHADE_HEADER) BatteryMeterView batteryMeterView, UserTracker userTracker, ConfigurationController configurationController, TunerService tunerService, @Main Handler mainHandler, ContentResolver contentResolver, FeatureFlags featureFlags, BatteryController batteryController )219     static BatteryMeterViewController getBatteryMeterViewController(
220             @Named(SHADE_HEADER) BatteryMeterView batteryMeterView,
221             UserTracker userTracker,
222             ConfigurationController configurationController,
223             TunerService tunerService,
224             @Main Handler mainHandler,
225             ContentResolver contentResolver,
226             FeatureFlags featureFlags,
227             BatteryController batteryController
228     ) {
229         return new BatteryMeterViewController(
230                 batteryMeterView,
231                 userTracker,
232                 configurationController,
233                 tunerService,
234                 mainHandler,
235                 contentResolver,
236                 featureFlags,
237                 batteryController);
238 
239     }
240 
241     /** */
242     @Provides
243     @CentralSurfacesComponent.CentralSurfacesScope
getTapAgainView(NotificationPanelView npv)244     public static TapAgainView getTapAgainView(NotificationPanelView npv) {
245         return npv.getTapAgainView();
246     }
247 
248     /** */
249     @Provides
250     @CentralSurfacesComponent.CentralSurfacesScope
getNotificationsQuickSettingsContainer( NotificationShadeWindowView notificationShadeWindowView)251     public static NotificationsQuickSettingsContainer getNotificationsQuickSettingsContainer(
252             NotificationShadeWindowView notificationShadeWindowView) {
253         return notificationShadeWindowView.findViewById(R.id.notification_container_parent);
254     }
255 
256     @Binds
257     @IntoSet
statusBarInitializedListener( LetterboxAppearanceCalculator letterboxAppearanceCalculator )258     abstract OnStatusBarViewInitializedListener statusBarInitializedListener(
259             LetterboxAppearanceCalculator letterboxAppearanceCalculator
260     );
261 
262     @Binds
263     @IntoSet
sysBarAttrsListenerAsBoundsListener( SystemBarAttributesListener systemBarAttributesListener)264     abstract StatusBarBoundsProvider.BoundsChangeListener sysBarAttrsListenerAsBoundsListener(
265             SystemBarAttributesListener systemBarAttributesListener);
266 
267     /**
268      * Creates a new {@link CollapsedStatusBarFragment}.
269      *
270      * **IMPORTANT**: This method intentionally does not have
271      * {@link CentralSurfacesComponent.CentralSurfacesScope}, which means a new fragment *will* be
272      * created each time this method is called. This is intentional because we need fragments to
273      * re-created in certain lifecycle scenarios.
274      *
275      * This provider is {@link Named} such that it does not conflict with the provider inside of
276      * {@link StatusBarFragmentComponent}.
277      */
278     @Provides
279     @Named(STATUS_BAR_FRAGMENT)
createCollapsedStatusBarFragment( StatusBarFragmentComponent.Factory statusBarFragmentComponentFactory, OngoingCallController ongoingCallController, SystemStatusAnimationScheduler animationScheduler, StatusBarLocationPublisher locationPublisher, NotificationIconAreaController notificationIconAreaController, ShadeExpansionStateManager shadeExpansionStateManager, FeatureFlags featureFlags, StatusBarIconController statusBarIconController, StatusBarIconController.DarkIconManager.Factory darkIconManagerFactory, StatusBarHideIconsForBouncerManager statusBarHideIconsForBouncerManager, KeyguardStateController keyguardStateController, NotificationPanelViewController notificationPanelViewController, StatusBarStateController statusBarStateController, CommandQueue commandQueue, CarrierConfigTracker carrierConfigTracker, CollapsedStatusBarFragmentLogger collapsedStatusBarFragmentLogger, OperatorNameViewController.Factory operatorNameViewControllerFactory, SecureSettings secureSettings, @Main Executor mainExecutor, DumpManager dumpManager, StatusBarWindowStateController statusBarWindowStateController, KeyguardUpdateMonitor keyguardUpdateMonitor )280     public static CollapsedStatusBarFragment createCollapsedStatusBarFragment(
281             StatusBarFragmentComponent.Factory statusBarFragmentComponentFactory,
282             OngoingCallController ongoingCallController,
283             SystemStatusAnimationScheduler animationScheduler,
284             StatusBarLocationPublisher locationPublisher,
285             NotificationIconAreaController notificationIconAreaController,
286             ShadeExpansionStateManager shadeExpansionStateManager,
287             FeatureFlags featureFlags,
288             StatusBarIconController statusBarIconController,
289             StatusBarIconController.DarkIconManager.Factory darkIconManagerFactory,
290             StatusBarHideIconsForBouncerManager statusBarHideIconsForBouncerManager,
291             KeyguardStateController keyguardStateController,
292             NotificationPanelViewController notificationPanelViewController,
293             StatusBarStateController statusBarStateController,
294             CommandQueue commandQueue,
295             CarrierConfigTracker carrierConfigTracker,
296             CollapsedStatusBarFragmentLogger collapsedStatusBarFragmentLogger,
297             OperatorNameViewController.Factory operatorNameViewControllerFactory,
298             SecureSettings secureSettings,
299             @Main Executor mainExecutor,
300             DumpManager dumpManager,
301             StatusBarWindowStateController statusBarWindowStateController,
302             KeyguardUpdateMonitor keyguardUpdateMonitor
303     ) {
304         return new CollapsedStatusBarFragment(statusBarFragmentComponentFactory,
305                 ongoingCallController,
306                 animationScheduler,
307                 locationPublisher,
308                 notificationIconAreaController,
309                 shadeExpansionStateManager,
310                 featureFlags,
311                 statusBarIconController,
312                 darkIconManagerFactory,
313                 statusBarHideIconsForBouncerManager,
314                 keyguardStateController,
315                 notificationPanelViewController,
316                 statusBarStateController,
317                 commandQueue,
318                 carrierConfigTracker,
319                 collapsedStatusBarFragmentLogger,
320                 operatorNameViewControllerFactory,
321                 secureSettings,
322                 mainExecutor,
323                 dumpManager,
324                 statusBarWindowStateController,
325                 keyguardUpdateMonitor);
326     }
327 
328     /**
329      * Constructs a new, unattached {@link KeyguardBottomAreaView}.
330      *
331      * Note that this is explicitly _not_ a singleton, as we want to be able to reinflate it
332      */
333     @Provides
providesKeyguardBottomAreaView( NotificationPanelView npv, LayoutInflater layoutInflater)334     public static KeyguardBottomAreaView providesKeyguardBottomAreaView(
335             NotificationPanelView npv, LayoutInflater layoutInflater) {
336         return (KeyguardBottomAreaView) layoutInflater.inflate(R
337                 .layout.keyguard_bottom_area, npv, false);
338     }
339 
340 }
341