1 /*
2  * Copyright (C) 2023 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.scene.ui.view
18 
19 import dagger.Subcomponent
20 
21 /**
22  * A component providing access to [WindowRootView].
23  *
24  * Injecting [WindowRootView] directly into controllers can lead to crash loops. This is because
25  * [WindowRootView] contains [NotificationStackScrollLayout] and that view accesses [Dependency.get]
26  * in its constructor. If [Dependency.get] is not set up when your controller is constructed (which
27  * is possible because there are no guarantees from Dagger about the order of construction), then
28  * trying to inflate [NotificationStackScrollLayout] will crash. This component provides a way to
29  * fetch [WindowRootView] after the full Dagger graph is set up, which ensures that the inflation
30  * won't fail.
31  *
32  * This component is intended to be *temporary* and *only used from [CentralSurfacesImpl]*. Once
33  * [Dependency.get] is removed from [NotificationStackScrollLayout], we should re-attempt injecting
34  * [WindowRootView] directly into its controller [NotificationShadeWindowController].
35  */
36 @Subcomponent
37 interface WindowRootViewComponent {
38 
39     @Subcomponent.Factory
40     interface Factory {
createnull41         fun create(): WindowRootViewComponent
42     }
43 
44     /** Fetches the root view of the main SysUI window. */
45     fun getWindowRootView(): WindowRootView
46 }
47