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 @file:JvmName("UnfoldTransitionFactory")
17
18 package com.android.systemui.unfold
19
20 import android.content.Context
21 import android.hardware.SensorManager
22 import android.hardware.display.DisplayManager
23 import android.os.Handler
24 import com.android.systemui.unfold.config.UnfoldTransitionConfig
25 import com.android.systemui.unfold.updates.FoldProvider
26 import com.android.systemui.unfold.updates.screen.ScreenStatusProvider
27 import com.android.systemui.unfold.util.CurrentActivityTypeProvider
28 import java.util.concurrent.Executor
29
30 /**
31 * Factory for [UnfoldSharedComponent].
32 *
33 * This wraps the autogenerated factory (for discoverability), and is needed as Launcher has to
34 * create the object manually. If dagger is available, this object is provided in
35 * [UnfoldSharedModule].
36 *
37 * This should **never** be called from sysui, as the object is already provided in that process.
38 */
createUnfoldSharedComponentnull39 fun createUnfoldSharedComponent(
40 context: Context,
41 config: UnfoldTransitionConfig,
42 screenStatusProvider: ScreenStatusProvider,
43 foldProvider: FoldProvider,
44 activityTypeProvider: CurrentActivityTypeProvider,
45 sensorManager: SensorManager,
46 mainHandler: Handler,
47 mainExecutor: Executor,
48 singleThreadBgExecutor: Executor,
49 tracingTagPrefix: String,
50 displayManager: DisplayManager,
51 bgHandler: Handler,
52 ): UnfoldSharedComponent =
53 DaggerUnfoldSharedComponent.factory()
54 .create(
55 context,
56 config,
57 screenStatusProvider,
58 foldProvider,
59 activityTypeProvider,
60 sensorManager,
61 mainHandler,
62 mainExecutor,
63 singleThreadBgExecutor,
64 tracingTagPrefix,
65 displayManager,
66 bgHandler,
67 )
68
69 /**
70 * Factory for [RemoteUnfoldSharedComponent].
71 *
72 * Wraps [DaggerRemoteUnfoldSharedComponent] (that is autogenerated), for better discoverability.
73 */
74 fun createRemoteUnfoldSharedComponent(
75 context: Context,
76 config: UnfoldTransitionConfig,
77 mainExecutor: Executor,
78 mainHandler: Handler,
79 singleThreadBgExecutor: Executor,
80 bgHandler: Handler,
81 tracingTagPrefix: String,
82 displayManager: DisplayManager,
83 ): RemoteUnfoldSharedComponent =
84 DaggerRemoteUnfoldSharedComponent.factory()
85 .create(
86 context,
87 config,
88 mainExecutor,
89 mainHandler,
90 singleThreadBgExecutor,
91 bgHandler,
92 displayManager,
93 tracingTagPrefix,
94 )
95