1 /* 2 * Copyright (C) 2025 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.communal.data.model 18 19 sealed interface SuppressionReason { 20 @CommunalFeature val suppressedFeatures: Int 21 22 /** Whether this reason suppresses a particular feature. */ isSuppressednull23 fun isSuppressed(@CommunalFeature feature: Int): Boolean { 24 return (suppressedFeatures and feature) != 0 25 } 26 27 /** Suppress hub automatically opening due to Android Auto projection */ 28 data object ReasonCarProjection : SuppressionReason { 29 override val suppressedFeatures: Int = FEATURE_AUTO_OPEN 30 } 31 32 /** Suppress hub due to the "When to dream" conditions not being met */ 33 data class ReasonWhenToAutoShow(override val suppressedFeatures: Int) : SuppressionReason 34 35 /** Suppress hub due to device policy */ 36 data object ReasonDevicePolicy : SuppressionReason { 37 override val suppressedFeatures: Int = FEATURE_ALL 38 } 39 40 /** Suppress hub due to the user disabling the setting */ 41 data object ReasonSettingDisabled : SuppressionReason { 42 override val suppressedFeatures: Int = FEATURE_ALL 43 } 44 45 /** Suppress hub due to the user being locked */ 46 data object ReasonUserLocked : SuppressionReason { 47 override val suppressedFeatures: Int = FEATURE_ALL 48 } 49 50 /** Suppress hub due the a secondary user being active */ 51 data object ReasonSecondaryUser : SuppressionReason { 52 override val suppressedFeatures: Int = FEATURE_ALL 53 } 54 55 /** Suppress hub due to the flag being disabled */ 56 data object ReasonFlagDisabled : SuppressionReason { 57 override val suppressedFeatures: Int = FEATURE_ALL 58 } 59 60 /** Suppress hub due to an unknown reason, used as initial state and in tests */ 61 data class ReasonUnknown(override val suppressedFeatures: Int = FEATURE_ALL) : 62 SuppressionReason 63 } 64