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

Commit 8fc813bf authored by Hawkwood Glazier's avatar Hawkwood Glazier
Browse files

Replace function type in interface w/ reflectable version

This issue was due to passing a builtin kotlin type (in this case
Function<>) across the api boundary. This caused there to be two
versions of the target type, which could not be reconciled at
runtime.

Unlike previous similar bugs, neither SystemUI nor WPP crashed due
to this, but instead both successfully fell back to using the default
clock in non-debug builds.

Bug: 400469538
Flag: NONE bugfix
Test: Manually checked operation of custom clocks
Change-Id: I0d7ac683130c360a672f79ea7dd753669f4b97dc
parent 45292785
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@ import android.content.Context
import android.content.res.Resources
import android.graphics.Color
import android.graphics.Rect
import android.graphics.RectF
import android.icu.text.NumberFormat
import android.util.TypedValue
import android.view.LayoutInflater
@@ -29,6 +28,7 @@ import com.android.systemui.plugins.clocks.AlarmData
import com.android.systemui.plugins.clocks.ClockAnimations
import com.android.systemui.plugins.clocks.ClockConfig
import com.android.systemui.plugins.clocks.ClockController
import com.android.systemui.plugins.clocks.ClockEventListener
import com.android.systemui.plugins.clocks.ClockEvents
import com.android.systemui.plugins.clocks.ClockFaceConfig
import com.android.systemui.plugins.clocks.ClockFaceController
@@ -102,7 +102,7 @@ class DefaultClockController(
        isDarkTheme: Boolean,
        dozeFraction: Float,
        foldFraction: Float,
        onBoundsChanged: (RectF) -> Unit,
        clockListener: ClockEventListener?,
    ) {
        largeClock.recomputePadding(null)

+4 −4
Original line number Diff line number Diff line
@@ -16,13 +16,13 @@

package com.android.systemui.shared.clocks

import android.graphics.RectF
import com.android.systemui.animation.GSFAxes
import com.android.systemui.customization.R
import com.android.systemui.plugins.clocks.AlarmData
import com.android.systemui.plugins.clocks.AxisType
import com.android.systemui.plugins.clocks.ClockConfig
import com.android.systemui.plugins.clocks.ClockController
import com.android.systemui.plugins.clocks.ClockEventListener
import com.android.systemui.plugins.clocks.ClockEvents
import com.android.systemui.plugins.clocks.ClockFontAxis
import com.android.systemui.plugins.clocks.ClockFontAxis.Companion.merge
@@ -107,11 +107,11 @@ class FlexClockController(private val clockCtx: ClockContext) : ClockController
        isDarkTheme: Boolean,
        dozeFraction: Float,
        foldFraction: Float,
        onBoundsChanged: (RectF) -> Unit,
        clockListener: ClockEventListener?,
    ) {
        events.onFontAxesChanged(clockCtx.settings.axes)
        smallClock.run {
            layerController.onViewBoundsChanged = onBoundsChanged
            layerController.onViewBoundsChanged = { clockListener?.onBoundsChanged(it) }
            events.onThemeChanged(theme.copy(isDarkTheme = isDarkTheme))
            animations.doze(dozeFraction)
            animations.fold(foldFraction)
@@ -119,7 +119,7 @@ class FlexClockController(private val clockCtx: ClockContext) : ClockController
        }

        largeClock.run {
            layerController.onViewBoundsChanged = onBoundsChanged
            layerController.onViewBoundsChanged = { clockListener?.onBoundsChanged(it) }
            events.onThemeChanged(theme.copy(isDarkTheme = isDarkTheme))
            animations.doze(dozeFraction)
            animations.fold(foldFraction)
+1 −1
Original line number Diff line number Diff line
@@ -108,7 +108,7 @@ class DefaultClockProviderTest : SysuiTestCase() {
        verify(mockSmallClockView).setColors(DOZE_COLOR, Color.MAGENTA)
        verify(mockLargeClockView).setColors(DOZE_COLOR, Color.MAGENTA)

        clock.initialize(true, 0f, 0f, {})
        clock.initialize(true, 0f, 0f, null)

        val expectedColor = 0
        verify(mockSmallClockView).setColors(DOZE_COLOR, expectedColor)
+5 −1
Original line number Diff line number Diff line
@@ -42,9 +42,13 @@ interface ClockController {
        isDarkTheme: Boolean,
        dozeFraction: Float,
        foldFraction: Float,
        onBoundsChanged: (RectF) -> Unit,
        clockListener: ClockEventListener?,
    )

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

interface ClockEventListener {
    fun onBoundsChanged(bounds: RectF)
}
+9 −1
Original line number Diff line number Diff line
@@ -56,6 +56,7 @@ import com.android.systemui.log.core.Logger
import com.android.systemui.modes.shared.ModesUi
import com.android.systemui.plugins.clocks.AlarmData
import com.android.systemui.plugins.clocks.ClockController
import com.android.systemui.plugins.clocks.ClockEventListener
import com.android.systemui.plugins.clocks.ClockFaceController
import com.android.systemui.plugins.clocks.ClockMessageBuffers
import com.android.systemui.plugins.clocks.ClockTickRate
@@ -148,7 +149,7 @@ constructor(
        val clockStr = clock.toString()
        loggers.forEach { it.d({ "New Clock: $str1" }) { str1 = clockStr } }

        clock.initialize(isDarkTheme(), dozeAmount.value, 0f, { onClockBoundsChanged.value = it })
        clock.initialize(isDarkTheme(), dozeAmount.value, 0f, clockListener)

        if (!regionSamplingEnabled) {
            updateColors()
@@ -312,6 +313,13 @@ constructor(
    private var zenData: ZenData? = null
    private var alarmData: AlarmData? = null

    private val clockListener =
        object : ClockEventListener {
            override fun onBoundsChanged(bounds: RectF) {
                onClockBoundsChanged.value = bounds
            }
        }

    private val configListener =
        object : ConfigurationController.ConfigurationListener {
            override fun onThemeChanged() {