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

Commit daa91ddd authored by Grace Cheng's avatar Grace Cheng
Browse files

Create SecureLockDeviceLog

Create LogBuffer class for secure lock device for debugging purposes

Flag: android.security.secure_lock_device
Bug: 401645997
Test: EXEMPT logging only
Change-Id: I5cea94e207880e6684301a1d1244058ddbfcd207
parent 6dc66003
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 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.log.dagger

import javax.inject.Qualifier

/** A [Qualifier] for the log buffer for the secure lock device feature. */
@Qualifier
@MustBeDocumented
@Retention(AnnotationRetention.RUNTIME)
annotation class SecureLockDeviceLog
+13 −0
Original line number Diff line number Diff line
@@ -24,6 +24,9 @@ import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.deviceentry.domain.interactor.DeviceEntryBiometricSettingsInteractor
import com.android.systemui.deviceentry.domain.interactor.SystemUIDeviceEntryFaceAuthInteractor
import com.android.systemui.keyguard.data.repository.BiometricSettingsRepository
import com.android.systemui.log.LogBuffer
import com.android.systemui.log.LogBufferFactory
import com.android.systemui.log.dagger.SecureLockDeviceLog
import com.android.systemui.securelockdevice.data.repository.SecureLockDeviceRepository
import com.android.systemui.securelockdevice.data.repository.SecureLockDeviceRepositoryImpl
import com.android.systemui.securelockdevice.domain.interactor.SecureLockDeviceInteractor
@@ -32,6 +35,7 @@ import dagger.Provides
import java.util.concurrent.Executor
import kotlinx.coroutines.CoroutineScope

/** Dagger module for secure lock device feature. */
@Module
interface SecureLockDeviceModule {

@@ -54,6 +58,7 @@ interface SecureLockDeviceModule {
        @SysUISingleton
        fun providesSecureLockDeviceInteractor(
            @Application applicationScope: CoroutineScope,
            @SecureLockDeviceLog logBuffer: LogBuffer,
            secureLockDeviceRepository: SecureLockDeviceRepository,
            biometricSettingsInteractor: DeviceEntryBiometricSettingsInteractor,
            deviceEntryFaceAuthInteractor: SystemUIDeviceEntryFaceAuthInteractor,
@@ -62,6 +67,7 @@ interface SecureLockDeviceModule {
        ): SecureLockDeviceInteractor {
            return SecureLockDeviceInteractor(
                applicationScope = applicationScope,
                logBuffer = logBuffer,
                secureLockDeviceRepository = secureLockDeviceRepository,
                biometricSettingsInteractor = biometricSettingsInteractor,
                deviceEntryFaceAuthInteractor = deviceEntryFaceAuthInteractor,
@@ -69,5 +75,12 @@ interface SecureLockDeviceModule {
                facePropertyInteractor = facePropertyInteractor,
            )
        }

        @Provides
        @SysUISingleton
        @SecureLockDeviceLog
        fun provideSecureLockDeviceLogBuffer(factory: LogBufferFactory): LogBuffer {
            return factory.create("SecureLockDeviceLog", 100)
        }
    }
}
+25 −1
Original line number Diff line number Diff line
@@ -25,6 +25,9 @@ import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.deviceentry.domain.interactor.DeviceEntryBiometricSettingsInteractor
import com.android.systemui.deviceentry.domain.interactor.SystemUIDeviceEntryFaceAuthInteractor
import com.android.systemui.log.LogBuffer
import com.android.systemui.log.core.LogLevel
import com.android.systemui.log.dagger.SecureLockDeviceLog
import com.android.systemui.securelockdevice.data.repository.SecureLockDeviceRepository
import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
@@ -37,12 +40,21 @@ import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.stateIn

/** Handles business logic for secure lock device. */
/**
 * Handles business logic for secure lock device.
 *
 * Secure lock device is a feature called by a privileged component to remotely enable secure lock
 * on the device across all users. Secure lock is an enhanced security state that restricts access
 * to sensitive data (app notifications, widgets, quick settings, assistant, etc), and locks the
 * device under the calling user's credentials with multi-factor authentication for device entry,
 * such as two-factor primary authentication and strong biometric authentication.
 */
@SysUISingleton
class SecureLockDeviceInteractor
@Inject
constructor(
    @Application applicationScope: CoroutineScope,
    @SecureLockDeviceLog private val logBuffer: LogBuffer,
    secureLockDeviceRepository: SecureLockDeviceRepository,
    biometricSettingsInteractor: DeviceEntryBiometricSettingsInteractor,
    private val deviceEntryFaceAuthInteractor: SystemUIDeviceEntryFaceAuthInteractor,
@@ -120,6 +132,12 @@ constructor(

    /** Called upon updates to strong biometric authenticated status. */
    fun onBiometricAuthenticatedStateUpdated(authState: PromptAuthState) {
        logBuffer.log(
            TAG,
            LogLevel.DEBUG,
            { str1 = authState.toString() },
            { "onBiometricAuthenticatedStateUpdated: authState=$str1" },
        )
        _strongBiometricAuthenticationComplete.value = authState.isAuthenticatedAndConfirmed
    }

@@ -129,6 +147,7 @@ constructor(
     * indicating the biometric auth UI is ready for dismissal
     */
    fun onReadyToDismissBiometricAuth() {
        logBuffer.log(TAG, LogLevel.DEBUG, "onReadyToDismissBiometricAuth")
        _isFullyUnlockedAndReadyToDismiss.value = true
    }

@@ -170,7 +189,12 @@ constructor(
    /** Called when biometric authentication is requested for secure lock device. */
    // TODO: call when secure lock device biometric auth is shown
    fun onBiometricAuthRequested() {
        logBuffer.log(TAG, LogLevel.DEBUG, "onBiometricAuthRequested")
        _shouldShowBiometricAuth.value = true
        deviceEntryFaceAuthInteractor.onSecureLockDeviceBiometricAuthRequested()
    }

    companion object {
        private const val TAG = "SecureLockDeviceInteractor"
    }
}
+2 −0
Original line number Diff line number Diff line
@@ -22,12 +22,14 @@ import com.android.systemui.deviceentry.domain.interactor.deviceEntryBiometricSe
import com.android.systemui.deviceentry.domain.interactor.deviceEntryFaceAuthInteractor
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.applicationCoroutineScope
import com.android.systemui.log.logcatLogBuffer
import com.android.systemui.securelockdevice.data.repository.secureLockDeviceRepository

val Kosmos.secureLockDeviceInteractor by
    Kosmos.Fixture {
        SecureLockDeviceInteractor(
            applicationScope = applicationCoroutineScope,
            logBuffer = logcatLogBuffer("SecureLockDeviceLog"),
            secureLockDeviceRepository = secureLockDeviceRepository,
            biometricSettingsInteractor = deviceEntryBiometricSettingsInteractor,
            deviceEntryFaceAuthInteractor = deviceEntryFaceAuthInteractor,