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.dagger;
18 
19 import com.android.systemui.BootCompleteCacheImpl;
20 import com.android.systemui.CoreStartable;
21 import com.android.systemui.Dependency;
22 import com.android.systemui.InitController;
23 import com.android.systemui.SystemUIAppComponentFactoryBase;
24 import com.android.systemui.dagger.qualifiers.PerUser;
25 import com.android.systemui.dump.DumpManager;
26 import com.android.systemui.keyguard.KeyguardSliceProvider;
27 import com.android.systemui.people.PeopleProvider;
28 import com.android.systemui.startable.Dependencies;
29 import com.android.systemui.statusbar.NotificationInsetsModule;
30 import com.android.systemui.statusbar.QsFrameTranslateModule;
31 import com.android.systemui.statusbar.policy.ConfigurationController;
32 import com.android.wm.shell.back.BackAnimation;
33 import com.android.wm.shell.bubbles.Bubbles;
34 import com.android.wm.shell.desktopmode.DesktopMode;
35 import com.android.wm.shell.displayareahelper.DisplayAreaHelper;
36 import com.android.wm.shell.keyguard.KeyguardTransitions;
37 import com.android.wm.shell.onehanded.OneHanded;
38 import com.android.wm.shell.pip.Pip;
39 import com.android.wm.shell.recents.RecentTasks;
40 import com.android.wm.shell.shared.ShellTransitions;
41 import com.android.wm.shell.splitscreen.SplitScreen;
42 import com.android.wm.shell.startingsurface.StartingSurface;
43 import com.android.wm.shell.sysui.ShellInterface;
44 import com.android.wm.shell.taskview.TaskViewFactory;
45 
46 import dagger.BindsInstance;
47 import dagger.Subcomponent;
48 
49 import java.util.Map;
50 import java.util.Optional;
51 import java.util.Set;
52 
53 import javax.inject.Provider;
54 
55 /**
56  * An example Dagger Subcomponent for Core SysUI.
57  * <p>
58  * See {@link ReferenceSysUIComponent} for the one actually used by AOSP.
59  */
60 @SysUISingleton
61 @Subcomponent(modules = {
62         DefaultComponentBinder.class,
63         DependencyProvider.class,
64         NotificationInsetsModule.class,
65         QsFrameTranslateModule.class,
66         SystemUIBinder.class,
67         SystemUIModule.class,
68         SystemUICoreStartableModule.class,
69         ReferenceSystemUIModule.class})
70 public interface SysUIComponent {
71 
72     /**
73      * Builder for a SysUIComponent.
74      */
75     @SysUISingleton
76     @Subcomponent.Builder
77     interface Builder {
78         @BindsInstance
setShell(ShellInterface s)79         Builder setShell(ShellInterface s);
80 
81         @BindsInstance
setPip(Optional<Pip> p)82         Builder setPip(Optional<Pip> p);
83 
84         @BindsInstance
setSplitScreen(Optional<SplitScreen> s)85         Builder setSplitScreen(Optional<SplitScreen> s);
86 
87         @BindsInstance
setOneHanded(Optional<OneHanded> o)88         Builder setOneHanded(Optional<OneHanded> o);
89 
90         @BindsInstance
setBubbles(Optional<Bubbles> b)91         Builder setBubbles(Optional<Bubbles> b);
92 
93         @BindsInstance
setTaskViewFactory(Optional<TaskViewFactory> t)94         Builder setTaskViewFactory(Optional<TaskViewFactory> t);
95 
96         @BindsInstance
setShellTransitions(ShellTransitions t)97         Builder setShellTransitions(ShellTransitions t);
98 
99         @BindsInstance
setKeyguardTransitions(KeyguardTransitions k)100         Builder setKeyguardTransitions(KeyguardTransitions k);
101 
102         @BindsInstance
setStartingSurface(Optional<StartingSurface> s)103         Builder setStartingSurface(Optional<StartingSurface> s);
104 
105         @BindsInstance
setDisplayAreaHelper(Optional<DisplayAreaHelper> h)106         Builder setDisplayAreaHelper(Optional<DisplayAreaHelper> h);
107 
108         @BindsInstance
setRecentTasks(Optional<RecentTasks> r)109         Builder setRecentTasks(Optional<RecentTasks> r);
110 
111         @BindsInstance
setBackAnimation(Optional<BackAnimation> b)112         Builder setBackAnimation(Optional<BackAnimation> b);
113 
114         @BindsInstance
setDesktopMode(Optional<DesktopMode> d)115         Builder setDesktopMode(Optional<DesktopMode> d);
116 
build()117         SysUIComponent build();
118     }
119 
120     /**
121      * Provides a BootCompleteCache.
122      */
123     @SysUISingleton
provideBootCacheImpl()124     BootCompleteCacheImpl provideBootCacheImpl();
125 
126     /**
127      * Creates a ContextComponentHelper.
128      */
129     @SysUISingleton
getConfigurationController()130     ConfigurationController getConfigurationController();
131 
132     /**
133      * Creates a ContextComponentHelper.
134      */
135     @SysUISingleton
getContextComponentHelper()136     ContextComponentHelper getContextComponentHelper();
137 
138     /**
139      * Main dependency providing module.
140      */
141     @SysUISingleton
createDependency()142     Dependency createDependency();
143 
144     /** */
145     @SysUISingleton
createDumpManager()146     DumpManager createDumpManager();
147 
148     /**
149      * Creates a InitController.
150      */
151     @SysUISingleton
getInitController()152     InitController getInitController();
153 
154     /**
155      * Returns {@link CoreStartable}s that should be started with the application.
156      */
getStartables()157     Map<Class<?>, Provider<CoreStartable>> getStartables();
158 
159     /**
160      * Returns {@link CoreStartable}s that should be started for every user.
161      */
getPerUserStartables()162     @PerUser Map<Class<?>, Provider<CoreStartable>> getPerUserStartables();
163 
164     /**
165      * Returns {@link CoreStartable} dependencies if there are any.
166      */
getStartableDependencies()167     @Dependencies Map<Class<?>, Set<Class<? extends CoreStartable>>> getStartableDependencies();
168 
169     /**
170      * Member injection into the supplied argument.
171      */
inject(SystemUIAppComponentFactoryBase factory)172     void inject(SystemUIAppComponentFactoryBase factory);
173 
174     /**
175      * Member injection into the supplied argument.
176      */
inject(KeyguardSliceProvider keyguardSliceProvider)177     void inject(KeyguardSliceProvider keyguardSliceProvider);
178 
179     /**
180      * Member injection into the supplied argument.
181      */
inject(PeopleProvider peopleProvider)182     void inject(PeopleProvider peopleProvider);
183 }
184