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

Commit 484fdc11 authored by Sherry Zhou's avatar Sherry Zhou
Browse files

Fix Post Boot Regression after migrating stepping animation

Flag: ACONFIG com.android.systemui.migrate_clocks_to_blueprint DEVELOPMENT
Bug: 319556690
Test: v2/android-crystalball-eng/asit/perf/post_boot_perf_test
Change-Id: I18824d4c0c566ec724d2ac1e65bdf0341ca58a40
parent 77400256
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.text.TextUtils
import android.text.format.DateFormat
import android.util.AttributeSet
import android.util.MathUtils.constrainedMap
import android.view.View
import android.widget.TextView
import com.android.app.animation.Interpolators
import com.android.internal.annotations.VisibleForTesting
@@ -51,7 +52,7 @@ class AnimatableClockView @JvmOverloads constructor(
    context: Context,
    attrs: AttributeSet? = null,
    defStyleAttr: Int = 0,
    defStyleRes: Int = 0
    defStyleRes: Int = 0,
) : TextView(context, attrs, defStyleAttr, defStyleRes) {
    // To protect us from issues from this being null while the TextView constructor is running, we
    // implement the get method and ensure a value is returned before initialization is complete.
@@ -61,6 +62,9 @@ class AnimatableClockView @JvmOverloads constructor(
        get() = logger.buffer
        set(value) { logger = Logger(value, TAG) }

    var hasCustomPositionUpdatedAnimation: Boolean = false
    var migratedClocks: Boolean = false

    private val time = Calendar.getInstance()

    private val dozingWeightInternal: Int
@@ -193,9 +197,18 @@ class AnimatableClockView @JvmOverloads constructor(
        } else {
            animator.updateLayout(layout)
        }
        if (migratedClocks && hasCustomPositionUpdatedAnimation) {
            // Expand width to avoid clock being clipped during stepping animation
            setMeasuredDimension(measuredWidth +
                    MeasureSpec.getSize(widthMeasureSpec) / 2, measuredHeight)
        }
    }

    override fun onDraw(canvas: Canvas) {
        if (migratedClocks && hasCustomPositionUpdatedAnimation) {
            canvas.save()
            canvas.translate((parent as View).measuredWidth / 4F, 0F)
        }
        logger.d({ "onDraw($str1)"}) { str1 = text.toString() }
        // Use textAnimator to render text if animation is enabled.
        // Otherwise default to using standard draw functions.
@@ -205,6 +218,9 @@ class AnimatableClockView @JvmOverloads constructor(
        } else {
            super.onDraw(canvas)
        }
        if (migratedClocks && hasCustomPositionUpdatedAnimation) {
            canvas.restore()
        }
    }

    override fun invalidate() {
+2 −0
Original line number Diff line number Diff line
@@ -193,6 +193,8 @@ class DefaultClockController(
            ClockFaceConfig(hasCustomPositionUpdatedAnimation = hasStepClockAnimation)

        init {
            view.migratedClocks = migratedClocks
            view.hasCustomPositionUpdatedAnimation = hasStepClockAnimation
            animations = LargeClockAnimations(view, 0f, 0f)
        }

+1 −5
Original line number Diff line number Diff line
@@ -29,8 +29,4 @@ class KeyguardRootView(
    ConstraintLayout(
        context,
        attrs,
    ) {
    init {
        clipChildren = false
    }
}
    )