• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
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 
18 package com.android.systemui.keyguard.data.repository
19 
20 import android.graphics.Point
21 import com.android.systemui.common.shared.model.Position
22 import com.android.systemui.keyguard.shared.model.BiometricUnlockModel
23 import com.android.systemui.keyguard.shared.model.BiometricUnlockSource
24 import com.android.systemui.keyguard.shared.model.DozeTransitionModel
25 import com.android.systemui.keyguard.shared.model.StatusBarState
26 import com.android.systemui.keyguard.shared.model.WakeSleepReason
27 import com.android.systemui.keyguard.shared.model.WakefulnessModel
28 import com.android.systemui.keyguard.shared.model.WakefulnessState
29 import kotlinx.coroutines.flow.Flow
30 import kotlinx.coroutines.flow.MutableStateFlow
31 import kotlinx.coroutines.flow.StateFlow
32 import kotlinx.coroutines.flow.asStateFlow
33 
34 /** Fake implementation of [KeyguardRepository] */
35 class FakeKeyguardRepository : KeyguardRepository {
36 
37     private val _animateBottomAreaDozingTransitions = MutableStateFlow(false)
38     override val animateBottomAreaDozingTransitions: StateFlow<Boolean> =
39         _animateBottomAreaDozingTransitions
40 
41     private val _bottomAreaAlpha = MutableStateFlow(1f)
42     override val bottomAreaAlpha: StateFlow<Float> = _bottomAreaAlpha
43 
44     private val _clockPosition = MutableStateFlow(Position(0, 0))
45     override val clockPosition: StateFlow<Position> = _clockPosition
46 
47     private val _isKeyguardShowing = MutableStateFlow(false)
48     override val isKeyguardShowing: Flow<Boolean> = _isKeyguardShowing
49 
50     private val _isKeyguardUnlocked = MutableStateFlow(false)
51     override val isKeyguardUnlocked: Flow<Boolean> = _isKeyguardUnlocked
52 
53     private val _isKeyguardOccluded = MutableStateFlow(false)
54     override val isKeyguardOccluded: Flow<Boolean> = _isKeyguardOccluded
55 
56     private val _isDozing = MutableStateFlow(false)
57     override val isDozing: Flow<Boolean> = _isDozing
58 
59     private val _isAodAvailable = MutableStateFlow(false)
60     override val isAodAvailable: Flow<Boolean> = _isAodAvailable
61 
62     private val _isDreaming = MutableStateFlow(false)
63     override val isDreaming: Flow<Boolean> = _isDreaming
64 
65     private val _isDreamingWithOverlay = MutableStateFlow(false)
66     override val isDreamingWithOverlay: Flow<Boolean> = _isDreamingWithOverlay
67 
68     private val _dozeAmount = MutableStateFlow(0f)
69     override val linearDozeAmount: Flow<Float> = _dozeAmount
70 
71     private val _statusBarState = MutableStateFlow(StatusBarState.SHADE)
72     override val statusBarState: Flow<StatusBarState> = _statusBarState
73 
74     private val _dozeTransitionModel = MutableStateFlow(DozeTransitionModel())
75     override val dozeTransitionModel: Flow<DozeTransitionModel> = _dozeTransitionModel
76 
77     private val _wakefulnessModel =
78         MutableStateFlow(
79             WakefulnessModel(
80                 WakefulnessState.ASLEEP,
81                 false,
82                 WakeSleepReason.OTHER,
83                 WakeSleepReason.OTHER
84             )
85         )
86     override val wakefulness: Flow<WakefulnessModel> = _wakefulnessModel
87 
88     private val _isUdfpsSupported = MutableStateFlow(false)
89 
90     private val _isKeyguardGoingAway = MutableStateFlow(false)
91     override val isKeyguardGoingAway: Flow<Boolean> = _isKeyguardGoingAway
92 
93     private val _biometricUnlockState = MutableStateFlow(BiometricUnlockModel.NONE)
94     override val biometricUnlockState: Flow<BiometricUnlockModel> = _biometricUnlockState
95 
96     private val _fingerprintSensorLocation = MutableStateFlow<Point?>(null)
97     override val fingerprintSensorLocation: Flow<Point?> = _fingerprintSensorLocation
98 
99     private val _faceSensorLocation = MutableStateFlow<Point?>(null)
100     override val faceSensorLocation: Flow<Point?> = _faceSensorLocation
101 
102     private val _biometricUnlockSource = MutableStateFlow<BiometricUnlockSource?>(null)
103     override val biometricUnlockSource: Flow<BiometricUnlockSource?> = _biometricUnlockSource
104 
105     private val _isQuickSettingsVisible = MutableStateFlow(false)
106     override val isQuickSettingsVisible: Flow<Boolean> = _isQuickSettingsVisible.asStateFlow()
107 
setQuickSettingsVisiblenull108     override fun setQuickSettingsVisible(isVisible: Boolean) {
109         _isQuickSettingsVisible.value = isVisible
110     }
111 
isKeyguardShowingnull112     override fun isKeyguardShowing(): Boolean {
113         return _isKeyguardShowing.value
114     }
115 
setAnimateDozingTransitionsnull116     override fun setAnimateDozingTransitions(animate: Boolean) {
117         _animateBottomAreaDozingTransitions.tryEmit(animate)
118     }
119 
setBottomAreaAlphanull120     override fun setBottomAreaAlpha(alpha: Float) {
121         _bottomAreaAlpha.value = alpha
122     }
123 
setClockPositionnull124     override fun setClockPosition(x: Int, y: Int) {
125         _clockPosition.value = Position(x, y)
126     }
127 
setKeyguardShowingnull128     fun setKeyguardShowing(isShowing: Boolean) {
129         _isKeyguardShowing.value = isShowing
130     }
131 
setKeyguardOccludednull132     fun setKeyguardOccluded(isOccluded: Boolean) {
133         _isKeyguardOccluded.value = isOccluded
134     }
135 
setDozingnull136     fun setDozing(isDozing: Boolean) {
137         _isDozing.value = isDozing
138     }
139 
setAodAvailablenull140     fun setAodAvailable(isAodAvailable: Boolean) {
141         _isAodAvailable.value = isAodAvailable
142     }
143 
setDreamingWithOverlaynull144     fun setDreamingWithOverlay(isDreaming: Boolean) {
145         _isDreamingWithOverlay.value = isDreaming
146     }
147 
setDozeAmountnull148     fun setDozeAmount(dozeAmount: Float) {
149         _dozeAmount.value = dozeAmount
150     }
151 
setWakefulnessModelnull152     fun setWakefulnessModel(model: WakefulnessModel) {
153         _wakefulnessModel.value = model
154     }
155 
setBiometricUnlockStatenull156     fun setBiometricUnlockState(state: BiometricUnlockModel) {
157         _biometricUnlockState.tryEmit(state)
158     }
159 
setBiometricUnlockSourcenull160     fun setBiometricUnlockSource(source: BiometricUnlockSource?) {
161         _biometricUnlockSource.tryEmit(source)
162     }
163 
setFaceSensorLocationnull164     fun setFaceSensorLocation(location: Point?) {
165         _faceSensorLocation.tryEmit(location)
166     }
167 
setFingerprintSensorLocationnull168     fun setFingerprintSensorLocation(location: Point?) {
169         _fingerprintSensorLocation.tryEmit(location)
170     }
171 
setDozeTransitionModelnull172     fun setDozeTransitionModel(model: DozeTransitionModel) {
173         _dozeTransitionModel.value = model
174     }
175 
setStatusBarStatenull176     fun setStatusBarState(state: StatusBarState) {
177         _statusBarState.value = state
178     }
179 
isUdfpsSupportednull180     override fun isUdfpsSupported(): Boolean {
181         return _isUdfpsSupported.value
182     }
183 }
184