• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
<lambda>null2  * 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.statusbar.pipeline.shared.domain.interactor
18 
19 import com.android.systemui.dagger.SysUISingleton
20 import com.android.systemui.statusbar.disableflags.domain.interactor.DisableFlagsInteractor
21 import com.android.systemui.statusbar.pipeline.airplane.domain.interactor.AirplaneModeInteractor
22 import com.android.systemui.statusbar.pipeline.mobile.domain.interactor.CarrierConfigInteractor
23 import com.android.systemui.statusbar.pipeline.shared.domain.model.StatusBarDisableFlagsVisibilityModel
24 import javax.inject.Inject
25 import kotlinx.coroutines.flow.Flow
26 import kotlinx.coroutines.flow.combine
27 import kotlinx.coroutines.flow.flatMapLatest
28 import kotlinx.coroutines.flow.flowOf
29 import kotlinx.coroutines.flow.map
30 
31 /**
32  * Interactor for the home screen status bar (aka
33  * [com.android.systemui.statusbar.phone.fragment.CollapsedStatusBarFragment]).
34  */
35 @SysUISingleton
36 class HomeStatusBarInteractor
37 @Inject
38 constructor(
39     airplaneModeInteractor: AirplaneModeInteractor,
40     carrierConfigInteractor: CarrierConfigInteractor,
41     disableFlagsInteractor: DisableFlagsInteractor,
42 ) {
43     /**
44      * The visibilities of various status bar child views, based only on the information we received
45      * from disable flags.
46      */
47     val visibilityViaDisableFlags: Flow<StatusBarDisableFlagsVisibilityModel> =
48         disableFlagsInteractor.disableFlags.map {
49             StatusBarDisableFlagsVisibilityModel(
50                 isClockAllowed = it.isClockEnabled,
51                 areNotificationIconsAllowed = it.areNotificationIconsEnabled,
52                 isSystemInfoAllowed = it.isSystemInfoEnabled,
53                 animate = it.animate,
54             )
55         }
56 
57     private val defaultDataSubConfigShowOperatorView =
58         carrierConfigInteractor.defaultDataSubscriptionCarrierConfig.flatMapLatest {
59             it?.showOperatorNameInStatusBar ?: flowOf(false)
60         }
61 
62     /**
63      * True if the carrier config for the default data subscription has
64      * [SystemUiCarrierConfig.showOperatorNameInStatusBar] set and the device is not in airplane
65      * mode
66      */
67     val shouldShowOperatorName: Flow<Boolean> =
68         combine(defaultDataSubConfigShowOperatorView, airplaneModeInteractor.isAirplaneMode) {
69             showOperatorName,
70             isAirplaneMode ->
71             showOperatorName && !isAirplaneMode
72         }
73 }
74