ThemePicker: default to TONAL_SPOT for invalid Styles
It is possible for the current style to not be supported if users
are coming from a stock ROM and logging into their Google account
which will restore their settings.
Default to TONAL_SPOT, same as in all other places which parse
a Style value from string.
Change-Id: I28c08cff5f7fbb63233cd465f19b6995365d1cde
diff --git a/src/com/android/customization/picker/color/data/repository/ColorPickerRepositoryImpl.kt b/src/com/android/customization/picker/color/data/repository/ColorPickerRepositoryImpl.kt
index 7e63834..ca5fafe 100644
--- a/src/com/android/customization/picker/color/data/repository/ColorPickerRepositoryImpl.kt
+++ b/src/com/android/customization/picker/color/data/repository/ColorPickerRepositoryImpl.kt
@@ -140,7 +140,9 @@
override fun getCurrentColorOption(): ColorOptionModel {
val overlays = colorManager.currentOverlays
val styleOrNull = colorManager.currentStyle
- val style = styleOrNull?.let { Style.valueOf(it) } ?: Style.TONAL_SPOT
+ val style = runCatching {
+ styleOrNull?.let { Style.valueOf(it) }
+ }.getOrNull() ?: Style.TONAL_SPOT
val source = colorManager.currentColorSource
val colorOptionBuilder = ColorOptionImpl.Builder()
colorOptionBuilder.source = source