• 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 package com.android.systemui.statusbar.pipeline
18 
19 import android.content.Context
20 import com.android.systemui.dagger.SysUISingleton
21 import com.android.systemui.flags.FeatureFlags
22 import com.android.systemui.flags.Flags
23 import javax.inject.Inject
24 
25 /** All flagging methods related to the new status bar pipeline (see b/238425913). */
26 @SysUISingleton
27 class StatusBarPipelineFlags
28 @Inject
29 constructor(
30     context: Context,
31     private val featureFlags: FeatureFlags,
32 ) {
33     private val mobileSlot = context.getString(com.android.internal.R.string.status_bar_mobile)
34     private val wifiSlot = context.getString(com.android.internal.R.string.status_bar_wifi)
35 
36     /** True if we should display the mobile icons using the new status bar data pipeline. */
useNewMobileIconsnull37     fun useNewMobileIcons(): Boolean = featureFlags.isEnabled(Flags.NEW_STATUS_BAR_MOBILE_ICONS)
38 
39     /**
40      * True if we should run the new mobile icons backend to get the logging.
41      *
42      * Does *not* affect whether we render the mobile icons using the new backend data. See
43      * [useNewMobileIcons] for that.
44      */
45     fun runNewMobileIconsBackend(): Boolean =
46         featureFlags.isEnabled(Flags.NEW_STATUS_BAR_MOBILE_ICONS_BACKEND) || useNewMobileIcons()
47 
48     /** True if we should display the wifi icon using the new status bar data pipeline. */
49     fun useNewWifiIcon(): Boolean = featureFlags.isEnabled(Flags.NEW_STATUS_BAR_WIFI_ICON)
50 
51     /**
52      * True if we should run the new wifi icon backend to get the logging.
53      *
54      * Does *not* affect whether we render the wifi icon using the new backend data. See
55      * [useNewWifiIcon] for that.
56      */
57     fun runNewWifiIconBackend(): Boolean =
58         featureFlags.isEnabled(Flags.NEW_STATUS_BAR_WIFI_ICON_BACKEND) || useNewWifiIcon()
59 
60     /**
61      * Returns true if we should apply some coloring to the icons that were rendered with the new
62      * pipeline to help with debugging.
63      */
64     fun useDebugColoring(): Boolean =
65         featureFlags.isEnabled(Flags.NEW_STATUS_BAR_ICONS_DEBUG_COLORING)
66 
67     /**
68      * For convenience in the StatusBarIconController, we want to gate some actions based on slot
69      * name and the flag together.
70      *
71      * @return true if this icon is controlled by any of the status bar pipeline flags
72      */
73     fun isIconControlledByFlags(slotName: String): Boolean =
74         slotName == wifiSlot && useNewWifiIcon() || slotName == mobileSlot && useNewMobileIcons()
75 }
76