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 */ 39 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 ): UnfoldSharedComponent = 52 DaggerUnfoldSharedComponent.factory() 53 .create( 54 context, 55 config, 56 screenStatusProvider, 57 foldProvider, 58 activityTypeProvider, 59 sensorManager, 60 mainHandler, 61 mainExecutor, 62 singleThreadBgExecutor, 63 tracingTagPrefix, 64 displayManager, 65 ) 66 67 /** 68 * Factory for [RemoteUnfoldSharedComponent]. 69 * 70 * Wraps [DaggerRemoteUnfoldSharedComponent] (that is autogenerated), for better discoverability. 71 */ 72 fun createRemoteUnfoldSharedComponent( 73 context: Context, 74 config: UnfoldTransitionConfig, 75 mainExecutor: Executor, 76 mainHandler: Handler, 77 singleThreadBgExecutor: Executor, 78 tracingTagPrefix: String, 79 displayManager: DisplayManager, 80 ): RemoteUnfoldSharedComponent = 81 DaggerRemoteUnfoldSharedComponent.factory() 82 .create( 83 context, 84 config, 85 mainExecutor, 86 mainHandler, 87 singleThreadBgExecutor, 88 displayManager, 89 tracingTagPrefix, 90 ) 91