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

Commit bc0bb2c0 authored by Matt Pietal's avatar Matt Pietal
Browse files

Add coroutine names for tracing

Also, shutoff ClockEventController registrations from clock
switch when flag is on. This was noticed in the traces.

Bug: 331748021
Test: Take traces
Flag: ACONFIG com.android.systemui.migrate_clocks_to_blueprint
TEAMFOOD

Change-Id: If25d3a0e04aa0b73a4db29139da6f34814163835
parent 10504c50
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -250,7 +250,6 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
            mLargeClockFrame = mView.findViewById(R.id.lockscreen_clock_view_large);
        }


        if (!mOnlyClock) {
            mDumpManager.unregisterDumpable(getClass().getSimpleName()); // unregister previous
            mDumpManager.registerDumpable(getClass().getSimpleName(), this);
@@ -282,7 +281,9 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
    protected void onViewAttached() {
        mClockRegistry.registerClockChangeListener(mClockChangedListener);
        setClock(mClockRegistry.createCurrentClock());
        if (!MigrateClocksToBlueprint.isEnabled()) {
            mClockEventController.registerListeners(mView);
        }
        mKeyguardSmallClockTopMargin =
                mView.getResources().getDimensionPixelSize(R.dimen.keyguard_clock_top_margin);
        mKeyguardLargeClockTopMargin =
@@ -365,7 +366,9 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
    @Override
    protected void onViewDetached() {
        mClockRegistry.unregisterClockChangeListener(mClockChangedListener);
        if (!MigrateClocksToBlueprint.isEnabled()) {
            mClockEventController.unregisterListeners();
        }
        setClock(null);

        mBgExecutor.execute(() -> {
+2 −2
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.animation.ValueAnimator.AnimatorUpdateListener
import android.annotation.FloatRange
import android.os.Trace
import android.util.Log
import com.android.app.tracing.coroutines.withContext
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.keyguard.shared.model.KeyguardState
@@ -41,7 +42,6 @@ import kotlinx.coroutines.flow.asSharedFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.withContext

/**
 * The source of truth for all keyguard transitions.
@@ -150,7 +150,7 @@ constructor(
        _currentTransitionInfo.value = info

        // Animators must be started on the main thread.
        return withContext(mainDispatcher) {
        return withContext("$TAG#startTransition", mainDispatcher) {
            if (lastStep.from == info.from && lastStep.to == info.to) {
                Log.i(TAG, "Duplicate call to start the transition, rejecting: $info")
                return@withContext null
+7 −7
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.systemui.keyguard.domain.interactor

import android.animation.ValueAnimator
import com.android.app.animation.Interpolators
import com.android.app.tracing.coroutines.launch
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.dagger.qualifiers.Main
@@ -33,7 +34,6 @@ import kotlin.time.Duration.Companion.milliseconds
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.debounce
import kotlinx.coroutines.launch

@SysUISingleton
class FromAodTransitionInteractor
@@ -72,7 +72,7 @@ constructor(
        // Use PowerInteractor's wakefulness, which is the earliest wake signal available. We
        // have all of the information we need at this time to make a decision about where to
        // transition.
        scope.launch {
        scope.launch("$TAG#listenForAodToAwake") {
            powerInteractor.detailedWakefulness
                .filterRelevantKeyguardStateAnd { wakefulness -> wakefulness.isAwake() }
                .sample(
@@ -150,7 +150,7 @@ constructor(
            return
        }

        scope.launch {
        scope.launch("$TAG#listenForAodToOccluded") {
            keyguardInteractor.isKeyguardOccluded
                .filterRelevantKeyguardStateAnd { isOccluded -> isOccluded }
                .collect {
@@ -168,7 +168,7 @@ constructor(
     * PRIMARY_BOUNCER.
     */
    private fun listenForAodToPrimaryBouncer() {
        scope.launch {
        scope.launch("$TAG#listenForAodToPrimaryBouncer") {
            keyguardInteractor.primaryBouncerShowing
                .filterRelevantKeyguardStateAnd { primaryBouncerShowing -> primaryBouncerShowing }
                .collect { startTransitionTo(KeyguardState.PRIMARY_BOUNCER) }
@@ -181,7 +181,7 @@ constructor(
            return
        }

        scope.launch {
        scope.launch("$TAG#listenForAodToGone") {
            powerInteractor.isAwake
                .debounce(50L)
                .filterRelevantKeyguardState()
@@ -209,7 +209,7 @@ constructor(
     * AOD.
     */
    fun dismissAod() {
        scope.launch { startTransitionTo(KeyguardState.GONE) }
        scope.launch("$TAG#dismissAod") { startTransitionTo(KeyguardState.GONE) }
    }

    override fun getDefaultAnimatorForTransitionsToState(toState: KeyguardState): ValueAnimator {
@@ -224,7 +224,7 @@ constructor(
    }

    companion object {
        const val TAG = "FromAodTransitionInteractor"
        private const val TAG = "FromAodTransitionInteractor"
        private val DEFAULT_DURATION = 500.milliseconds
        val TO_LOCKSCREEN_DURATION = 500.milliseconds
        val TO_GONE_DURATION = DEFAULT_DURATION
+8 −6
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.systemui.keyguard.domain.interactor

import android.animation.ValueAnimator
import com.android.app.animation.Interpolators
import com.android.app.tracing.coroutines.launch
import com.android.systemui.communal.domain.interactor.CommunalInteractor
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Background
@@ -68,13 +69,13 @@ constructor(
    }

    fun showKeyguard() {
        scope.launch { startTransitionTo(KeyguardState.LOCKSCREEN) }
        scope.launch("$TAG#showKeyguard") { startTransitionTo(KeyguardState.LOCKSCREEN) }
    }

    // Primarily for when the user chooses to lock down the device
    private fun listenForGoneToLockscreenOrHub() {
        if (KeyguardWmStateRefactor.isEnabled) {
            scope.launch {
            scope.launch("$TAG#listenForGoneToLockscreenOrHub") {
                biometricSettingsRepository.isCurrentUserInLockdown
                    .distinctUntilChanged()
                    .filterRelevantKeyguardStateAnd { inLockdown -> inLockdown }
@@ -90,7 +91,7 @@ constructor(
                    }
            }
        } else {
            scope.launch {
            scope.launch("$TAG#listenForGoneToLockscreenOrHub") {
                keyguardInteractor.isKeyguardShowing
                    .filterRelevantKeyguardStateAnd { isKeyguardShowing -> isKeyguardShowing }
                    .sample(communalInteractor.isIdleOnCommunal, ::Pair)
@@ -108,7 +109,7 @@ constructor(
    }

    private fun listenForGoneToDreamingLockscreenHosted() {
        scope.launch {
        scope.launch("$TAG#listenForGoneToDreamingLockscreenHosted") {
            keyguardInteractor.isActiveDreamLockscreenHosted
                .filterRelevantKeyguardStateAnd { isActiveDreamLockscreenHosted ->
                    isActiveDreamLockscreenHosted
@@ -118,7 +119,7 @@ constructor(
    }

    private fun listenForGoneToDreaming() {
        scope.launch {
        scope.launch("$TAG#listenForGoneToDreaming") {
            keyguardInteractor.isAbleToDream
                .sample(keyguardInteractor.isActiveDreamLockscreenHosted, ::Pair)
                .filterRelevantKeyguardStateAnd { (isAbleToDream, isActiveDreamLockscreenHosted) ->
@@ -129,7 +130,7 @@ constructor(
    }

    private fun listenForGoneToAodOrDozing() {
        scope.launch {
        scope.launch("$TAG#listenForGoneToAodOrDozing") {
            listenForSleepTransition(
                modeOnCanceledFromStartedStep = { TransitionModeOnCanceled.RESET },
            )
@@ -151,6 +152,7 @@ constructor(
    }

    companion object {
        private const val TAG = "FromGoneTransitionInteractor"
        private val DEFAULT_DURATION = 500.milliseconds
        val TO_DREAMING_DURATION = 933.milliseconds
        val TO_AOD_DURATION = 1300.milliseconds
+12 −11
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.systemui.keyguard.domain.interactor
import android.animation.ValueAnimator
import android.util.MathUtils
import com.android.app.animation.Interpolators
import com.android.app.tracing.coroutines.launch
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.dagger.qualifiers.Main
@@ -119,7 +120,7 @@ constructor(
        }

        val invalidFromStates = setOf(KeyguardState.AOD, KeyguardState.DOZING)
        scope.launch {
        scope.launch("$TAG#listenForLockscreenToDreaming") {
            keyguardInteractor.isAbleToDream
                .filterRelevantKeyguardState()
                .sampleCombine(
@@ -149,7 +150,7 @@ constructor(
    }

    private fun listenForLockscreenToPrimaryBouncer() {
        scope.launch {
        scope.launch("$TAG#listenForLockscreenToPrimaryBouncer") {
            keyguardInteractor.primaryBouncerShowing
                .filterRelevantKeyguardStateAnd { isBouncerShowing -> isBouncerShowing }
                .collect {
@@ -162,7 +163,7 @@ constructor(
    }

    private fun listenForLockscreenToAlternateBouncer() {
        scope.launch {
        scope.launch("$TAG#listenForLockscreenToAlternateBouncer") {
            keyguardInteractor.alternateBouncerShowing
                .filterRelevantKeyguardStateAnd { isAlternateBouncerShowing ->
                    isAlternateBouncerShowing
@@ -174,7 +175,7 @@ constructor(
    /* Starts transitions when manually dragging up the bouncer from the lockscreen. */
    private fun listenForLockscreenToPrimaryBouncerDragging() {
        var transitionId: UUID? = null
        scope.launch {
        scope.launch("$TAG#listenForLockscreenToPrimaryBouncerDragging") {
            shadeRepository.legacyShadeExpansion
                .sampleCombine(
                    startedKeyguardTransitionStep,
@@ -258,7 +259,7 @@ constructor(
    }

    fun dismissKeyguard() {
        scope.launch { startTransitionTo(KeyguardState.GONE) }
        scope.launch("$TAG#dismissKeyguard") { startTransitionTo(KeyguardState.GONE) }
    }

    private fun listenForLockscreenToGone() {
@@ -266,7 +267,7 @@ constructor(
            return
        }

        scope.launch {
        scope.launch("$TAG#listenForLockscreenToGone") {
            keyguardInteractor.isKeyguardGoingAway
                .filterRelevantKeyguardStateAnd { isKeyguardGoingAway -> isKeyguardGoingAway }
                .collect {
@@ -281,7 +282,7 @@ constructor(
    private fun listenForLockscreenToGoneDragging() {
        if (KeyguardWmStateRefactor.isEnabled) {
            // When the refactor is enabled, we no longer use isKeyguardGoingAway.
            scope.launch {
            scope.launch("$TAG#listenForLockscreenToGoneDragging") {
                swipeToDismissInteractor.dismissFling
                    .filterNotNull()
                    .filterRelevantKeyguardState()
@@ -292,7 +293,7 @@ constructor(

    private fun listenForLockscreenToOccludedOrDreaming() {
        if (KeyguardWmStateRefactor.isEnabled) {
            scope.launch {
            scope.launch("$TAG#listenForLockscreenToOccludedOrDreaming") {
                keyguardOcclusionInteractor.showWhenLockedActivityInfo
                    .filterRelevantKeyguardStateAnd { it.isOnTop }
                    .collect { taskInfo ->
@@ -306,7 +307,7 @@ constructor(
                    }
            }
        } else {
            scope.launch {
            scope.launch("$TAG#listenForLockscreenToOccludedOrDreaming") {
                keyguardInteractor.isKeyguardOccluded
                    .filterRelevantKeyguardStateAnd { isOccluded -> isOccluded }
                    .collect { startTransitionTo(KeyguardState.OCCLUDED) }
@@ -315,7 +316,7 @@ constructor(
    }

    private fun listenForLockscreenToAodOrDozing() {
        scope.launch {
        scope.launch("$TAG#listenForLockscreenToAodOrDozing") {
            listenForSleepTransition(
                modeOnCanceledFromStartedStep = { startedStep ->
                    if (
@@ -367,7 +368,7 @@ constructor(
    }

    companion object {
        const val TAG = "FromLockscreenTransitionInteractor"
        private const val TAG = "FromLockscreenTransitionInteractor"
        private val DEFAULT_DURATION = 400.milliseconds
        val TO_DOZING_DURATION = 500.milliseconds
        val TO_DREAMING_DURATION = 933.milliseconds
Loading