1 /*
<lambda>null2  * Copyright 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.model
18 
19 import com.android.systemui.dagger.qualifiers.DisplayId
20 
21 /**
22  * In-bulk updates multiple flag values and commits the update.
23  *
24  * Example:
25  * ```
26  * sysuiState.updateFlags(
27  *     displayId,
28  *     SYSUI_STATE_NOTIFICATION_PANEL_VISIBLE to (sceneKey != Scenes.Gone),
29  *     SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED to (sceneKey == Scenes.Shade),
30  *     SYSUI_STATE_QUICK_SETTINGS_EXPANDED to (sceneKey == Scenes.QuickSettings),
31  *     SYSUI_STATE_BOUNCER_SHOWING to (sceneKey == Scenes.Bouncer),
32  *     SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING to (sceneKey == Scenes.Lockscreen),
33  * )
34  * ```
35  *
36  * You can inject [displayId] by injecting it using:
37  * ```
38  *     @DisplayId private val displayId: Int`,
39  * ```
40  */
41 fun SysUiState.updateFlags(
42     @DisplayId displayId: Int,
43     vararg flagValuePairs: Pair<Long, Boolean>,
44 ) {
45     flagValuePairs.forEach { (flag, enabled) -> setFlag(flag, enabled) }
46     commitUpdate(displayId)
47 }
48