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 package com.android.systemui.statusbar.phone.domain.interactor
17 
18 import com.android.systemui.dagger.SysUISingleton
19 import com.android.systemui.statusbar.data.model.StatusBarMode
20 import com.android.systemui.statusbar.data.repository.StatusBarModeRepositoryStore
21 import javax.inject.Inject
22 import kotlinx.coroutines.flow.Flow
23 import kotlinx.coroutines.flow.map
24 
25 /**
26  * Apps can request a low profile mode [android.view.View.SYSTEM_UI_FLAG_LOW_PROFILE] where status
27  * bar and navigation icons dim. In this mode, a notification dot appears where the notification
28  * icons would appear if they would be shown outside of this mode.
29  *
30  * This interactor knows whether the device is in [android.view.View.SYSTEM_UI_FLAG_LOW_PROFILE].
31  */
32 @SysUISingleton
33 class LightsOutInteractor
34 @Inject
35 constructor(private val repository: StatusBarModeRepositoryStore) {
36 
isLowProfilenull37     fun isLowProfile(displayId: Int): Flow<Boolean> =
38         repository.forDisplay(displayId).statusBarMode.map {
39             when (it) {
40                 StatusBarMode.LIGHTS_OUT,
41                 StatusBarMode.LIGHTS_OUT_TRANSPARENT -> true
42                 else -> false
43             }
44         }
45 }
46