1 /* <lambda>null2 * Copyright (C) 2024 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.unfold 18 19 import com.android.systemui.CoreStartable 20 import com.android.systemui.Flags 21 import com.android.systemui.unfold.dagger.UnfoldBg 22 import com.android.systemui.unfold.progress.UnfoldTransitionProgressForwarder 23 import java.util.Optional 24 import javax.inject.Inject 25 26 class UnfoldInitializationStartable 27 @Inject 28 constructor( 29 private val unfoldComponentOptional: Optional<SysUIUnfoldComponent>, 30 private val foldStateLoggingProviderOptional: Optional<FoldStateLoggingProvider>, 31 private val foldStateLoggerOptional: Optional<FoldStateLogger>, 32 @UnfoldBg 33 private val unfoldBgTransitionProgressProviderOptional: 34 Optional<UnfoldTransitionProgressProvider>, 35 private val unfoldTransitionProgressProviderOptional: 36 Optional<UnfoldTransitionProgressProvider>, 37 private val unfoldTransitionProgressForwarder: Optional<UnfoldTransitionProgressForwarder> 38 ) : CoreStartable { 39 override fun start() { 40 unfoldComponentOptional.ifPresent { c: SysUIUnfoldComponent -> 41 c.getFullScreenLightRevealAnimations().forEach { it: FullscreenLightRevealAnimation -> 42 it.init() 43 } 44 c.getUnfoldTransitionWallpaperController().init() 45 c.getUnfoldHapticsPlayer() 46 c.getNaturalRotationUnfoldProgressProvider().init() 47 c.getUnfoldLatencyTracker().init() 48 } 49 50 foldStateLoggingProviderOptional.ifPresent { obj: FoldStateLoggingProvider -> obj.init() } 51 foldStateLoggerOptional.ifPresent { obj: FoldStateLogger -> obj.init() } 52 53 val unfoldTransitionProgressProvider: Optional<UnfoldTransitionProgressProvider> = 54 if (Flags.unfoldAnimationBackgroundProgress()) { 55 unfoldBgTransitionProgressProviderOptional 56 } else { 57 unfoldTransitionProgressProviderOptional 58 } 59 unfoldTransitionProgressProvider.ifPresent { 60 progressProvider: UnfoldTransitionProgressProvider -> 61 unfoldTransitionProgressForwarder.ifPresent { 62 listener: UnfoldTransitionProgressForwarder -> 63 progressProvider.addCallback(listener) 64 } 65 } 66 } 67 } 68