1 /*
2  * Copyright (C) 2023 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5  * except in compliance with the License. You may obtain a copy of the License at
6  *
7  *      http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software distributed under the
10  * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
11  * KIND, either express or implied. See the License for the specific language governing
12  * permissions and limitations under the License.
13  */
14 
15 package com.android.systemui.statusbar.phone.fragment
16 
17 import android.app.StatusBarManager.DISABLE2_NONE
18 import android.app.StatusBarManager.DISABLE2_SYSTEM_ICONS
19 import android.app.StatusBarManager.DISABLE_CLOCK
20 import android.app.StatusBarManager.DISABLE_NONE
21 import android.app.StatusBarManager.DISABLE_NOTIFICATION_ICONS
22 import android.app.StatusBarManager.DISABLE_ONGOING_CALL_CHIP
23 import android.app.StatusBarManager.DISABLE_SYSTEM_INFO
24 
25 /** A model for which parts of the status bar should be visible or not visible. */
26 data class StatusBarVisibilityModel(
27     val showClock: Boolean,
28     val showNotificationIcons: Boolean,
29     val showOngoingActivityChip: Boolean,
30     val showSystemInfo: Boolean,
31 ) {
32     companion object {
33         /** Creates the default model. */
34         @JvmStatic
createDefaultModelnull35         fun createDefaultModel(): StatusBarVisibilityModel {
36             return createModelFromFlags(DISABLE_NONE, DISABLE2_NONE)
37         }
38 
39         /**
40          * Given a set of disabled flags, converts them into the correct visibility statuses.
41          *
42          * See [CommandQueue.Callbacks.disable].
43          */
44         @JvmStatic
createModelFromFlagsnull45         fun createModelFromFlags(disabled1: Int, disabled2: Int): StatusBarVisibilityModel {
46             return StatusBarVisibilityModel(
47                 showClock = (disabled1 and DISABLE_CLOCK) == 0,
48                 showNotificationIcons = (disabled1 and DISABLE_NOTIFICATION_ICONS) == 0,
49                 // TODO(b/279899176): [CollapsedStatusBarFragment] always overwrites this with the
50                 //  value of [OngoingCallController]. Do we need to process the flag here?
51                 showOngoingActivityChip = (disabled1 and DISABLE_ONGOING_CALL_CHIP) == 0,
52                 showSystemInfo =
53                     (disabled1 and DISABLE_SYSTEM_INFO) == 0 &&
54                         (disabled2 and DISABLE2_SYSTEM_ICONS) == 0
55             )
56         }
57     }
58 }
59