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.deviceentry.ui.viewmodel
18 
19 import com.android.systemui.accessibility.domain.interactor.AccessibilityInteractor
20 import com.android.systemui.biometrics.domain.interactor.UdfpsOverlayInteractor
21 import com.android.systemui.keyguard.ui.view.DeviceEntryIconView
22 import com.android.systemui.keyguard.ui.viewmodel.DeviceEntryForegroundViewModel
23 import com.android.systemui.keyguard.ui.viewmodel.DeviceEntryIconViewModel
24 import javax.inject.Inject
25 import kotlinx.coroutines.ExperimentalCoroutinesApi
26 import kotlinx.coroutines.flow.Flow
27 import kotlinx.coroutines.flow.combine
28 
29 /** Models the UI state for the non-alternate bouncer UDFPS accessibility overlay */
30 @ExperimentalCoroutinesApi
31 class DeviceEntryUdfpsAccessibilityOverlayViewModel
32 @Inject
33 constructor(
34     udfpsOverlayInteractor: UdfpsOverlayInteractor,
35     accessibilityInteractor: AccessibilityInteractor,
36     private val deviceEntryIconViewModel: DeviceEntryIconViewModel,
37     private val deviceEntryFgIconViewModel: DeviceEntryForegroundViewModel,
38 ) :
39     UdfpsAccessibilityOverlayViewModel(
40         udfpsOverlayInteractor,
41         accessibilityInteractor,
42     ) {
43     /** Overlay is only visible if the UDFPS icon is visible on the keyguard. */
44     override fun isVisibleWhenTouchExplorationEnabled(): Flow<Boolean> =
45         combine(
46             deviceEntryFgIconViewModel.viewModel,
47             deviceEntryIconViewModel.deviceEntryViewAlpha,
48         ) { iconViewModel, alpha ->
49             iconViewModel.type == DeviceEntryIconView.IconType.FINGERPRINT &&
50                 !iconViewModel.useAodVariant &&
51                 alpha == 1f
52         }
53 }
54