Transitions - add tracing
Add sync tracing that includes the name of the 'to' and 'from' states Bug: 195430376 Test: Take trace and view in perfetto Change-Id: I3bc15180edf64ff57bb59d382875a4bc35764689
This commit is contained in:
@@ -20,6 +20,7 @@ import android.animation.AnimatorListenerAdapter
|
||||
import android.animation.ValueAnimator
|
||||
import android.animation.ValueAnimator.AnimatorUpdateListener
|
||||
import android.annotation.FloatRange
|
||||
import android.os.Trace
|
||||
import android.util.Log
|
||||
import com.android.systemui.dagger.SysUISingleton
|
||||
import com.android.systemui.keyguard.shared.model.KeyguardState
|
||||
@@ -157,12 +158,36 @@ class KeyguardTransitionRepository @Inject constructor() {
|
||||
value: Float,
|
||||
transitionState: TransitionState
|
||||
) {
|
||||
trace(info, transitionState)
|
||||
|
||||
if (transitionState == TransitionState.FINISHED) {
|
||||
currentTransitionInfo = null
|
||||
}
|
||||
_transitions.value = TransitionStep(info.from, info.to, value, transitionState)
|
||||
}
|
||||
|
||||
private fun trace(info: TransitionInfo, transitionState: TransitionState) {
|
||||
if (
|
||||
transitionState != TransitionState.STARTED &&
|
||||
transitionState != TransitionState.FINISHED
|
||||
) {
|
||||
return
|
||||
}
|
||||
val traceName =
|
||||
"Transition: ${info.from} -> ${info.to} " +
|
||||
if (info.animator == null) {
|
||||
"(manual)"
|
||||
} else {
|
||||
""
|
||||
}
|
||||
val traceCookie = traceName.hashCode()
|
||||
if (transitionState == TransitionState.STARTED) {
|
||||
Trace.beginAsyncSection(traceName, traceCookie)
|
||||
} else if (transitionState == TransitionState.FINISHED) {
|
||||
Trace.endAsyncSection(traceName, traceCookie)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val TAG = "KeyguardTransitionRepository"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user