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

Commit b4bdc9ed authored by Chris Poultney's avatar Chris Poultney
Browse files

Prevent picker crash when clock init crashes

Bug: 414815071
Bug: 406317266
Flag: EXEMPT bugfix
Test: manually verified that clocks work in picker
Change-Id: I7678d335a2bca605d5e580d6fdb23982581845ff
parent 11e7da85
Loading
Loading
Loading
Loading
+25 −15
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ import android.app.Activity
import android.app.WallpaperColors
import android.app.WallpaperManager
import android.graphics.Rect
import android.util.Log
import android.view.View
import android.widget.FrameLayout
import androidx.annotation.ColorInt
@@ -187,6 +188,7 @@ constructor(
    }

    private fun initClockController(clockId: String): ClockController? {
        try {
            val isWallpaperDark = isLockscreenWallpaperDark()
            return registry.createExampleClock(activity, clockId)?.also { controller ->
                controller.initialize(isWallpaperDark, 0f, 0f)
@@ -204,6 +206,14 @@ constructor(
                controller.smallClock.events.onTargetRegionChanged(getSmallClockRegion())
                controller.events.onWeatherDataChanged(WeatherData.getPlaceholderWeatherData())
            }
        } catch (e: Exception) {
            Log.e(
                "ThemePickerClockViewFactory",
                "caught clock init exception, proceeding without clocks",
                e,
            )
            return null
        }
    }

    /**