1 /*
2  * Copyright (C) 2020 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.notification;
18 
19 import android.content.Context;
20 
21 import com.android.car.notification.CarHeadsUpNotificationManager;
22 import com.android.car.notification.CarNotificationListener;
23 import com.android.car.notification.CarUxRestrictionManagerWrapper;
24 import com.android.car.notification.NotificationClickHandlerFactory;
25 import com.android.car.notification.NotificationDataManager;
26 import com.android.car.notification.headsup.CarHeadsUpNotificationContainer;
27 import com.android.internal.statusbar.IStatusBarService;
28 import com.android.systemui.dagger.SysUISingleton;
29 
30 import dagger.Binds;
31 import dagger.Module;
32 import dagger.Provides;
33 
34 /**
35  * Module for Car SysUI Notifications
36  */
37 @Module
38 public abstract class CarNotificationModule {
39     @Provides
40     @SysUISingleton
provideNotificationClickHandlerFactory( IStatusBarService barService)41     static NotificationClickHandlerFactory provideNotificationClickHandlerFactory(
42             IStatusBarService barService) {
43         return new NotificationClickHandlerFactory(barService);
44     }
45 
46     @Provides
47     @SysUISingleton
provideNotificationDataManager()48     static NotificationDataManager provideNotificationDataManager() {
49         return NotificationDataManager.getInstance();
50     }
51 
52     @Provides
53     @SysUISingleton
provideCarUxRestrictionManagerWrapper()54     static CarUxRestrictionManagerWrapper provideCarUxRestrictionManagerWrapper() {
55         return new CarUxRestrictionManagerWrapper();
56     }
57 
58     @Provides
59     @SysUISingleton
provideCarNotificationListener(Context context, CarUxRestrictionManagerWrapper carUxRestrictionManagerWrapper, CarHeadsUpNotificationManager carHeadsUpNotificationManager)60     static CarNotificationListener provideCarNotificationListener(Context context,
61             CarUxRestrictionManagerWrapper carUxRestrictionManagerWrapper,
62             CarHeadsUpNotificationManager carHeadsUpNotificationManager) {
63         CarNotificationListener listener = new CarNotificationListener();
64         listener.registerAsSystemService(context, carUxRestrictionManagerWrapper,
65                 carHeadsUpNotificationManager);
66         return listener;
67     }
68 
69     @Provides
70     @SysUISingleton
provideCarHeadsUpNotificationManager(Context context, NotificationClickHandlerFactory notificationClickHandlerFactory, CarHeadsUpNotificationContainer headsUpNotificationDisplay)71     static CarHeadsUpNotificationManager provideCarHeadsUpNotificationManager(Context context,
72             NotificationClickHandlerFactory notificationClickHandlerFactory,
73             CarHeadsUpNotificationContainer headsUpNotificationDisplay) {
74         return new CarHeadsUpNotificationManager(context, notificationClickHandlerFactory,
75                 headsUpNotificationDisplay);
76     }
77 
78     @Binds
bindsCarHeadsUpNotificationContainer( CarHeadsUpNotificationSystemContainer carHeadsUpNotificationSystemContainer)79     abstract CarHeadsUpNotificationContainer bindsCarHeadsUpNotificationContainer(
80             CarHeadsUpNotificationSystemContainer carHeadsUpNotificationSystemContainer);
81 }
82