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

Commit 0e3670ae authored by Chandru S's avatar Chandru S
Browse files

Add additional logging for state that bouncer messages rely on

Bug: 305044151
Bug: 323084862
Bug: 323301830
Test: manually, everything builds, checked the logs to make sure the state changes are logged
Flag: NONE additional logging
Change-Id: Iee8df0161c3b09c94e9f9799963e5bd2318835ea
parent e31362de
Loading
Loading
Loading
Loading
+33 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 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.bouncer.dagger

import com.android.systemui.CoreStartable
import com.android.systemui.bouncer.log.BouncerLoggerStartable
import dagger.Binds
import dagger.Module
import dagger.multibindings.ClassKey
import dagger.multibindings.IntoMap

@Module
interface BouncerLoggerModule {

    @Binds
    @IntoMap
    @ClassKey(BouncerLoggerStartable::class)
    fun bindBouncerLoggerStartable(impl: BouncerLoggerStartable): CoreStartable
}
+81 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 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.bouncer.log

import android.os.Build
import com.android.systemui.CoreStartable
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.deviceentry.domain.interactor.DeviceEntryBiometricSettingsInteractor
import com.android.systemui.deviceentry.domain.interactor.DeviceEntryFaceAuthInteractor
import com.android.systemui.deviceentry.domain.interactor.DeviceEntryFingerprintAuthInteractor
import com.android.systemui.log.BouncerLogger
import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.launch

/** Startable that logs the flows that bouncer depends on. */
@OptIn(ExperimentalCoroutinesApi::class)
class BouncerLoggerStartable
@Inject
constructor(
    @Application private val applicationScope: CoroutineScope,
    private val biometricSettingsInteractor: DeviceEntryBiometricSettingsInteractor,
    private val faceAuthInteractor: DeviceEntryFaceAuthInteractor,
    private val fingerprintAuthInteractor: DeviceEntryFingerprintAuthInteractor,
    private val bouncerLogger: BouncerLogger,
) : CoreStartable {
    override fun start() {
        if (!Build.isDebuggable()) {
            return
        }
        applicationScope.launch {
            biometricSettingsInteractor.isFaceAuthEnrolledAndEnabled.collectLatest { newValue ->
                bouncerLogger.interestedStateChanged("isFaceAuthEnrolledAndEnabled", newValue)
            }
        }
        applicationScope.launch {
            biometricSettingsInteractor.isFingerprintAuthEnrolledAndEnabled.collectLatest { newValue
                ->
                bouncerLogger.interestedStateChanged(
                    "isFingerprintAuthEnrolledAndEnabled",
                    newValue
                )
            }
        }
        applicationScope.launch {
            faceAuthInteractor.isLockedOut.collectLatest { newValue ->
                bouncerLogger.interestedStateChanged("faceAuthLockedOut", newValue)
            }
        }
        applicationScope.launch {
            fingerprintAuthInteractor.isLockedOut.collectLatest { newValue ->
                bouncerLogger.interestedStateChanged("fingerprintLockedOut", newValue)
            }
        }
        applicationScope.launch {
            fingerprintAuthInteractor.isFingerprintCurrentlyAllowedOnBouncer.collectLatest {
                newValue ->
                bouncerLogger.interestedStateChanged(
                    "fingerprintCurrentlyAllowedOnBouncer",
                    newValue
                )
            }
        }
    }
}
+2 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import com.android.keyguard.dagger.KeyguardUserSwitcherComponent;
import com.android.keyguard.mediator.ScreenOnCoordinator;
import com.android.systemui.CoreStartable;
import com.android.systemui.animation.ActivityTransitionAnimator;
import com.android.systemui.bouncer.dagger.BouncerLoggerModule;
import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.classifier.FalsingCollector;
import com.android.systemui.classifier.FalsingModule;
@@ -113,6 +114,7 @@ import java.util.concurrent.Executor;
            KeyguardDisplayModule.class,
            StartKeyguardTransitionModule.class,
            ResourceTrimmerModule.class,
            BouncerLoggerModule.class,
        })
public interface KeyguardModule {
    /**
+12 −0
Original line number Diff line number Diff line
@@ -60,4 +60,16 @@ class BouncerLogger @Inject constructor(@BouncerLog private val buffer: LogBuffe
    fun bindingBouncerMessageView() {
        buffer.log(TAG, LogLevel.DEBUG, "Binding BouncerMessageView")
    }

    fun interestedStateChanged(whatChanged: String, newValue: Boolean) {
        buffer.log(
            TAG,
            LogLevel.DEBUG,
            {
                str1 = whatChanged
                bool1 = newValue
            },
            { "state changed: $str1: $bool1" }
        )
    }
}