1 /* 2 * Copyright (C) 2022 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.keyguard.logging.KeyguardLogger 20 import com.android.systemui.dagger.SysUISingleton 21 import com.android.systemui.dagger.qualifiers.Application 22 import com.android.systemui.plugins.log.LogLevel.VERBOSE 23 import javax.inject.Inject 24 import kotlinx.coroutines.CoroutineScope 25 import kotlinx.coroutines.launch 26 27 private val TAG = KeyguardTransitionAuditLogger::class.simpleName!! 28 29 /** Collect flows of interest for auditing keyguard transitions. */ 30 @SysUISingleton 31 class KeyguardTransitionAuditLogger 32 @Inject 33 constructor( 34 @Application private val scope: CoroutineScope, 35 private val interactor: KeyguardTransitionInteractor, 36 private val keyguardInteractor: KeyguardInteractor, 37 private val logger: KeyguardLogger, 38 ) { 39 startnull40 fun start() { 41 scope.launch { 42 keyguardInteractor.wakefulnessModel.collect { 43 logger.log(TAG, VERBOSE, "WakefulnessModel", it) 44 } 45 } 46 47 scope.launch { 48 keyguardInteractor.primaryBouncerShowing.collect { 49 logger.log(TAG, VERBOSE, "Primary bouncer showing", it) 50 } 51 } 52 53 scope.launch { 54 keyguardInteractor.alternateBouncerShowing.collect { 55 logger.log(TAG, VERBOSE, "Alternate bouncer showing", it) 56 } 57 } 58 59 scope.launch { 60 keyguardInteractor.isDozing.collect { logger.log(TAG, VERBOSE, "isDozing", it) } 61 } 62 63 scope.launch { 64 keyguardInteractor.isAbleToDream.collect { 65 logger.log(TAG, VERBOSE, "isAbleToDream", it) 66 } 67 } 68 69 scope.launch { 70 keyguardInteractor.isKeyguardOccluded.collect { 71 logger.log(TAG, VERBOSE, "isOccluded", it) 72 } 73 } 74 75 scope.launch { 76 interactor.finishedKeyguardTransitionStep.collect { 77 logger.log(TAG, VERBOSE, "Finished transition", it) 78 } 79 } 80 81 scope.launch { 82 interactor.canceledKeyguardTransitionStep.collect { 83 logger.log(TAG, VERBOSE, "Canceled transition", it) 84 } 85 } 86 87 scope.launch { 88 interactor.startedKeyguardTransitionStep.collect { 89 logger.log(TAG, VERBOSE, "Started transition", it) 90 } 91 } 92 93 scope.launch { 94 keyguardInteractor.dozeTransitionModel.collect { 95 logger.log(TAG, VERBOSE, "Doze transition", it) 96 } 97 } 98 } 99 } 100