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 Original line Diff line number Diff line
@@ -54,7 +54,6 @@ class AnimatableClockView @JvmOverloads constructor(
    defStyleAttr: Int = 0,
    defStyleAttr: Int = 0,
    defStyleRes: Int = 0
    defStyleRes: Int = 0
) : TextView(context, attrs, defStyleAttr, defStyleRes) {
) : TextView(context, attrs, defStyleAttr, defStyleRes) {
    var tag: String = "UnnamedClockView"
    var logBuffer: LogBuffer? = null
    var logBuffer: LogBuffer? = null


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


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


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


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


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


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


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


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


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


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


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


    companion object {
    companion object {
        private val TAG = AnimatableClockView::class.simpleName
        private val TAG = AnimatableClockView::class.simpleName!!
        const val ANIMATION_DURATION_FOLD_TO_AOD: Int = 600
        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_12_HOUR = "hh\nmm"
        private const val DOUBLE_LINE_FORMAT_24_HOUR = "HH\nmm"
        private const val DOUBLE_LINE_FORMAT_24_HOUR = "HH\nmm"
+6 −7
Original line number Original line Diff line number Diff line
@@ -88,13 +88,6 @@ class DefaultClockController(
        events.onTimeTick()
        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(
    open inner class DefaultClockFaceController(
        override val view: AnimatableClockView,
        override val view: AnimatableClockView,
    ) : ClockFaceController {
    ) : ClockFaceController {
@@ -104,6 +97,12 @@ class DefaultClockController(
        private var isRegionDark = false
        private var isRegionDark = false
        protected var targetRegion: Rect? = null
        protected var targetRegion: Rect? = null


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

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


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

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


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


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

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


/** Events that should call when various rendering parameters change */
/** Events that should call when various rendering parameters change */
+7 −2
Original line number Original line 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
     * 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.
     * 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) =
    @JvmOverloads
        log(tag, level, { str1 = message }, { str1!! })
    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.
     * You should call [log] instead of this method.
+13 −5
Original line number Original line 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.domain.interactor.KeyguardTransitionInteractor
import com.android.systemui.keyguard.shared.model.TransitionState
import com.android.systemui.keyguard.shared.model.TransitionState
import com.android.systemui.lifecycle.repeatWhenAttached
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.ClockController
import com.android.systemui.plugins.log.LogBuffer
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.shared.regionsampling.RegionSampler
import com.android.systemui.statusbar.policy.BatteryController
import com.android.systemui.statusbar.policy.BatteryController
import com.android.systemui.statusbar.policy.BatteryController.BatteryStateChangeCallback
import com.android.systemui.statusbar.policy.BatteryController.BatteryStateChangeCallback
@@ -73,16 +75,18 @@ open class ClockEventController @Inject constructor(
    private val context: Context,
    private val context: Context,
    @Main private val mainExecutor: Executor,
    @Main private val mainExecutor: Executor,
    @Background private val bgExecutor: 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
    private val featureFlags: FeatureFlags
) {
) {
    var clock: ClockController? = null
    var clock: ClockController? = null
        set(value) {
        set(value) {
            field = value
            field = value
            if (value != null) {
            if (value != null) {
                if (logBuffer != null) {
                smallLogBuffer?.log(TAG, DEBUG, {}, { "New Clock" })
                    value.setLogBuffer(logBuffer)
                value.smallClock.logBuffer = smallLogBuffer
                }
                largeLogBuffer?.log(TAG, DEBUG, {}, { "New Clock" })
                value.largeClock.logBuffer = largeLogBuffer


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

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