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.app.tracing.coroutines.launchTraced as launch 20 import com.android.keyguard.logging.KeyguardLogger 21 import com.android.systemui.dagger.SysUISingleton 22 import com.android.systemui.dagger.qualifiers.Background 23 import com.android.systemui.deviceentry.domain.interactor.DeviceEntryInteractor 24 import com.android.systemui.keyguard.ui.viewmodel.AodBurnInViewModel 25 import com.android.systemui.keyguard.ui.viewmodel.KeyguardRootViewModel 26 import com.android.systemui.log.core.LogLevel.VERBOSE 27 import com.android.systemui.power.domain.interactor.PowerInteractor 28 import com.android.systemui.scene.shared.flag.SceneContainerFlag 29 import com.android.systemui.shade.domain.interactor.ShadeInteractor 30 import com.android.systemui.statusbar.notification.stack.ui.viewmodel.SharedNotificationContainerViewModel 31 import javax.inject.Inject 32 import kotlinx.coroutines.CoroutineScope 33 import kotlinx.coroutines.FlowPreview 34 import kotlinx.coroutines.flow.debounce 35 36 private val TAG = KeyguardTransitionAuditLogger::class.simpleName!! 37 38 /** Collect flows of interest for auditing keyguard transitions. */ 39 @SysUISingleton 40 class KeyguardTransitionAuditLogger 41 @Inject 42 constructor( 43 @Background private val scope: CoroutineScope, 44 private val interactor: KeyguardTransitionInteractor, 45 private val keyguardInteractor: KeyguardInteractor, 46 private val logger: KeyguardLogger, 47 private val powerInteractor: PowerInteractor, 48 private val sharedNotificationContainerViewModel: SharedNotificationContainerViewModel, 49 private val keyguardRootViewModel: KeyguardRootViewModel, 50 private val aodBurnInViewModel: AodBurnInViewModel, 51 private val shadeInteractor: ShadeInteractor, 52 private val keyguardOcclusionInteractor: KeyguardOcclusionInteractor, 53 private val deviceEntryInteractor: DeviceEntryInteractor, 54 ) { 55 56 @OptIn(FlowPreview::class) startnull57 fun start() { 58 scope.launch { 59 powerInteractor.detailedWakefulness.collect { 60 logger.log(TAG, VERBOSE, "WakefulnessModel", it) 61 } 62 } 63 64 scope.launch { 65 sharedNotificationContainerViewModel.isOnLockscreen.collect { 66 logger.log(TAG, VERBOSE, "Notif: isOnLockscreen", it) 67 } 68 } 69 70 scope.launch { 71 shadeInteractor.isUserInteracting.collect { 72 logger.log(TAG, VERBOSE, "Shade: isUserInteracting", it) 73 } 74 } 75 76 if (!SceneContainerFlag.isEnabled) { 77 scope.launch { 78 sharedNotificationContainerViewModel.bounds.debounce(20L).collect { 79 logger.log(TAG, VERBOSE, "Notif: bounds (debounced)", it) 80 } 81 } 82 } 83 84 scope.launch { 85 sharedNotificationContainerViewModel.isOnLockscreenWithoutShade.collect { 86 logger.log(TAG, VERBOSE, "Notif: isOnLockscreenWithoutShade", it) 87 } 88 } 89 90 scope.launch { 91 deviceEntryInteractor.isUnlocked.collect { 92 logger.log(TAG, VERBOSE, "DeviceEntry isUnlocked", it) 93 } 94 } 95 96 scope.launch { 97 deviceEntryInteractor.isLockscreenEnabled.collect { 98 logger.log(TAG, VERBOSE, "DeviceEntry isLockscreenEnabled", it) 99 } 100 } 101 102 scope.launch { 103 keyguardInteractor.primaryBouncerShowing.collect { 104 logger.log(TAG, VERBOSE, "Primary bouncer showing", it) 105 } 106 } 107 108 scope.launch { 109 keyguardInteractor.alternateBouncerShowing.collect { 110 logger.log(TAG, VERBOSE, "Alternate bouncer showing", it) 111 } 112 } 113 114 scope.launch { 115 keyguardInteractor.isDozing.collect { logger.log(TAG, VERBOSE, "isDozing", it) } 116 } 117 118 scope.launch { 119 keyguardInteractor.isDreaming.collect { logger.log(TAG, VERBOSE, "isDreaming", it) } 120 } 121 122 scope.launch { 123 keyguardInteractor.isDreamingWithOverlay.collect { 124 logger.log(TAG, VERBOSE, "isDreamingWithOverlay", it) 125 } 126 } 127 128 scope.launch { 129 keyguardInteractor.isAbleToDream.collect { 130 logger.log(TAG, VERBOSE, "isAbleToDream", it) 131 } 132 } 133 134 scope.launch { 135 keyguardInteractor.isKeyguardGoingAway.collect { 136 logger.log(TAG, VERBOSE, "isKeyguardGoingAway", it) 137 } 138 } 139 140 scope.launch { 141 keyguardInteractor.isKeyguardOccluded.collect { 142 logger.log(TAG, VERBOSE, "isOccluded", it) 143 } 144 } 145 146 scope.launch { 147 keyguardInteractor.keyguardTranslationY.collect { 148 logger.log(TAG, VERBOSE, "keyguardTranslationY", it) 149 } 150 } 151 152 scope.launch { 153 aodBurnInViewModel.movement.debounce(20L).collect { 154 logger.log(TAG, VERBOSE, "BurnInModel (debounced)", it) 155 } 156 } 157 158 scope.launch { 159 keyguardInteractor.isKeyguardDismissible.collect { 160 logger.log(TAG, VERBOSE, "isDismissible", it) 161 } 162 } 163 164 scope.launch { 165 keyguardInteractor.isKeyguardShowing.collect { 166 logger.log(TAG, VERBOSE, "isShowing", it) 167 } 168 } 169 170 scope.launch { 171 keyguardInteractor.dozeTransitionModel.collect { 172 logger.log(TAG, VERBOSE, "Doze transition", it) 173 } 174 } 175 176 scope.launch { 177 keyguardInteractor.onCameraLaunchDetected.collect { 178 logger.log(TAG, VERBOSE, "onCameraLaunchDetected", it) 179 } 180 } 181 182 scope.launch { 183 keyguardOcclusionInteractor.showWhenLockedActivityInfo.collect { 184 logger.log(TAG, VERBOSE, "showWhenLockedActivityInfo", it) 185 } 186 } 187 } 188 } 189