From d9817f4eb7ca62e7654cd174f7ac9e459cdb48e9 Mon Sep 17 00:00:00 2001 From: Andreas Miko Date: Mon, 13 Nov 2023 14:55:14 +0100 Subject: Move KeyguardTransitionRepository logging Transition logs are stable and very useful for debugging many scenarios and therefore should appear in standard logcat which is also easy to access in bugreports Test: NONE Bug: b/310906083 Flag: NONE Change-Id: I86db5d051cbff90f3cbb8acb91da6b8e256e6fba --- .../repository/KeyguardTransitionRepository.kt | 36 +++++++++++----------- .../interactor/KeyguardTransitionAuditLogger.kt | 18 ----------- 2 files changed, 18 insertions(+), 36 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardTransitionRepository.kt b/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardTransitionRepository.kt index 8d5d73f88ca1..5c76be80f1ad 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardTransitionRepository.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardTransitionRepository.kt @@ -49,8 +49,10 @@ import kotlinx.coroutines.flow.filter * [TransitionInteractor]. These interactors will call [startTransition] and [updateTransition] on * this repository. * - * To print all transitions to logcat to help with debugging, run this command: adb shell settings - * put global systemui/buffer/KeyguardLog VERBOSE + * To print all transitions to logcat to help with debugging, run this command: + * ``` + * adb shell cmd statusbar echo -b KeyguardLog:VERBOSE + * ``` * * This will print all keyguard transitions to logcat with the KeyguardTransitionAuditLogger tag. */ @@ -175,9 +177,11 @@ class KeyguardTransitionRepositoryImpl @Inject constructor() : KeyguardTransitio override fun onAnimationStart(animation: Animator) { emitTransition(TransitionStep(info, startingValue, TransitionState.STARTED)) } + override fun onAnimationCancel(animation: Animator) { endAnimation(lastStep.value, TransitionState.CANCELED) } + override fun onAnimationEnd(animation: Animator) { endAnimation(1f, TransitionState.FINISHED) } @@ -222,7 +226,7 @@ class KeyguardTransitionRepositoryImpl @Inject constructor() : KeyguardTransitio } private fun emitTransition(nextStep: TransitionStep, isManual: Boolean = false) { - trace(nextStep, isManual) + logAndTrace(nextStep, isManual) val emitted = _transitions.tryEmit(nextStep) if (!emitted) { Log.w(TAG, "Failed to emit next value without suspending") @@ -230,26 +234,22 @@ class KeyguardTransitionRepositoryImpl @Inject constructor() : KeyguardTransitio lastStep = nextStep } - private fun trace(step: TransitionStep, isManual: Boolean) { + private fun logAndTrace(step: TransitionStep, isManual: Boolean) { if (step.transitionState == TransitionState.RUNNING) { return } - val traceName = - "Transition: ${step.from} -> ${step.to} " + - if (isManual) { - "(manual)" - } else { - "" - } + val manualStr = if (isManual) " (manual)" else "" + val traceName = "Transition: ${step.from} -> ${step.to}$manualStr" + val traceCookie = traceName.hashCode() - if (step.transitionState == TransitionState.STARTED) { - Trace.beginAsyncSection(traceName, traceCookie) - } else if ( - step.transitionState == TransitionState.FINISHED || - step.transitionState == TransitionState.CANCELED - ) { - Trace.endAsyncSection(traceName, traceCookie) + when (step.transitionState) { + TransitionState.STARTED -> Trace.beginAsyncSection(traceName, traceCookie) + TransitionState.FINISHED -> Trace.endAsyncSection(traceName, traceCookie) + TransitionState.CANCELED -> Trace.endAsyncSection(traceName, traceCookie) + else -> {} } + + Log.i(TAG, "${step.transitionState.name} transition: $step$manualStr") } companion object { diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionAuditLogger.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionAuditLogger.kt index 419524fe7730..a03fa38ec850 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionAuditLogger.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionAuditLogger.kt @@ -74,24 +74,6 @@ constructor( } } - scope.launch { - interactor.finishedKeyguardTransitionStep.collect { - logger.log(TAG, VERBOSE, "Finished transition", it) - } - } - - scope.launch { - interactor.canceledKeyguardTransitionStep.collect { - logger.log(TAG, VERBOSE, "Canceled transition", it) - } - } - - scope.launch { - interactor.startedKeyguardTransitionStep.collect { - logger.log(TAG, VERBOSE, "Started transition", it) - } - } - scope.launch { keyguardInteractor.dozeTransitionModel.collect { logger.log(TAG, VERBOSE, "Doze transition", it) -- cgit v1.2.3-59-g8ed1b