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

Commit 24ec2523 authored by Hawkwood Glazier's avatar Hawkwood Glazier
Browse files

Remove default impls from clock plugins

This appears to prevent crashes from dynamic loading failures when
building and deploying sysui & wpp from sysui studio instead of building
through soong.

Bug: 279049213
Test: Deployed wpp & sysui from sysui studio
Change-Id: I6225f9529898ef8c6f4953957fb83cf0cd2abda0
parent 8278c862
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import com.android.systemui.plugins.ClockFaceConfig
import com.android.systemui.plugins.ClockFaceController
import com.android.systemui.plugins.ClockFaceEvents
import com.android.systemui.plugins.ClockSettings
import com.android.systemui.plugins.WeatherData
import java.io.PrintWriter
import java.util.Locale
import java.util.TimeZone
@@ -227,6 +228,8 @@ class DefaultClockController(

            clocks.forEach { it.refreshFormat() }
        }

        override fun onWeatherDataChanged(data: WeatherData) {}
    }

    open inner class DefaultClockAnimations(
@@ -273,6 +276,8 @@ class DefaultClockController(
            // the top margin change in recomputePadding to make clock be centered
            view.translationY = 0.5f * view.bottom * (1 - swipingFraction)
        }

        override fun onPositionUpdated(fromLeft: Int, direction: Int, fraction: Float) {}
    }

    inner class LargeClockAnimations(
+18 −26
Original line number Diff line number Diff line
@@ -74,18 +74,10 @@ interface ClockController {
        resources: Resources,
        dozeFraction: Float,
        foldFraction: Float,
    ) {
        events.onColorPaletteChanged(resources)
        smallClock.animations.doze(dozeFraction)
        largeClock.animations.doze(dozeFraction)
        smallClock.animations.fold(foldFraction)
        largeClock.animations.fold(foldFraction)
        smallClock.events.onTimeTick()
        largeClock.events.onTimeTick()
    }
    )

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

/** Interface for a specific clock face version rendered by the clock */
@@ -109,37 +101,37 @@ interface ClockFaceController {
/** Events that should call when various rendering parameters change */
interface ClockEvents {
    /** Call whenever timezone changes */
    fun onTimeZoneChanged(timeZone: TimeZone) {}
    fun onTimeZoneChanged(timeZone: TimeZone)

    /** Call whenever the text time format changes (12hr vs 24hr) */
    fun onTimeFormatChanged(is24Hr: Boolean) {}
    fun onTimeFormatChanged(is24Hr: Boolean)

    /** Call whenever the locale changes */
    fun onLocaleChanged(locale: Locale) {}
    fun onLocaleChanged(locale: Locale)

    /** Call whenever the color palette should update */
    fun onColorPaletteChanged(resources: Resources) {}
    fun onColorPaletteChanged(resources: Resources)

    /** Call if the seed color has changed and should be updated */
    fun onSeedColorChanged(seedColor: Int?) {}
    fun onSeedColorChanged(seedColor: Int?)

    /** Call whenever the weather data should update */
    fun onWeatherDataChanged(data: WeatherData) {}
    fun onWeatherDataChanged(data: WeatherData)
}

/** Methods which trigger various clock animations */
interface ClockAnimations {
    /** Runs an enter animation (if any) */
    fun enter() {}
    fun enter()

    /** Sets how far into AOD the device currently is. */
    fun doze(fraction: Float) {}
    fun doze(fraction: Float)

    /** Sets how far into the folding animation the device is. */
    fun fold(fraction: Float) {}
    fun fold(fraction: Float)

    /** Runs the battery animation (if any). */
    fun charge() {}
    fun charge()

    /**
     * Runs when the clock's position changed during the move animation.
@@ -150,32 +142,32 @@ interface ClockAnimations {
     * @param fraction fraction of the clock movement. 0 means it is at the beginning, and 1 means
     *   it finished moving.
     */
    fun onPositionUpdated(fromLeft: Int, direction: Int, fraction: Float) {}
    fun onPositionUpdated(fromLeft: Int, direction: Int, fraction: Float)

    /**
     * Runs when swiping clock picker, swipingFraction: 1.0 -> clock is scaled up in the preview,
     * 0.0 -> clock is scaled down in the shade; previewRatio is previewSize / screenSize
     */
    fun onPickerCarouselSwiping(swipingFraction: Float) {}
    fun onPickerCarouselSwiping(swipingFraction: Float)
}

/** Events that have specific data about the related face */
interface ClockFaceEvents {
    /** Call every time tick */
    fun onTimeTick() {}
    fun onTimeTick()

    /**
     * Region Darkness specific to the clock face.
     * - isRegionDark = dark theme -> clock should be light
     * - !isRegionDark = light theme -> clock should be dark
     */
    fun onRegionDarknessChanged(isRegionDark: Boolean) {}
    fun onRegionDarknessChanged(isRegionDark: Boolean)

    /**
     * Call whenever font settings change. Pass in a target font size in pixels. The specific clock
     * design is allowed to ignore this target size on a case-by-case basis.
     */
    fun onFontSettingChanged(fontSizePx: Float) {}
    fun onFontSettingChanged(fontSizePx: Float)

    /**
     * Target region information for the clock face. For small clock, this will match the bounds of
@@ -184,7 +176,7 @@ interface ClockFaceEvents {
     * render within the centered targetRect to avoid obstructing other elements. The specified
     * targetRegion is relative to the parent view.
     */
    fun onTargetRegionChanged(targetRegion: Rect?) {}
    fun onTargetRegionChanged(targetRegion: Rect?)
}

/** Tick rates for clocks */