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.shade.data.repository 19 20 import com.android.systemui.dagger.SysUISingleton 21 import com.android.systemui.shade.shared.model.ShadeMode 22 import dagger.Binds 23 import dagger.Module 24 import javax.inject.Inject 25 import kotlinx.coroutines.flow.MutableStateFlow 26 import kotlinx.coroutines.flow.StateFlow 27 import kotlinx.coroutines.flow.asStateFlow 28 29 /** Fake implementation of [ShadeRepository] */ 30 @SysUISingleton 31 class FakeShadeRepository @Inject constructor() : ShadeRepository { 32 private val _qsExpansion = MutableStateFlow(0f) 33 override val qsExpansion = _qsExpansion 34 35 private val _udfpsTransitionToFullShadeProgress = MutableStateFlow(0f) 36 override val udfpsTransitionToFullShadeProgress = _udfpsTransitionToFullShadeProgress 37 38 private val _currentFling: MutableStateFlow<FlingInfo?> = MutableStateFlow(null) 39 override val currentFling: StateFlow<FlingInfo?> = _currentFling 40 41 private val _lockscreenShadeExpansion = MutableStateFlow(0f) 42 override val lockscreenShadeExpansion = _lockscreenShadeExpansion 43 44 private val _legacyShadeExpansion = MutableStateFlow(0f) 45 @Deprecated("Use ShadeInteractor instead") 46 override val legacyShadeExpansion = _legacyShadeExpansion 47 48 private val _legacyShadeTracking = MutableStateFlow(false) 49 @Deprecated("Use ShadeInteractor instead") 50 override val legacyShadeTracking = _legacyShadeTracking 51 52 private val _legacyQsTracking = MutableStateFlow(false) 53 @Deprecated("Use ShadeInteractor instead") override val legacyQsTracking = _legacyQsTracking 54 55 private val _legacyExpandedOrAwaitingInputTransfer = MutableStateFlow(false) 56 @Deprecated("Use ShadeInteractor instead") 57 override val legacyExpandedOrAwaitingInputTransfer = _legacyExpandedOrAwaitingInputTransfer 58 59 private val _legacyIsQsExpanded = MutableStateFlow(false) 60 @Deprecated("Use ShadeInteractor instead") override val legacyIsQsExpanded = _legacyIsQsExpanded 61 62 override val legacyLockscreenShadeTracking = MutableStateFlow(false) 63 64 private val _shadeMode = MutableStateFlow<ShadeMode>(ShadeMode.Single) 65 override val shadeMode: StateFlow<ShadeMode> = _shadeMode.asStateFlow() 66 67 @Deprecated("Use ShadeInteractor instead") setLegacyIsQsExpandednull68 override fun setLegacyIsQsExpanded(legacyIsQsExpanded: Boolean) { 69 _legacyIsQsExpanded.value = legacyIsQsExpanded 70 } 71 72 private val _legacyExpandImmediate = MutableStateFlow(false) 73 @Deprecated("Use ShadeInteractor instead") 74 override val legacyExpandImmediate = _legacyExpandImmediate 75 76 @Deprecated("Use ShadeInteractor instead") setLegacyExpandImmediatenull77 override fun setLegacyExpandImmediate(legacyExpandImmediate: Boolean) { 78 _legacyExpandImmediate.value = legacyExpandImmediate 79 } 80 81 @Deprecated("Use ShadeInteractor instead") setLegacyExpandedOrAwaitingInputTransfernull82 override fun setLegacyExpandedOrAwaitingInputTransfer( 83 legacyExpandedOrAwaitingInputTransfer: Boolean 84 ) { 85 _legacyExpandedOrAwaitingInputTransfer.value = legacyExpandedOrAwaitingInputTransfer 86 } 87 88 @Deprecated("Should only be called by NPVC and tests") setLegacyQsTrackingnull89 override fun setLegacyQsTracking(legacyQsTracking: Boolean) { 90 _legacyQsTracking.value = legacyQsTracking 91 } 92 93 @Deprecated("Should only be called by NPVC and tests") setLegacyShadeTrackingnull94 override fun setLegacyShadeTracking(tracking: Boolean) { 95 _legacyShadeTracking.value = tracking 96 } 97 98 @Deprecated("Should only be called by NPVC and tests") setLegacyLockscreenShadeTrackingnull99 override fun setLegacyLockscreenShadeTracking(tracking: Boolean) { 100 legacyLockscreenShadeTracking.value = tracking 101 } 102 103 private val _legacyQsFullscreen = MutableStateFlow(false) 104 @Deprecated("Use ShadeInteractor instead") override val legacyQsFullscreen = _legacyQsFullscreen 105 106 @Deprecated("Use ShadeInteractor instead") setLegacyQsFullscreennull107 override fun setLegacyQsFullscreen(legacyQsFullscreen: Boolean) { 108 _legacyQsFullscreen.value = legacyQsFullscreen 109 } 110 111 private val _legacyIsClosing = MutableStateFlow(false) 112 @Deprecated("Use ShadeInteractor instead") override val legacyIsClosing = _legacyIsClosing 113 114 @Deprecated("Use ShadeInteractor instead") setLegacyIsClosingnull115 override fun setLegacyIsClosing(isClosing: Boolean) { 116 _legacyIsClosing.value = isClosing 117 } 118 setQsExpansionnull119 override fun setQsExpansion(qsExpansion: Float) { 120 _qsExpansion.value = qsExpansion 121 } 122 setUdfpsTransitionToFullShadeProgressnull123 override fun setUdfpsTransitionToFullShadeProgress(progress: Float) { 124 _udfpsTransitionToFullShadeProgress.value = progress 125 } 126 setCurrentFlingnull127 override fun setCurrentFling(info: FlingInfo?) { 128 _currentFling.value = info 129 } 130 setLockscreenShadeExpansionnull131 override fun setLockscreenShadeExpansion(lockscreenShadeExpansion: Float) { 132 _lockscreenShadeExpansion.value = lockscreenShadeExpansion 133 } 134 135 @Deprecated("Should only be called by NPVC and tests") setLegacyShadeExpansionnull136 override fun setLegacyShadeExpansion(expandedFraction: Float) { 137 _legacyShadeExpansion.value = expandedFraction 138 } 139 setShadeModenull140 override fun setShadeMode(shadeMode: ShadeMode) { 141 _shadeMode.value = shadeMode 142 } 143 } 144 145 @Module 146 interface FakeShadeRepositoryModule { bindFakenull147 @Binds fun bindFake(fake: FakeShadeRepository): ShadeRepository 148 } 149