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

Commit 384f7658 authored by Hawkwood's avatar Hawkwood
Browse files

Keep ClockEventController attached in Flexiglass

ClockEventController should keep it's callbacks connected. Otherwise
when the lockscreen isn't visible, we end up missing updates to user
setting changes like timezone changes. To accomplish this, we divide
the binder pattern doze listeners from the others. This lets us keep
ClockEventController's longer term listeners active while lockscreen
is not rendered, but only bind the doze listeners while it is.

Bug: 433723356
Test: Manually checked reproduction
Flag: com.android.systemui.scene_container
Change-Id: I6cce0eee710ebc6087b9b0c7a1841265a1e25b44
parent 44a60618
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -68,6 +68,10 @@ class LockscreenContent(
            rememberViewModel("LockscreenContent-scrimViewModel") {
                notificationScrimViewModelFactory.create()
            }

        // Ensure clock events are connected. This is a no-op if they are already registered.
        clockInteractor.clockEventController.registerListeners()

        if (!viewModel.isContentVisible) {
            // If the content isn't supposed to be visible, show a large empty box as it's needed
            // for scene transition animations (can't just skip rendering everything or shared
@@ -78,9 +82,8 @@ class LockscreenContent(
        }

        DisposableEffect(view) {
            clockInteractor.clockEventController.registerListeners(view)

            onDispose { clockInteractor.clockEventController.unregisterListeners() }
            val handle = clockInteractor.clockEventController.bind(view)
            onDispose { handle.dispose() }
        }

        val blueprint = blueprintByBlueprintId[viewModel.blueprintId] ?: return
+15 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.systemui.customization.clocks

import android.icu.util.TimeZone
import android.view.View
import android.view.View.MeasureSpec
import com.android.systemui.log.LogcatOnlyMessageBuffer
@@ -24,6 +25,8 @@ import com.android.systemui.log.core.Logger
import com.android.systemui.log.core.MessageBuffer
import com.android.systemui.plugins.keyguard.VPointF
import com.android.systemui.plugins.keyguard.VRect
import com.android.systemui.plugins.keyguard.ui.clocks.TimeFormatKind
import java.util.Locale
import kotlin.math.abs

class ClockLogger(private val view: View?, buffer: MessageBuffer, tag: String) :
@@ -49,6 +52,18 @@ class ClockLogger(private val view: View?, buffer: MessageBuffer, tag: String) :
        }
    }

    fun onTimeZoneChanged(timeZone: TimeZone) {
        d({ "onTimeZoneChanged($str1)" }) { str1 = "$timeZone" }
    }

    fun onTimeFormatChanged(formatKind: TimeFormatKind) {
        d({ "onTimeFormatChanged($str1)" }) { str1 = "$formatKind" }
    }

    fun onLocaleChanged(formatKind: Locale) {
        d({ "onLocaleChanged($str1)" }) { str1 = "$formatKind" }
    }

    fun onMeasure(widthSpec: Int, heightSpec: Int) {
        d({ "onMeasure(${getSpecText(int1)}, ${getSpecText(int2)})" }) {
            int1 = widthSpec
+7 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.widget.FrameLayout
import com.android.app.animation.Interpolators
import com.android.systemui.animation.GSFAxes
import com.android.systemui.customization.clocks.ClockContext
import com.android.systemui.customization.clocks.ClockLogger
import com.android.systemui.customization.clocks.DefaultClockFaceLayout
import com.android.systemui.customization.clocks.DigitalTimeFormatter
import com.android.systemui.customization.clocks.DigitalTimespec
@@ -77,6 +78,9 @@ class FlexClockFaceController(
    override val view: View
        get() = layerController.view

    private val logger =
        ClockLogger(null, clockCtx.messageBuffer, FlexClockFaceController::class.simpleName!!)

    override val config = ClockFaceConfig(hasCustomPositionUpdatedAnimation = true)

    override var theme = ThemeConfig(true, clockCtx.settings.seedColor)
@@ -124,16 +128,19 @@ class FlexClockFaceController(
        }

        override fun onTimeZoneChanged(timeZone: TimeZone) {
            logger.onTimeZoneChanged(timeZone)
            clockCtx.timeKeeper.timeZone = timeZone
            layerController.events.onTimeZoneChanged(timeZone)
        }

        override fun onTimeFormatChanged(formatKind: TimeFormatKind) {
            logger.onTimeFormatChanged(formatKind)
            timeFormatter.formatKind = formatKind
            layerController.events.onTimeFormatChanged(formatKind)
        }

        override fun onLocaleChanged(locale: Locale) {
            logger.onLocaleChanged(locale)
            timeFormatter.locale = locale
            layerController.events.onLocaleChanged(locale)
        }
+2 −2
Original line number Diff line number Diff line
@@ -22,12 +22,12 @@ import android.view.View
import android.view.ViewGroup
import android.widget.RelativeLayout
import com.android.systemui.customization.clocks.ClockContext
import com.android.systemui.customization.clocks.ClockLogger
import com.android.systemui.customization.clocks.DigitalTimeFormatter
import com.android.systemui.customization.clocks.DigitalTimespec
import com.android.systemui.customization.clocks.DigitalTimespecHandler
import com.android.systemui.customization.clocks.FontTextStyle
import com.android.systemui.customization.clocks.view.DigitalAlignment
import com.android.systemui.log.core.Logger
import com.android.systemui.plugins.keyguard.data.model.AlarmData
import com.android.systemui.plugins.keyguard.data.model.WeatherData
import com.android.systemui.plugins.keyguard.data.model.ZenData
@@ -57,7 +57,7 @@ open class FlexClockTextViewController(
    isLargeClock: Boolean,
) : FlexClockViewController {
    override val view = FlexClockTextView(clockCtx, isLargeClock)
    private val logger = Logger(clockCtx.messageBuffer, TAG)
    private val logger = ClockLogger(null, clockCtx.messageBuffer, TAG)
    private val timespec = DigitalTimespecHandler(layerCfg.timespec, layerCfg.timeFormatter!!)
    override var onViewBoundsChanged by view::onViewBoundsChanged
    override var onViewMaxSizeChanged by view::onViewMaxSizeChanged
+2 −2
Original line number Diff line number Diff line
@@ -20,13 +20,13 @@ import android.graphics.Rect
import android.icu.util.TimeZone
import com.android.app.animation.Interpolators
import com.android.systemui.customization.clocks.ClockContext
import com.android.systemui.customization.clocks.ClockLogger
import com.android.systemui.customization.clocks.DigitalTimeFormatter
import com.android.systemui.customization.clocks.DigitalTimespec
import com.android.systemui.customization.clocks.FontTextStyle
import com.android.systemui.customization.clocks.view.DigitalAlignment
import com.android.systemui.customization.clocks.view.HorizontalAlignment
import com.android.systemui.customization.clocks.view.VerticalAlignment
import com.android.systemui.log.core.Logger
import com.android.systemui.plugins.keyguard.data.model.AlarmData
import com.android.systemui.plugins.keyguard.data.model.WeatherData
import com.android.systemui.plugins.keyguard.data.model.ZenData
@@ -43,7 +43,7 @@ import java.util.Locale

class FlexClockViewGroupController(private val clockCtx: ClockContext) : FlexClockViewController {
    private val logger =
        Logger(clockCtx.messageBuffer, FlexClockViewGroupController::class.simpleName!!)
        ClockLogger(null, clockCtx.messageBuffer, FlexClockViewGroupController::class.simpleName!!)

    val layerControllers = mutableListOf<FlexClockViewController>()
    val dozeState = DefaultClockController.AnimationState(1F)
Loading