1 /* <lambda>null2 * Copyright (C) 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.statusbar.notification.shelf.domain.interactor 18 19 import android.os.PowerManager 20 import com.android.systemui.dagger.SysUISingleton 21 import com.android.systemui.deviceentry.data.repository.DeviceEntryFaceAuthRepository 22 import com.android.systemui.keyguard.data.repository.KeyguardRepository 23 import com.android.systemui.power.domain.interactor.PowerInteractor 24 import com.android.systemui.shade.domain.interactor.ShadeModeInteractor 25 import com.android.systemui.shade.shared.model.ShadeMode 26 import com.android.systemui.statusbar.LockscreenShadeTransitionController 27 import com.android.systemui.statusbar.NotificationShelf 28 import javax.inject.Inject 29 import kotlinx.coroutines.flow.Flow 30 import kotlinx.coroutines.flow.combine 31 import kotlinx.coroutines.flow.map 32 33 /** Interactor for the [NotificationShelf] */ 34 @SysUISingleton 35 class NotificationShelfInteractor 36 @Inject 37 constructor( 38 private val keyguardRepository: KeyguardRepository, 39 private val deviceEntryFaceAuthRepository: DeviceEntryFaceAuthRepository, 40 private val powerInteractor: PowerInteractor, 41 private val shadeModeInteractor: ShadeModeInteractor, 42 private val keyguardTransitionController: LockscreenShadeTransitionController, 43 ) { 44 /** Is the shelf showing on the keyguard? */ 45 val isShowingOnKeyguard: Flow<Boolean> 46 get() = keyguardRepository.isKeyguardShowing 47 48 /** Is the system in a state where the shelf is just a static display of notification icons? */ 49 val isShelfStatic: Flow<Boolean> 50 get() = 51 combine( 52 keyguardRepository.isKeyguardShowing, 53 deviceEntryFaceAuthRepository.isBypassEnabled, 54 ) { isKeyguardShowing, isBypassEnabled -> 55 isKeyguardShowing && isBypassEnabled 56 } 57 58 /** Should the shelf be aligned to the end in the current configuration? */ 59 val isAlignedToEnd: Flow<Boolean> 60 get() = 61 shadeModeInteractor.shadeMode.map { shadeMode -> 62 when (shadeMode) { 63 ShadeMode.Split -> true 64 else -> false 65 } 66 } 67 68 /** Transition keyguard to the locked shade, triggered by the shelf. */ 69 fun goToLockedShadeFromShelf() { 70 powerInteractor.wakeUpIfDozing("SHADE_CLICK", PowerManager.WAKE_REASON_GESTURE) 71 keyguardTransitionController.goToLockedShade(null) 72 } 73 } 74