1 /* 2 * 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.keyguard.domain.interactor 18 19 import com.android.systemui.dagger.SysUISingleton 20 import com.android.systemui.keyguard.data.repository.TrustRepository 21 import javax.inject.Inject 22 import kotlinx.coroutines.flow.Flow 23 import kotlinx.coroutines.flow.StateFlow 24 25 /** Encapsulates any state relevant to trust agents and trust grants. */ 26 @SysUISingleton 27 class TrustInteractor @Inject constructor(repository: TrustRepository) { 28 /** 29 * Whether the current user has a trust agent enabled. This is true if the user has at least one 30 * trust agent enabled in settings. 31 */ 32 val isEnrolledAndEnabled: StateFlow<Boolean> = repository.isCurrentUserTrustUsuallyManaged 33 34 /** 35 * Whether the current user's trust agent is currently allowed, this will be false if trust 36 * agent is disabled for any reason (security timeout, disabled on lock screen by opening the 37 * power menu, etc), it does not include temporary biometric lockouts. 38 */ 39 val isTrustAgentCurrentlyAllowed: StateFlow<Boolean> = repository.isCurrentUserTrustManaged 40 41 /** Whether the current user is trusted by any of the enabled trust agents. */ 42 val isTrusted: Flow<Boolean> = repository.isCurrentUserTrusted 43 } 44