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 android.os.HandlerThread;
20 
21 import androidx.annotation.Nullable;
22 
23 import com.android.systemui.SystemUIInitializer;
24 import com.android.systemui.tv.TvWMComponent;
25 import com.android.wm.shell.back.BackAnimation;
26 import com.android.wm.shell.bubbles.Bubbles;
27 import com.android.wm.shell.common.annotations.ShellMainThread;
28 import com.android.wm.shell.dagger.TvWMShellModule;
29 import com.android.wm.shell.dagger.WMShellModule;
30 import com.android.wm.shell.dagger.WMSingleton;
31 import com.android.wm.shell.desktopmode.DesktopMode;
32 import com.android.wm.shell.displayareahelper.DisplayAreaHelper;
33 import com.android.wm.shell.keyguard.KeyguardTransitions;
34 import com.android.wm.shell.onehanded.OneHanded;
35 import com.android.wm.shell.pip.Pip;
36 import com.android.wm.shell.recents.RecentTasks;
37 import com.android.wm.shell.splitscreen.SplitScreen;
38 import com.android.wm.shell.startingsurface.StartingSurface;
39 import com.android.wm.shell.sysui.ShellInterface;
40 import com.android.wm.shell.taskview.TaskViewFactory;
41 import com.android.wm.shell.transition.ShellTransitions;
42 
43 import dagger.BindsInstance;
44 import dagger.Subcomponent;
45 
46 import java.util.Optional;
47 
48 /**
49  * Dagger Subcomponent for WindowManager.  This class explicitly describes the interfaces exported
50  * from the WM component into the SysUI component (in
51  * {@link SystemUIInitializer#init(boolean)}), and references the specific dependencies
52  * provided by its particular device/form-factor SystemUI implementation.
53  *
54  * ie. {@link WMComponent} includes {@link WMShellModule}
55  *     and {@link TvWMComponent} includes {@link TvWMShellModule}
56  */
57 @WMSingleton
58 @Subcomponent(modules = {WMShellModule.class})
59 public interface WMComponent {
60 
61     /**
62      * Builder for a WMComponent.
63      */
64     @Subcomponent.Builder
65     interface Builder {
66 
67         @BindsInstance
setShellMainThread(@ullable @hellMainThread HandlerThread t)68         Builder setShellMainThread(@Nullable @ShellMainThread HandlerThread t);
69 
build()70         WMComponent build();
71     }
72 
73     /**
74      * Initializes all the WMShell components before starting any of the SystemUI components.
75      */
init()76     default void init() {
77         getShell().onInit();
78     }
79 
80     @WMSingleton
getShell()81     ShellInterface getShell();
82 
83     @WMSingleton
getOneHanded()84     Optional<OneHanded> getOneHanded();
85 
86     @WMSingleton
getPip()87     Optional<Pip> getPip();
88 
89     @WMSingleton
getSplitScreen()90     Optional<SplitScreen> getSplitScreen();
91 
92     @WMSingleton
getBubbles()93     Optional<Bubbles> getBubbles();
94 
95     @WMSingleton
getTaskViewFactory()96     Optional<TaskViewFactory> getTaskViewFactory();
97 
98     @WMSingleton
getTransitions()99     ShellTransitions getTransitions();
100 
101     @WMSingleton
getKeyguardTransitions()102     KeyguardTransitions getKeyguardTransitions();
103 
104     @WMSingleton
getStartingSurface()105     Optional<StartingSurface> getStartingSurface();
106 
107     @WMSingleton
getDisplayAreaHelper()108     Optional<DisplayAreaHelper> getDisplayAreaHelper();
109 
110     @WMSingleton
getRecentTasks()111     Optional<RecentTasks> getRecentTasks();
112 
113     @WMSingleton
getBackAnimation()114     Optional<BackAnimation> getBackAnimation();
115 
116     /**
117      * Optional {@link DesktopMode} component for interacting with desktop mode.
118      */
119     @WMSingleton
getDesktopMode()120     Optional<DesktopMode> getDesktopMode();
121 }
122