1 /*
2  * Copyright (C) 2021 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.wm.shell.dagger;
18 
19 import android.content.Context;
20 import android.os.Handler;
21 
22 import com.android.launcher3.icons.IconProvider;
23 import com.android.wm.shell.RootTaskDisplayAreaOrganizer;
24 import com.android.wm.shell.ShellTaskOrganizer;
25 import com.android.wm.shell.common.DisplayController;
26 import com.android.wm.shell.common.DisplayImeController;
27 import com.android.wm.shell.common.DisplayInsetsController;
28 import com.android.wm.shell.common.LaunchAdjacentController;
29 import com.android.wm.shell.common.ShellExecutor;
30 import com.android.wm.shell.common.SyncTransactionQueue;
31 import com.android.wm.shell.common.SystemWindows;
32 import com.android.wm.shell.common.TransactionPool;
33 import com.android.wm.shell.common.annotations.ShellMainThread;
34 import com.android.wm.shell.dagger.pip.TvPipModule;
35 import com.android.wm.shell.draganddrop.DragAndDropController;
36 import com.android.wm.shell.recents.RecentTasksController;
37 import com.android.wm.shell.splitscreen.SplitScreenController;
38 import com.android.wm.shell.splitscreen.tv.TvSplitScreenController;
39 import com.android.wm.shell.startingsurface.StartingWindowTypeAlgorithm;
40 import com.android.wm.shell.startingsurface.tv.TvStartingWindowTypeAlgorithm;
41 import com.android.wm.shell.sysui.ShellCommandHandler;
42 import com.android.wm.shell.sysui.ShellController;
43 import com.android.wm.shell.sysui.ShellInit;
44 import com.android.wm.shell.transition.Transitions;
45 
46 import dagger.Module;
47 import dagger.Provides;
48 
49 import java.util.Optional;
50 
51 /**
52  * Provides dependencies from {@link com.android.wm.shell}, these dependencies are only
53  * accessible from components within the WM subcomponent (can be explicitly exposed to the
54  * SysUIComponent, see {@link WMComponent}).
55  *
56  * This module only defines Shell dependencies for the TV SystemUI implementation.  Common
57  * dependencies should go into {@link WMShellBaseModule}.
58  */
59 @Module(includes = {TvPipModule.class})
60 public class TvWMShellModule {
61 
62     //
63     // Starting Windows (Splash Screen)
64     //
65 
66     @WMSingleton
67     @Provides
68     @DynamicOverride
provideStartingWindowTypeAlgorithm()69     static StartingWindowTypeAlgorithm provideStartingWindowTypeAlgorithm() {
70         return new TvStartingWindowTypeAlgorithm();
71     }
72 
73     @WMSingleton
74     @Provides
75     @DynamicOverride
provideSplitScreenController(Context context, ShellInit shellInit, ShellCommandHandler shellCommandHandler, ShellController shellController, ShellTaskOrganizer shellTaskOrganizer, SyncTransactionQueue syncQueue, RootTaskDisplayAreaOrganizer rootTDAOrganizer, DisplayController displayController, DisplayImeController displayImeController, DisplayInsetsController displayInsetsController, Optional<DragAndDropController> dragAndDropController, Transitions transitions, TransactionPool transactionPool, IconProvider iconProvider, Optional<RecentTasksController> recentTasks, LaunchAdjacentController launchAdjacentController, @ShellMainThread ShellExecutor mainExecutor, Handler mainHandler, SystemWindows systemWindows)76     static SplitScreenController provideSplitScreenController(Context context,
77             ShellInit shellInit,
78             ShellCommandHandler shellCommandHandler,
79             ShellController shellController,
80             ShellTaskOrganizer shellTaskOrganizer,
81             SyncTransactionQueue syncQueue,
82             RootTaskDisplayAreaOrganizer rootTDAOrganizer,
83             DisplayController displayController,
84             DisplayImeController displayImeController,
85             DisplayInsetsController displayInsetsController,
86             Optional<DragAndDropController> dragAndDropController,
87             Transitions transitions,
88             TransactionPool transactionPool,
89             IconProvider iconProvider,
90             Optional<RecentTasksController> recentTasks,
91             LaunchAdjacentController launchAdjacentController,
92             @ShellMainThread ShellExecutor mainExecutor,
93             Handler mainHandler,
94             SystemWindows systemWindows) {
95         return new TvSplitScreenController(context, shellInit, shellCommandHandler, shellController,
96                 shellTaskOrganizer, syncQueue, rootTDAOrganizer, displayController,
97                 displayImeController, displayInsetsController, dragAndDropController, transitions,
98                 transactionPool, iconProvider, recentTasks, launchAdjacentController, mainExecutor,
99                 mainHandler, systemWindows);
100     }
101 }
102