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

Commit b6fe5484 authored by Hawkwood Glazier's avatar Hawkwood Glazier Committed by Android (Google) Code Review
Browse files

Merge "Update LogBuffer pattern in some keyguard code" into tm-qpr-dev

parents 6162cc7f ead1a2a0
Loading
Loading
Loading
Loading
+18 −18
Original line number Diff line number Diff line
@@ -54,7 +54,6 @@ class AnimatableClockView @JvmOverloads constructor(
    defStyleAttr: Int = 0,
    defStyleRes: Int = 0
) : TextView(context, attrs, defStyleAttr, defStyleRes) {
    var tag: String = "UnnamedClockView"
    var logBuffer: LogBuffer? = null

    private val time = Calendar.getInstance()
@@ -132,7 +131,7 @@ class AnimatableClockView @JvmOverloads constructor(

    override fun onAttachedToWindow() {
        super.onAttachedToWindow()
        logBuffer?.log(tag, DEBUG, "onAttachedToWindow")
        logBuffer?.log(TAG, DEBUG, "onAttachedToWindow")
        refreshFormat()
    }

@@ -148,7 +147,7 @@ class AnimatableClockView @JvmOverloads constructor(
        time.timeInMillis = timeOverrideInMillis ?: System.currentTimeMillis()
        contentDescription = DateFormat.format(descFormat, time)
        val formattedText = DateFormat.format(format, time)
        logBuffer?.log(tag, DEBUG,
        logBuffer?.log(TAG, DEBUG,
                { str1 = formattedText?.toString() },
                { "refreshTime: new formattedText=$str1" }
        )
@@ -157,7 +156,7 @@ class AnimatableClockView @JvmOverloads constructor(
        // relayout if the text didn't actually change.
        if (!TextUtils.equals(text, formattedText)) {
            text = formattedText
            logBuffer?.log(tag, DEBUG,
            logBuffer?.log(TAG, DEBUG,
                    { str1 = formattedText?.toString() },
                    { "refreshTime: done setting new time text to: $str1" }
            )
@@ -167,17 +166,17 @@ class AnimatableClockView @JvmOverloads constructor(
            // without being notified TextInterpolator being notified.
            if (layout != null) {
                textAnimator?.updateLayout(layout)
                logBuffer?.log(tag, DEBUG, "refreshTime: done updating textAnimator layout")
                logBuffer?.log(TAG, DEBUG, "refreshTime: done updating textAnimator layout")
            }
            requestLayout()
            logBuffer?.log(tag, DEBUG, "refreshTime: after requestLayout")
            logBuffer?.log(TAG, DEBUG, "refreshTime: after requestLayout")
        }
    }

    fun onTimeZoneChanged(timeZone: TimeZone?) {
        time.timeZone = timeZone
        refreshFormat()
        logBuffer?.log(tag, DEBUG,
        logBuffer?.log(TAG, DEBUG,
                { str1 = timeZone?.toString() },
                { "onTimeZoneChanged newTimeZone=$str1" }
        )
@@ -194,7 +193,7 @@ class AnimatableClockView @JvmOverloads constructor(
        } else {
            animator.updateLayout(layout)
        }
        logBuffer?.log(tag, DEBUG, "onMeasure")
        logBuffer?.log(TAG, DEBUG, "onMeasure")
    }

    override fun onDraw(canvas: Canvas) {
@@ -206,12 +205,12 @@ class AnimatableClockView @JvmOverloads constructor(
        } else {
            super.onDraw(canvas)
        }
        logBuffer?.log(tag, DEBUG, "onDraw lastDraw")
        logBuffer?.log(TAG, DEBUG, "onDraw")
    }

    override fun invalidate() {
        super.invalidate()
        logBuffer?.log(tag, DEBUG, "invalidate")
        logBuffer?.log(TAG, DEBUG, "invalidate")
    }

    override fun onTextChanged(
@@ -221,7 +220,7 @@ class AnimatableClockView @JvmOverloads constructor(
            lengthAfter: Int
    ) {
        super.onTextChanged(text, start, lengthBefore, lengthAfter)
        logBuffer?.log(tag, DEBUG,
        logBuffer?.log(TAG, DEBUG,
                { str1 = text.toString() },
                { "onTextChanged text=$str1" }
        )
@@ -238,7 +237,7 @@ class AnimatableClockView @JvmOverloads constructor(
    }

    fun animateColorChange() {
        logBuffer?.log(tag, DEBUG, "animateColorChange")
        logBuffer?.log(TAG, DEBUG, "animateColorChange")
        setTextStyle(
            weight = lockScreenWeight,
            textSize = -1f,
@@ -260,7 +259,7 @@ class AnimatableClockView @JvmOverloads constructor(
    }

    fun animateAppearOnLockscreen() {
        logBuffer?.log(tag, DEBUG, "animateAppearOnLockscreen")
        logBuffer?.log(TAG, DEBUG, "animateAppearOnLockscreen")
        setTextStyle(
            weight = dozingWeight,
            textSize = -1f,
@@ -285,7 +284,7 @@ class AnimatableClockView @JvmOverloads constructor(
        if (isAnimationEnabled && textAnimator == null) {
            return
        }
        logBuffer?.log(tag, DEBUG, "animateFoldAppear")
        logBuffer?.log(TAG, DEBUG, "animateFoldAppear")
        setTextStyle(
            weight = lockScreenWeightInternal,
            textSize = -1f,
@@ -312,7 +311,7 @@ class AnimatableClockView @JvmOverloads constructor(
            // Skip charge animation if dozing animation is already playing.
            return
        }
        logBuffer?.log(tag, DEBUG, "animateCharge")
        logBuffer?.log(TAG, DEBUG, "animateCharge")
        val startAnimPhase2 = Runnable {
            setTextStyle(
                weight = if (isDozing()) dozingWeight else lockScreenWeight,
@@ -336,7 +335,7 @@ class AnimatableClockView @JvmOverloads constructor(
    }

    fun animateDoze(isDozing: Boolean, animate: Boolean) {
        logBuffer?.log(tag, DEBUG, "animateDoze")
        logBuffer?.log(TAG, DEBUG, "animateDoze")
        setTextStyle(
            weight = if (isDozing) dozingWeight else lockScreenWeight,
            textSize = -1f,
@@ -455,7 +454,7 @@ class AnimatableClockView @JvmOverloads constructor(
            isSingleLineInternal && !use24HourFormat -> Patterns.sClockView12
            else -> DOUBLE_LINE_FORMAT_12_HOUR
        }
        logBuffer?.log(tag, DEBUG,
        logBuffer?.log(TAG, DEBUG,
                { str1 = format?.toString() },
                { "refreshFormat format=$str1" }
        )
@@ -466,6 +465,7 @@ class AnimatableClockView @JvmOverloads constructor(

    fun dump(pw: PrintWriter) {
        pw.println("$this")
        pw.println("    alpha=$alpha")
        pw.println("    measuredWidth=$measuredWidth")
        pw.println("    measuredHeight=$measuredHeight")
        pw.println("    singleLineInternal=$isSingleLineInternal")
@@ -626,7 +626,7 @@ class AnimatableClockView @JvmOverloads constructor(
    }

    companion object {
        private val TAG = AnimatableClockView::class.simpleName
        private val TAG = AnimatableClockView::class.simpleName!!
        const val ANIMATION_DURATION_FOLD_TO_AOD: Int = 600
        private const val DOUBLE_LINE_FORMAT_12_HOUR = "hh\nmm"
        private const val DOUBLE_LINE_FORMAT_24_HOUR = "HH\nmm"
+6 −7
Original line number Diff line number Diff line
@@ -88,13 +88,6 @@ class DefaultClockController(
        events.onTimeTick()
    }

    override fun setLogBuffer(logBuffer: LogBuffer) {
        smallClock.view.tag = "smallClockView"
        largeClock.view.tag = "largeClockView"
        smallClock.view.logBuffer = logBuffer
        largeClock.view.logBuffer = logBuffer
    }

    open inner class DefaultClockFaceController(
        override val view: AnimatableClockView,
    ) : ClockFaceController {
@@ -104,6 +97,12 @@ class DefaultClockController(
        private var isRegionDark = false
        protected var targetRegion: Rect? = null

        override var logBuffer: LogBuffer?
            get() = view.logBuffer
            set(value) {
                view.logBuffer = value
            }

        init {
            view.setColors(currentColor, currentColor)
        }
+3 −3
Original line number Diff line number Diff line
@@ -71,9 +71,6 @@ interface ClockController {

    /** Optional method for dumping debug information */
    fun dump(pw: PrintWriter) {}

    /** Optional method for debug logging */
    fun setLogBuffer(logBuffer: LogBuffer) {}
}

/** Interface for a specific clock face version rendered by the clock */
@@ -83,6 +80,9 @@ interface ClockFaceController {

    /** Events specific to this clock face */
    val events: ClockFaceEvents

    /** Some clocks may log debug information */
    var logBuffer: LogBuffer?
}

/** Events that should call when various rendering parameters change */
+7 −2
Original line number Diff line number Diff line
@@ -159,8 +159,13 @@ constructor(
     * bug report more actionable, so using the [log] with a messagePrinter to add more detail to
     * every log may do more to improve overall logging than adding more logs with this method.
     */
    fun log(tag: String, level: LogLevel, @CompileTimeConstant message: String) =
        log(tag, level, { str1 = message }, { str1!! })
    @JvmOverloads
    fun log(
        tag: String,
        level: LogLevel,
        @CompileTimeConstant message: String,
        exception: Throwable? = null,
    ) = log(tag, level, { str1 = message }, { str1!! }, exception)

    /**
     * You should call [log] instead of this method.
+13 −5
Original line number Diff line number Diff line
@@ -38,9 +38,11 @@ import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor
import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor
import com.android.systemui.keyguard.shared.model.TransitionState
import com.android.systemui.lifecycle.repeatWhenAttached
import com.android.systemui.log.dagger.KeyguardClockLog
import com.android.systemui.log.dagger.KeyguardSmallClockLog
import com.android.systemui.log.dagger.KeyguardLargeClockLog
import com.android.systemui.plugins.ClockController
import com.android.systemui.plugins.log.LogBuffer
import com.android.systemui.plugins.log.LogLevel.DEBUG
import com.android.systemui.shared.regionsampling.RegionSampler
import com.android.systemui.statusbar.policy.BatteryController
import com.android.systemui.statusbar.policy.BatteryController.BatteryStateChangeCallback
@@ -73,16 +75,18 @@ open class ClockEventController @Inject constructor(
    private val context: Context,
    @Main private val mainExecutor: Executor,
    @Background private val bgExecutor: Executor,
    @KeyguardClockLog private val logBuffer: LogBuffer?,
    @KeyguardSmallClockLog private val smallLogBuffer: LogBuffer?,
    @KeyguardLargeClockLog private val largeLogBuffer: LogBuffer?,
    private val featureFlags: FeatureFlags
) {
    var clock: ClockController? = null
        set(value) {
            field = value
            if (value != null) {
                if (logBuffer != null) {
                    value.setLogBuffer(logBuffer)
                }
                smallLogBuffer?.log(TAG, DEBUG, {}, { "New Clock" })
                value.smallClock.logBuffer = smallLogBuffer
                largeLogBuffer?.log(TAG, DEBUG, {}, { "New Clock" })
                value.largeClock.logBuffer = largeLogBuffer

                value.initialize(resources, dozeAmount, 0f)
                updateRegionSamplers(value)
@@ -325,4 +329,8 @@ open class ClockEventController @Inject constructor(
            }
        }
    }

    companion object {
        private val TAG = ClockEventController::class.simpleName!!
    }
}
Loading