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

Commit f3ba5399 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix jank in CUJ_SCREEN_OFF" into udc-dev

parents f479b9c1 f7763a5d
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@ import android.view.WindowManager.fixScale
import com.android.internal.jank.InteractionJankMonitor
import com.android.internal.jank.InteractionJankMonitor.CUJ_SCREEN_OFF
import com.android.internal.jank.InteractionJankMonitor.CUJ_SCREEN_OFF_SHOW_AOD
import com.android.systemui.DejankUtils
import com.android.systemui.animation.Interpolators
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.keyguard.KeyguardViewMediator
@@ -27,6 +28,7 @@ import com.android.systemui.statusbar.notification.PropertyAnimator
import com.android.systemui.statusbar.notification.stack.AnimationProperties
import com.android.systemui.statusbar.notification.stack.StackStateAnimator
import com.android.systemui.statusbar.policy.KeyguardStateController
import com.android.systemui.util.TraceUtils
import com.android.systemui.util.settings.GlobalSettings
import javax.inject.Inject

@@ -116,6 +118,11 @@ class UnlockedScreenOffAnimationController @Inject constructor(
        })
    }

    // FrameCallback used to delay starting the light reveal animation until the next frame
    private val startLightRevealCallback = TraceUtils.namedRunnable("startLightReveal") {
        lightRevealAnimator.start()
    }

    val animatorDurationScaleObserver = object : ContentObserver(null) {
        override fun onChange(selfChange: Boolean) {
            updateAnimatorDurationScale()
@@ -223,6 +230,7 @@ class UnlockedScreenOffAnimationController @Inject constructor(
        decidedToAnimateGoingToSleep = null

        shouldAnimateInKeyguard = false
        DejankUtils.removeCallbacks(startLightRevealCallback)
        lightRevealAnimator.cancel()
        handler.removeCallbacksAndMessages(null)
    }
@@ -253,7 +261,14 @@ class UnlockedScreenOffAnimationController @Inject constructor(

            shouldAnimateInKeyguard = true
            lightRevealAnimationPlaying = true
            lightRevealAnimator.start()

            // Start the animation on the next frame. startAnimation() is called after
            // PhoneWindowManager makes a binder call to System UI on
            // IKeyguardService#onStartedGoingToSleep(). By the time we get here, system_server is
            // already busy making changes to PowerManager and DisplayManager. This increases our
            // chance of missing the first frame, so to mitigate this we should start the animation
            // on the next frame.
            DejankUtils.postAfterTraversal(startLightRevealCallback)
            handler.postDelayed({
                // Only run this callback if the device is sleeping (not interactive). This callback
                // is removed in onStartedWakingUp, but since that event is asynchronously
+12 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.util

import android.os.Trace
import android.os.TraceNameSupplier

/**
 * Run a block within a [Trace] section.
@@ -39,5 +40,16 @@ class TraceUtils {
        inline fun traceRunnable(tag: String, crossinline block: () -> Unit): Runnable {
            return Runnable { traceSection(tag) { block() } }
        }

        /**
         * Helper function for creating a Runnable object that implements TraceNameSupplier.
         * This is useful for posting Runnables to Handlers with meaningful names.
         */
        inline fun namedRunnable(tag: String, crossinline block: () -> Unit): Runnable {
            return object : Runnable, TraceNameSupplier {
                override fun getTraceName(): String = tag
                override fun run() = block()
            }
        }
    }
}