Loading packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java +2 −1 Original line number Diff line number Diff line Loading @@ -4395,7 +4395,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab mFingerprintListenBuffer.toList() ).printTableData(pw); } pw.println("ActiveUnlockRunning=" + mTrustManager.isActiveUnlockRunning(KeyguardUpdateMonitor.getCurrentUser())); new DumpsysTableLogger( "KeyguardActiveUnlockTriggers", KeyguardActiveUnlockModel.TABLE_HEADERS, Loading packages/SystemUI/src/com/android/keyguard/logging/TrustRepositoryLogger.kt +22 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.keyguard.logging import com.android.systemui.dagger.SysUISingleton import com.android.systemui.keyguard.shared.model.ActiveUnlockModel import com.android.systemui.keyguard.shared.model.TrustManagedModel import com.android.systemui.keyguard.shared.model.TrustModel import com.android.systemui.log.LogBuffer Loading Loading @@ -76,6 +77,18 @@ constructor( ) } fun activeUnlockModelEmitted(value: ActiveUnlockModel) { logBuffer.log( TAG, LogLevel.DEBUG, { int1 = value.userId bool1 = value.isRunning }, { "activeUnlockModel emitted: userId: $int1 isRunning: $bool1" } ) } fun isCurrentUserTrusted(isCurrentUserTrusted: Boolean) { logBuffer.log( TAG, Loading @@ -85,6 +98,15 @@ constructor( ) } fun isCurrentUserActiveUnlockRunning(isCurrentUserActiveUnlockRunning: Boolean) { logBuffer.log( TAG, LogLevel.DEBUG, { bool1 = isCurrentUserActiveUnlockRunning }, { "isCurrentUserActiveUnlockRunning emitted: $bool1" } ) } fun isCurrentUserTrustManaged(isTrustManaged: Boolean) { logBuffer.log(TAG, DEBUG, { bool1 = isTrustManaged }, { "isTrustManaged emitted: $bool1" }) } Loading packages/SystemUI/src/com/android/systemui/keyguard/data/repository/TrustRepository.kt +30 −10 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import com.android.systemui.common.coroutine.ChannelExt.trySendWithFailureLoggin import com.android.systemui.common.coroutine.ConflatedCallbackFlow.conflatedCallbackFlow import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.keyguard.shared.model.ActiveUnlockModel import com.android.systemui.keyguard.shared.model.TrustManagedModel import com.android.systemui.keyguard.shared.model.TrustModel import com.android.systemui.user.data.repository.UserRepository Loading @@ -29,7 +30,6 @@ import javax.inject.Inject import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.combine Loading @@ -45,8 +45,8 @@ interface TrustRepository { /** Flow representing whether the current user is trusted. */ val isCurrentUserTrusted: Flow<Boolean> /** Flow representing whether active unlock is available for the current user. */ val isCurrentUserActiveUnlockAvailable: StateFlow<Boolean> /** Flow representing whether active unlock is running for the current user. */ val isCurrentUserActiveUnlockRunning: Flow<Boolean> /** Reports that whether trust is managed has changed for the current user. */ val isCurrentUserTrustManaged: StateFlow<Boolean> Loading @@ -62,6 +62,7 @@ constructor( private val logger: TrustRepositoryLogger, ) : TrustRepository { private val latestTrustModelForUser = mutableMapOf<Int, TrustModel>() private val activeUnlockRunningForUser = mutableMapOf<Int, ActiveUnlockModel>() private val trustManagedForUser = mutableMapOf<Int, TrustManagedModel>() private val trust = Loading @@ -87,6 +88,17 @@ constructor( override fun onEnabledTrustAgentsChanged(userId: Int) = Unit override fun onIsActiveUnlockRunningChanged( isRunning: Boolean, userId: Int ) { trySendWithFailureLogging( ActiveUnlockModel(isRunning, userId), TrustRepositoryLogger.TAG, "onActiveUnlockRunningChanged" ) } override fun onTrustManagedChanged(isTrustManaged: Boolean, userId: Int) { logger.onTrustManagedChanged(isTrustManaged, userId) trySendWithFailureLogging( Loading @@ -95,11 +107,6 @@ constructor( "onTrustManagedChanged" ) } override fun onIsActiveUnlockRunningChanged( isRunning: Boolean, userId: Int ) = Unit } trustManager.registerTrustListener(callback) logger.trustListenerRegistered() Loading @@ -114,6 +121,10 @@ constructor( latestTrustModelForUser[it.userId] = it logger.trustModelEmitted(it) } is ActiveUnlockModel -> { activeUnlockRunningForUser[it.userId] = it logger.activeUnlockModelEmitted(it) } is TrustManagedModel -> { trustManagedForUser[it.userId] = it logger.trustManagedModelEmitted(it) Loading @@ -122,8 +133,17 @@ constructor( } .shareIn(applicationScope, started = SharingStarted.Eagerly, replay = 1) // TODO: Implement based on TrustManager callback b/267322286 override val isCurrentUserActiveUnlockAvailable: StateFlow<Boolean> = MutableStateFlow(true) override val isCurrentUserActiveUnlockRunning: Flow<Boolean> = combine(trust, userRepository.selectedUserInfo, ::Pair) .map { activeUnlockRunningForUser[it.second.id]?.isRunning ?: false } .distinctUntilChanged() .onEach { logger.isCurrentUserActiveUnlockRunning(it) } .onStart { emit( activeUnlockRunningForUser[userRepository.getSelectedUserInfo().id]?.isRunning ?: false ) } override val isCurrentUserTrustManaged: StateFlow<Boolean> get() = Loading packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/PrimaryBouncerInteractor.kt +27 −13 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import com.android.systemui.DejankUtils import com.android.systemui.R import com.android.systemui.classifier.FalsingCollector import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.flags.FeatureFlags import com.android.systemui.flags.Flags Loading @@ -43,11 +44,14 @@ import com.android.systemui.keyguard.shared.model.BouncerShowMessageModel import com.android.systemui.plugins.ActivityStarter import com.android.systemui.shared.system.SysUiStatsLog import com.android.systemui.statusbar.policy.KeyguardStateController import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.collect import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.filter import kotlinx.coroutines.flow.filterNotNull import kotlinx.coroutines.flow.map import kotlinx.coroutines.launch import javax.inject.Inject /** Loading @@ -70,6 +74,7 @@ constructor( private val keyguardUpdateMonitor: KeyguardUpdateMonitor, private val trustRepository: TrustRepository, private val featureFlags: FeatureFlags, @Application private val applicationScope: CoroutineScope, ) { private val passiveAuthBouncerDelay = context.resources.getInteger( R.integer.primary_bouncer_passive_auth_delay).toLong() Loading Loading @@ -104,6 +109,7 @@ constructor( /** Allow for interaction when just about fully visible */ val isInteractable: Flow<Boolean> = bouncerExpansion.map { it > 0.9 } val sideFpsShowing: Flow<Boolean> = repository.sideFpsShowing private var currentUserActiveUnlockRunning = false /** This callback needs to be a class field so it does not get garbage collected. */ val keyguardUpdateMonitorCallback = Loading @@ -122,6 +128,13 @@ constructor( init { keyguardUpdateMonitor.registerCallback(keyguardUpdateMonitorCallback) if (featureFlags.isEnabled(Flags.DELAY_BOUNCER)) { applicationScope.launch { trustRepository.isCurrentUserActiveUnlockRunning.collect { currentUserActiveUnlockRunning = it } } } } // TODO(b/243685699): Move isScrimmed logic to data layer. Loading Loading @@ -377,8 +390,9 @@ constructor( private fun usePrimaryBouncerPassiveAuthDelay(): Boolean { val canRunFaceAuth = keyguardStateController.isFaceAuthEnabled && keyguardUpdateMonitor.isUnlockingWithBiometricAllowed(BiometricSourceType.FACE) val canRunActiveUnlock = trustRepository.isCurrentUserActiveUnlockAvailable.value && val canRunActiveUnlock = currentUserActiveUnlockRunning && keyguardUpdateMonitor.canTriggerActiveUnlockBasedOnDeviceState() return featureFlags.isEnabled(Flags.DELAY_BOUNCER) && !needsFullscreenBouncer() && (canRunFaceAuth || canRunActiveUnlock) Loading packages/SystemUI/src/com/android/systemui/keyguard/shared/model/ActiveUnlockModel.kt 0 → 100644 +25 −0 Original line number Diff line number Diff line /* * Copyright (C) 2023 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.systemui.keyguard.shared.model /** Represents the active unlock state */ data class ActiveUnlockModel( /** If true, the system believes active unlock is available and can be usd to unlock. */ val isRunning: Boolean, /** The user, for which active unlock may be running. */ val userId: Int, ) Loading
packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java +2 −1 Original line number Diff line number Diff line Loading @@ -4395,7 +4395,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab mFingerprintListenBuffer.toList() ).printTableData(pw); } pw.println("ActiveUnlockRunning=" + mTrustManager.isActiveUnlockRunning(KeyguardUpdateMonitor.getCurrentUser())); new DumpsysTableLogger( "KeyguardActiveUnlockTriggers", KeyguardActiveUnlockModel.TABLE_HEADERS, Loading
packages/SystemUI/src/com/android/keyguard/logging/TrustRepositoryLogger.kt +22 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.keyguard.logging import com.android.systemui.dagger.SysUISingleton import com.android.systemui.keyguard.shared.model.ActiveUnlockModel import com.android.systemui.keyguard.shared.model.TrustManagedModel import com.android.systemui.keyguard.shared.model.TrustModel import com.android.systemui.log.LogBuffer Loading Loading @@ -76,6 +77,18 @@ constructor( ) } fun activeUnlockModelEmitted(value: ActiveUnlockModel) { logBuffer.log( TAG, LogLevel.DEBUG, { int1 = value.userId bool1 = value.isRunning }, { "activeUnlockModel emitted: userId: $int1 isRunning: $bool1" } ) } fun isCurrentUserTrusted(isCurrentUserTrusted: Boolean) { logBuffer.log( TAG, Loading @@ -85,6 +98,15 @@ constructor( ) } fun isCurrentUserActiveUnlockRunning(isCurrentUserActiveUnlockRunning: Boolean) { logBuffer.log( TAG, LogLevel.DEBUG, { bool1 = isCurrentUserActiveUnlockRunning }, { "isCurrentUserActiveUnlockRunning emitted: $bool1" } ) } fun isCurrentUserTrustManaged(isTrustManaged: Boolean) { logBuffer.log(TAG, DEBUG, { bool1 = isTrustManaged }, { "isTrustManaged emitted: $bool1" }) } Loading
packages/SystemUI/src/com/android/systemui/keyguard/data/repository/TrustRepository.kt +30 −10 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import com.android.systemui.common.coroutine.ChannelExt.trySendWithFailureLoggin import com.android.systemui.common.coroutine.ConflatedCallbackFlow.conflatedCallbackFlow import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.keyguard.shared.model.ActiveUnlockModel import com.android.systemui.keyguard.shared.model.TrustManagedModel import com.android.systemui.keyguard.shared.model.TrustModel import com.android.systemui.user.data.repository.UserRepository Loading @@ -29,7 +30,6 @@ import javax.inject.Inject import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.combine Loading @@ -45,8 +45,8 @@ interface TrustRepository { /** Flow representing whether the current user is trusted. */ val isCurrentUserTrusted: Flow<Boolean> /** Flow representing whether active unlock is available for the current user. */ val isCurrentUserActiveUnlockAvailable: StateFlow<Boolean> /** Flow representing whether active unlock is running for the current user. */ val isCurrentUserActiveUnlockRunning: Flow<Boolean> /** Reports that whether trust is managed has changed for the current user. */ val isCurrentUserTrustManaged: StateFlow<Boolean> Loading @@ -62,6 +62,7 @@ constructor( private val logger: TrustRepositoryLogger, ) : TrustRepository { private val latestTrustModelForUser = mutableMapOf<Int, TrustModel>() private val activeUnlockRunningForUser = mutableMapOf<Int, ActiveUnlockModel>() private val trustManagedForUser = mutableMapOf<Int, TrustManagedModel>() private val trust = Loading @@ -87,6 +88,17 @@ constructor( override fun onEnabledTrustAgentsChanged(userId: Int) = Unit override fun onIsActiveUnlockRunningChanged( isRunning: Boolean, userId: Int ) { trySendWithFailureLogging( ActiveUnlockModel(isRunning, userId), TrustRepositoryLogger.TAG, "onActiveUnlockRunningChanged" ) } override fun onTrustManagedChanged(isTrustManaged: Boolean, userId: Int) { logger.onTrustManagedChanged(isTrustManaged, userId) trySendWithFailureLogging( Loading @@ -95,11 +107,6 @@ constructor( "onTrustManagedChanged" ) } override fun onIsActiveUnlockRunningChanged( isRunning: Boolean, userId: Int ) = Unit } trustManager.registerTrustListener(callback) logger.trustListenerRegistered() Loading @@ -114,6 +121,10 @@ constructor( latestTrustModelForUser[it.userId] = it logger.trustModelEmitted(it) } is ActiveUnlockModel -> { activeUnlockRunningForUser[it.userId] = it logger.activeUnlockModelEmitted(it) } is TrustManagedModel -> { trustManagedForUser[it.userId] = it logger.trustManagedModelEmitted(it) Loading @@ -122,8 +133,17 @@ constructor( } .shareIn(applicationScope, started = SharingStarted.Eagerly, replay = 1) // TODO: Implement based on TrustManager callback b/267322286 override val isCurrentUserActiveUnlockAvailable: StateFlow<Boolean> = MutableStateFlow(true) override val isCurrentUserActiveUnlockRunning: Flow<Boolean> = combine(trust, userRepository.selectedUserInfo, ::Pair) .map { activeUnlockRunningForUser[it.second.id]?.isRunning ?: false } .distinctUntilChanged() .onEach { logger.isCurrentUserActiveUnlockRunning(it) } .onStart { emit( activeUnlockRunningForUser[userRepository.getSelectedUserInfo().id]?.isRunning ?: false ) } override val isCurrentUserTrustManaged: StateFlow<Boolean> get() = Loading
packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/PrimaryBouncerInteractor.kt +27 −13 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import com.android.systemui.DejankUtils import com.android.systemui.R import com.android.systemui.classifier.FalsingCollector import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.flags.FeatureFlags import com.android.systemui.flags.Flags Loading @@ -43,11 +44,14 @@ import com.android.systemui.keyguard.shared.model.BouncerShowMessageModel import com.android.systemui.plugins.ActivityStarter import com.android.systemui.shared.system.SysUiStatsLog import com.android.systemui.statusbar.policy.KeyguardStateController import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.collect import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.filter import kotlinx.coroutines.flow.filterNotNull import kotlinx.coroutines.flow.map import kotlinx.coroutines.launch import javax.inject.Inject /** Loading @@ -70,6 +74,7 @@ constructor( private val keyguardUpdateMonitor: KeyguardUpdateMonitor, private val trustRepository: TrustRepository, private val featureFlags: FeatureFlags, @Application private val applicationScope: CoroutineScope, ) { private val passiveAuthBouncerDelay = context.resources.getInteger( R.integer.primary_bouncer_passive_auth_delay).toLong() Loading Loading @@ -104,6 +109,7 @@ constructor( /** Allow for interaction when just about fully visible */ val isInteractable: Flow<Boolean> = bouncerExpansion.map { it > 0.9 } val sideFpsShowing: Flow<Boolean> = repository.sideFpsShowing private var currentUserActiveUnlockRunning = false /** This callback needs to be a class field so it does not get garbage collected. */ val keyguardUpdateMonitorCallback = Loading @@ -122,6 +128,13 @@ constructor( init { keyguardUpdateMonitor.registerCallback(keyguardUpdateMonitorCallback) if (featureFlags.isEnabled(Flags.DELAY_BOUNCER)) { applicationScope.launch { trustRepository.isCurrentUserActiveUnlockRunning.collect { currentUserActiveUnlockRunning = it } } } } // TODO(b/243685699): Move isScrimmed logic to data layer. Loading Loading @@ -377,8 +390,9 @@ constructor( private fun usePrimaryBouncerPassiveAuthDelay(): Boolean { val canRunFaceAuth = keyguardStateController.isFaceAuthEnabled && keyguardUpdateMonitor.isUnlockingWithBiometricAllowed(BiometricSourceType.FACE) val canRunActiveUnlock = trustRepository.isCurrentUserActiveUnlockAvailable.value && val canRunActiveUnlock = currentUserActiveUnlockRunning && keyguardUpdateMonitor.canTriggerActiveUnlockBasedOnDeviceState() return featureFlags.isEnabled(Flags.DELAY_BOUNCER) && !needsFullscreenBouncer() && (canRunFaceAuth || canRunActiveUnlock) Loading
packages/SystemUI/src/com/android/systemui/keyguard/shared/model/ActiveUnlockModel.kt 0 → 100644 +25 −0 Original line number Diff line number Diff line /* * Copyright (C) 2023 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.systemui.keyguard.shared.model /** Represents the active unlock state */ data class ActiveUnlockModel( /** If true, the system believes active unlock is available and can be usd to unlock. */ val isRunning: Boolean, /** The user, for which active unlock may be running. */ val userId: Int, )