1 /*
2  * Copyright (C) 2022 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 distributed under the
11  * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
12  * KIND, either express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 package com.android.systemui.unfold.system
16 
17 import android.os.Handler
18 import com.android.systemui.dagger.qualifiers.Main
19 import com.android.systemui.dagger.qualifiers.UiBackground
20 import com.android.systemui.unfold.config.ResourceUnfoldTransitionConfig
21 import com.android.systemui.unfold.config.UnfoldTransitionConfig
22 import com.android.systemui.unfold.dagger.UnfoldSingleThreadBg
23 import com.android.systemui.unfold.dagger.UnfoldMain
24 import com.android.systemui.unfold.updates.FoldProvider
25 import com.android.systemui.unfold.util.CurrentActivityTypeProvider
26 import dagger.Binds
27 import dagger.Module
28 import java.util.concurrent.Executor
29 
30 /**
31  * Dagger module with system-only dependencies for the unfold animation.
32  * The code that is used to calculate unfold transition progress
33  * depends on some hidden APIs that are not available in normal
34  * apps. In order to re-use this code and use alternative implementations
35  * of these classes in other apps and hidden APIs here.
36  */
37 @Module
38 abstract class SystemUnfoldSharedModule {
39 
40     @Binds
41     abstract fun activityTypeProvider(executor: ActivityManagerActivityTypeProvider):
42             CurrentActivityTypeProvider
43 
44     @Binds
45     abstract fun config(config: ResourceUnfoldTransitionConfig): UnfoldTransitionConfig
46 
47     @Binds
48     abstract fun foldState(provider: DeviceStateManagerFoldProvider): FoldProvider
49 
50     @Binds
51     @UnfoldMain
52     abstract fun mainExecutor(@Main executor: Executor): Executor
53 
54     @Binds
55     @UnfoldMain
56     abstract fun mainHandler(@Main handler: Handler): Handler
57 
58     @Binds
59     @UnfoldSingleThreadBg
60     abstract fun backgroundExecutor(@UiBackground executor: Executor): Executor
61 }
62