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.notification.stack.domain.interactor 18 19 import com.android.systemui.dagger.SysUISingleton 20 import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor 21 import com.android.systemui.keyguard.shared.model.StatusBarState 22 import com.android.systemui.power.domain.interactor.PowerInteractor 23 import javax.inject.Inject 24 import kotlinx.coroutines.flow.Flow 25 import kotlinx.coroutines.flow.combine 26 import kotlinx.coroutines.flow.distinctUntilChanged 27 import kotlinx.coroutines.flow.map 28 29 /** Interactor exposing states related to the stack's context */ 30 @SysUISingleton 31 class NotificationStackInteractor 32 @Inject 33 constructor( 34 keyguardInteractor: KeyguardInteractor, 35 powerInteractor: PowerInteractor, 36 ) { 37 val isShowingOnLockscreen: Flow<Boolean> = 38 combine( 39 // Non-notification UI elements of the notification list should not be visible 40 // on the lockscreen (incl. AOD and bouncer), except if the shade is opened on 41 // top. See b/219680200 for the footer and b/228790482, b/267060171 for the 42 // empty shade. 43 // TODO(b/323187006): There's a plan to eventually get rid of StatusBarState 44 // entirely, so this will have to be replaced at some point. 45 keyguardInteractor.statusBarState.map { it == StatusBarState.KEYGUARD }, 46 // The StatusBarState is unfortunately not updated quickly enough when the power 47 // button is pressed, so this is necessary in addition to the KEYGUARD check to 48 // cover the transition to AOD while going to sleep (b/190227875). 49 powerInteractor.isAsleep, 50 ) { (isOnKeyguard, isAsleep) -> 51 isOnKeyguard || isAsleep 52 } 53 .distinctUntilChanged() 54 } 55