1 /*
2  * Copyright (C) 2023 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.statusbar.data.repository
18 
19 import android.view.Display
20 import com.android.systemui.dagger.SysUISingleton
21 import com.android.systemui.statusbar.data.model.StatusBarAppearance
22 import com.android.systemui.statusbar.data.model.StatusBarMode
23 import com.google.common.truth.Truth.assertThat
24 import dagger.Binds
25 import dagger.Module
26 import javax.inject.Inject
27 import kotlinx.coroutines.flow.MutableStateFlow
28 
29 @SysUISingleton
30 class FakeStatusBarModeRepository @Inject constructor() : StatusBarModeRepositoryStore {
31 
32     companion object {
33         const val DISPLAY_ID = Display.DEFAULT_DISPLAY
34     }
35 
36     override val defaultDisplay: FakeStatusBarModePerDisplayRepository =
37         FakeStatusBarModePerDisplayRepository()
38 
forDisplaynull39     override fun forDisplay(displayId: Int): FakeStatusBarModePerDisplayRepository {
40         assertThat(displayId).isEqualTo(DISPLAY_ID)
41         return defaultDisplay
42     }
43 }
44 
45 class FakeStatusBarModePerDisplayRepository : StatusBarModePerDisplayRepository {
46     override val isTransientShown = MutableStateFlow(false)
47     override val isInFullscreenMode = MutableStateFlow(false)
48     override val statusBarAppearance = MutableStateFlow<StatusBarAppearance?>(null)
49     override val statusBarMode = MutableStateFlow(StatusBarMode.TRANSPARENT)
50 
showTransientnull51     override fun showTransient() {
52         isTransientShown.value = true
53     }
clearTransientnull54     override fun clearTransient() {
55         isTransientShown.value = false
56     }
57 }
58 
59 @Module
60 interface FakeStatusBarModeRepositoryModule {
bindFakenull61     @Binds fun bindFake(fake: FakeStatusBarModeRepository): StatusBarModeRepositoryStore
62 }
63