Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 36eb5936 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "[flexiglass] TableLogBuffer" into main

parents 7650b0f3 f1dd746c
Loading
Loading
Loading
Loading
+9 −1
Original line number Original line Diff line number Diff line
@@ -32,6 +32,9 @@ import com.android.systemui.authentication.shared.model.AuthenticationWipeModel.
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.log.table.TableLogBuffer
import com.android.systemui.log.table.logDiffsForTable
import com.android.systemui.scene.domain.SceneFrameworkTableLog
import com.android.systemui.user.domain.interactor.SelectedUserInteractor
import com.android.systemui.user.domain.interactor.SelectedUserInteractor
import com.android.systemui.util.time.SystemClock
import com.android.systemui.util.time.SystemClock
import javax.inject.Inject
import javax.inject.Inject
@@ -66,6 +69,7 @@ constructor(
    @Background private val backgroundDispatcher: CoroutineDispatcher,
    @Background private val backgroundDispatcher: CoroutineDispatcher,
    private val repository: AuthenticationRepository,
    private val repository: AuthenticationRepository,
    private val selectedUserInteractor: SelectedUserInteractor,
    private val selectedUserInteractor: SelectedUserInteractor,
    @SceneFrameworkTableLog private val tableLogBuffer: TableLogBuffer,
) {
) {
    /**
    /**
     * The currently-configured authentication method. This determines how the authentication
     * The currently-configured authentication method. This determines how the authentication
@@ -85,7 +89,11 @@ constructor(
     * `true` even when the lockscreen is showing and still needs to be dismissed by the user to
     * `true` even when the lockscreen is showing and still needs to be dismissed by the user to
     * proceed.
     * proceed.
     */
     */
    val authenticationMethod: Flow<AuthenticationMethodModel> = repository.authenticationMethod
    val authenticationMethod: Flow<AuthenticationMethodModel> =
        repository.authenticationMethod.logDiffsForTable(
            tableLogBuffer = tableLogBuffer,
            initialValue = AuthenticationMethodModel.None,
        )


    /**
    /**
     * Whether the auto confirm feature is enabled for the currently-selected user.
     * Whether the auto confirm feature is enabled for the currently-selected user.
+9 −2
Original line number Original line Diff line number Diff line
@@ -16,6 +16,9 @@


package com.android.systemui.authentication.shared.model
package com.android.systemui.authentication.shared.model


import com.android.systemui.log.table.Diffable
import com.android.systemui.log.table.TableRowLogger

/** Enumerates all known authentication methods. */
/** Enumerates all known authentication methods. */
sealed class AuthenticationMethodModel(
sealed class AuthenticationMethodModel(
    /**
    /**
@@ -24,8 +27,8 @@ sealed class AuthenticationMethodModel(
     * "Secure" authentication methods require authentication to unlock the device. Non-secure auth
     * "Secure" authentication methods require authentication to unlock the device. Non-secure auth
     * methods simply require user dismissal.
     * methods simply require user dismissal.
     */
     */
    open val isSecure: Boolean,
    open val isSecure: Boolean
) {
) : Diffable<AuthenticationMethodModel> {
    /**
    /**
     * Device doesn't use a secure authentication method. Either there is no lockscreen or the lock
     * Device doesn't use a secure authentication method. Either there is no lockscreen or the lock
     * screen can be swiped away when displayed.
     * screen can be swiped away when displayed.
@@ -39,4 +42,8 @@ sealed class AuthenticationMethodModel(
    data object Pattern : AuthenticationMethodModel(isSecure = true)
    data object Pattern : AuthenticationMethodModel(isSecure = true)


    data object Sim : AuthenticationMethodModel(isSecure = true)
    data object Sim : AuthenticationMethodModel(isSecure = true)

    override fun logDiffs(prevVal: AuthenticationMethodModel, row: TableRowLogger) {
        row.logChange(columnName = "authenticationMethod", value = toString())
    }
}
}
+9 −6
Original line number Original line Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.systemui.deviceentry.domain.interactor
import com.android.systemui.CoreStartable
import com.android.systemui.CoreStartable
import com.android.systemui.deviceentry.shared.model.FaceAuthenticationStatus
import com.android.systemui.deviceentry.shared.model.FaceAuthenticationStatus
import com.android.systemui.deviceentry.shared.model.FaceDetectionStatus
import com.android.systemui.deviceentry.shared.model.FaceDetectionStatus
import com.android.systemui.log.table.TableLogBuffer
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.StateFlow


@@ -81,6 +82,8 @@ interface DeviceEntryFaceAuthInteractor : CoreStartable {


    /** Whether face auth is considered class 3 */
    /** Whether face auth is considered class 3 */
    fun isFaceAuthStrong(): Boolean
    fun isFaceAuthStrong(): Boolean

    suspend fun hydrateTableLogBuffer(tableLogBuffer: TableLogBuffer)
}
}


/**
/**
@@ -93,17 +96,17 @@ interface DeviceEntryFaceAuthInteractor : CoreStartable {
 */
 */
interface FaceAuthenticationListener {
interface FaceAuthenticationListener {
    /** Receive face isAuthenticated updates */
    /** Receive face isAuthenticated updates */
    fun onAuthenticatedChanged(isAuthenticated: Boolean)
    fun onAuthenticatedChanged(isAuthenticated: Boolean) = Unit


    /** Receive face authentication status updates */
    /** Receive face authentication status updates */
    fun onAuthenticationStatusChanged(status: FaceAuthenticationStatus)
    fun onAuthenticationStatusChanged(status: FaceAuthenticationStatus) = Unit


    /** Receive status updates whenever face detection runs */
    /** Receive status updates whenever face detection runs */
    fun onDetectionStatusChanged(status: FaceDetectionStatus)
    fun onDetectionStatusChanged(status: FaceDetectionStatus) = Unit


    fun onLockoutStateChanged(isLockedOut: Boolean)
    fun onLockoutStateChanged(isLockedOut: Boolean) = Unit


    fun onRunningStateChanged(isRunning: Boolean)
    fun onRunningStateChanged(isRunning: Boolean) = Unit


    fun onAuthEnrollmentStateChanged(enrolled: Boolean)
    fun onAuthEnrollmentStateChanged(enrolled: Boolean) = Unit
}
}
+42 −0
Original line number Original line Diff line number Diff line
@@ -25,7 +25,10 @@ import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.deviceentry.data.repository.DeviceEntryRepository
import com.android.systemui.deviceentry.data.repository.DeviceEntryRepository
import com.android.systemui.keyguard.DismissCallbackRegistry
import com.android.systemui.keyguard.DismissCallbackRegistry
import com.android.systemui.log.table.TableLogBuffer
import com.android.systemui.log.table.logDiffsForTable
import com.android.systemui.scene.data.model.asIterable
import com.android.systemui.scene.data.model.asIterable
import com.android.systemui.scene.domain.SceneFrameworkTableLog
import com.android.systemui.scene.domain.interactor.SceneBackInteractor
import com.android.systemui.scene.domain.interactor.SceneBackInteractor
import com.android.systemui.scene.domain.interactor.SceneInteractor
import com.android.systemui.scene.domain.interactor.SceneInteractor
import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.scene.shared.model.Scenes
@@ -33,9 +36,11 @@ import com.android.systemui.util.kotlin.pairwise
import com.android.systemui.utils.coroutines.flow.mapLatestConflated
import com.android.systemui.utils.coroutines.flow.mapLatestConflated
import javax.inject.Inject
import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.filter
@@ -43,6 +48,7 @@ import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.onStart
import kotlinx.coroutines.flow.onStart
import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.launch


/**
/**
 * Hosts application business logic related to device entry.
 * Hosts application business logic related to device entry.
@@ -62,6 +68,7 @@ constructor(
    private val alternateBouncerInteractor: AlternateBouncerInteractor,
    private val alternateBouncerInteractor: AlternateBouncerInteractor,
    private val dismissCallbackRegistry: DismissCallbackRegistry,
    private val dismissCallbackRegistry: DismissCallbackRegistry,
    sceneBackInteractor: SceneBackInteractor,
    sceneBackInteractor: SceneBackInteractor,
    @SceneFrameworkTableLog private val tableLogBuffer: TableLogBuffer,
) {
) {
    /**
    /**
     * Whether the device is unlocked.
     * Whether the device is unlocked.
@@ -147,6 +154,11 @@ constructor(
            ) { enteredDirectly, enteredOnBackStack ->
            ) { enteredDirectly, enteredOnBackStack ->
                enteredOnBackStack || enteredDirectly
                enteredOnBackStack || enteredDirectly
            }
            }
            .logDiffsForTable(
                tableLogBuffer = tableLogBuffer,
                columnName = "isDeviceEntered",
                initialValue = false,
            )
            .stateIn(
            .stateIn(
                scope = applicationScope,
                scope = applicationScope,
                started = SharingStarted.Eagerly,
                started = SharingStarted.Eagerly,
@@ -184,6 +196,11 @@ constructor(
                        deviceUnlockStatus.deviceUnlockSource?.dismissesLockscreen == false)) &&
                        deviceUnlockStatus.deviceUnlockSource?.dismissesLockscreen == false)) &&
                    !isDeviceEntered
                    !isDeviceEntered
            }
            }
            .logDiffsForTable(
                tableLogBuffer = tableLogBuffer,
                columnName = "canSwipeToEnter",
                initialValue = false,
            )
            .stateIn(
            .stateIn(
                scope = applicationScope,
                scope = applicationScope,
                started = SharingStarted.Eagerly,
                started = SharingStarted.Eagerly,
@@ -271,4 +288,29 @@ constructor(
    fun lockNow() {
    fun lockNow() {
        deviceUnlockedInteractor.lockNow()
        deviceUnlockedInteractor.lockNow()
    }
    }

    suspend fun hydrateTableLogBuffer(tableLogBuffer: TableLogBuffer) {
        coroutineScope {
            launch {
                isDeviceEntered
                    .logDiffsForTable(
                        tableLogBuffer = tableLogBuffer,
                        columnName = "isDeviceEntered",
                        initialValue = isDeviceEntered.value,
                    )
                    .collect()
            }

            launch {
                canSwipeToEnter
                    .map { it?.toString() ?: "" }
                    .logDiffsForTable(
                        tableLogBuffer = tableLogBuffer,
                        columnName = "canSwipeToEnter",
                        initialValue = canSwipeToEnter.value?.toString() ?: "",
                    )
                    .collect()
            }
        }
    }
}
}
+32 −11
Original line number Original line Diff line number Diff line
@@ -33,8 +33,11 @@ import com.android.systemui.keyguard.KeyguardViewMediator
import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor
import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor
import com.android.systemui.keyguard.domain.interactor.TrustInteractor
import com.android.systemui.keyguard.domain.interactor.TrustInteractor
import com.android.systemui.lifecycle.ExclusiveActivatable
import com.android.systemui.lifecycle.ExclusiveActivatable
import com.android.systemui.log.table.TableLogBuffer
import com.android.systemui.log.table.logDiffsForTable
import com.android.systemui.power.domain.interactor.PowerInteractor
import com.android.systemui.power.domain.interactor.PowerInteractor
import com.android.systemui.power.shared.model.WakeSleepReason
import com.android.systemui.power.shared.model.WakeSleepReason
import com.android.systemui.scene.domain.SceneFrameworkTableLog
import com.android.systemui.scene.shared.flag.SceneContainerFlag
import com.android.systemui.scene.shared.flag.SceneContainerFlag
import com.android.systemui.util.settings.repository.UserAwareSecureSettingsRepository
import com.android.systemui.util.settings.repository.UserAwareSecureSettingsRepository
import com.android.systemui.utils.coroutines.flow.flatMapLatestConflated
import com.android.systemui.utils.coroutines.flow.flatMapLatestConflated
@@ -48,6 +51,7 @@ import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.distinctUntilChanged
@@ -74,6 +78,7 @@ constructor(
    private val systemPropertiesHelper: SystemPropertiesHelper,
    private val systemPropertiesHelper: SystemPropertiesHelper,
    private val userAwareSecureSettingsRepository: UserAwareSecureSettingsRepository,
    private val userAwareSecureSettingsRepository: UserAwareSecureSettingsRepository,
    private val keyguardInteractor: KeyguardInteractor,
    private val keyguardInteractor: KeyguardInteractor,
    @SceneFrameworkTableLog private val tableLogBuffer: TableLogBuffer,
) : ExclusiveActivatable() {
) : ExclusiveActivatable() {


    private val deviceUnlockSource =
    private val deviceUnlockSource =
@@ -179,9 +184,12 @@ constructor(
    private val lockNowRequests = Channel<Unit>()
    private val lockNowRequests = Channel<Unit>()


    override suspend fun onActivated(): Nothing {
    override suspend fun onActivated(): Nothing {
        coroutineScope {
            launch {
                authenticationInteractor.authenticationMethod.collectLatest { authMethod ->
                authenticationInteractor.authenticationMethod.collectLatest { authMethod ->
                    if (!authMethod.isSecure) {
                    if (!authMethod.isSecure) {
                // Device remains unlocked as long as the authentication method is not secure.
                        // Device remains unlocked as long as the authentication method is not
                        // secure.
                        Log.d(TAG, "remaining unlocked because auth method not secure")
                        Log.d(TAG, "remaining unlocked because auth method not secure")
                        repository.deviceUnlockStatus.value = DeviceUnlockStatus(true, null)
                        repository.deviceUnlockStatus.value = DeviceUnlockStatus(true, null)
                    } else if (authMethod == AuthenticationMethodModel.Sim) {
                    } else if (authMethod == AuthenticationMethodModel.Sim) {
@@ -192,6 +200,19 @@ constructor(
                        handleLockAndUnlockEvents()
                        handleLockAndUnlockEvents()
                    }
                    }
                }
                }
            }

            launch {
                deviceUnlockStatus
                    .map { it.isUnlocked }
                    .logDiffsForTable(
                        tableLogBuffer = tableLogBuffer,
                        columnName = "isUnlocked",
                        initialValue = deviceUnlockStatus.value.isUnlocked,
                    )
                    .collect()
            }
        }


        awaitCancellation()
        awaitCancellation()
    }
    }
Loading