1 /*
2  * 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.shade.domain.interactor
18 
19 import com.android.keyguard.LockIconViewController
20 import com.android.systemui.dagger.qualifiers.Background
21 import com.android.systemui.dagger.qualifiers.Main
22 import com.android.systemui.scene.domain.interactor.SceneInteractor
23 import com.android.systemui.scene.shared.model.SceneFamilies
24 import com.android.systemui.scene.shared.model.Scenes
25 import com.android.systemui.shade.data.repository.ShadeRepository
26 import javax.inject.Inject
27 import kotlinx.coroutines.CoroutineDispatcher
28 import kotlinx.coroutines.CoroutineScope
29 import kotlinx.coroutines.delay
30 import kotlinx.coroutines.launch
31 import kotlinx.coroutines.withContext
32 
33 class ShadeLockscreenInteractorImpl
34 @Inject
35 constructor(
36     @Main private val mainDispatcher: CoroutineDispatcher,
37     @Background private val backgroundScope: CoroutineScope,
38     private val shadeInteractor: ShadeInteractor,
39     private val sceneInteractor: SceneInteractor,
40     private val lockIconViewController: LockIconViewController,
41     shadeRepository: ShadeRepository,
42 ) : ShadeLockscreenInteractor {
43 
44     override val udfpsTransitionToFullShadeProgress =
45         shadeRepository.udfpsTransitionToFullShadeProgress
46 
expandToNotificationsnull47     override fun expandToNotifications() {
48         changeToShadeScene()
49     }
50 
51     override val isExpanded
52         get() = shadeInteractor.isAnyExpanded.value
53 
startBouncerPreHideAnimationnull54     override fun startBouncerPreHideAnimation() {
55         // TODO("b/324280998") Implement replacement or delete
56     }
57 
dozeTimeTicknull58     override fun dozeTimeTick() {
59         lockIconViewController.dozeTimeTick()
60     }
61 
blockExpansionForCurrentTouchnull62     override fun blockExpansionForCurrentTouch() {
63         // TODO("b/324280998") Implement replacement or delete
64     }
65 
resetViewsnull66     override fun resetViews(animate: Boolean) {
67         // The existing comment to the only call to this claims it only calls it to collapse QS
68         changeToShadeScene()
69     }
70 
setPulsingnull71     override fun setPulsing(pulsing: Boolean) {
72         // Now handled elsewhere. Do nothing.
73     }
74 
transitionToExpandedShadenull75     override fun transitionToExpandedShade(delay: Long) {
76         backgroundScope.launch {
77             delay(delay)
78             withContext(mainDispatcher) { changeToShadeScene() }
79         }
80     }
81 
resetViewGroupFadenull82     override fun resetViewGroupFade() {
83         // Now handled elsewhere. Do nothing.
84     }
85 
setKeyguardTransitionProgressnull86     override fun setKeyguardTransitionProgress(keyguardAlpha: Float, keyguardTranslationY: Int) {
87         // Now handled elsewhere. Do nothing.
88     }
89 
setOverStretchAmountnull90     override fun setOverStretchAmount(amount: Float) {
91         // Now handled elsewhere. Do nothing.
92     }
93 
setKeyguardStatusBarAlphanull94     override fun setKeyguardStatusBarAlpha(alpha: Float) {
95         // TODO(b/325072511) delete this
96     }
97 
showAodUinull98     override fun showAodUi() {
99         sceneInteractor.changeScene(Scenes.Lockscreen, "showAodUi")
100         // TODO(b/330311871) implement transition to AOD
101     }
102 
changeToShadeScenenull103     private fun changeToShadeScene() {
104         sceneInteractor.changeScene(
105             SceneFamilies.NotifShade,
106             "ShadeLockscreenInteractorImpl.expandToNotifications",
107         )
108     }
109 }
110