fix: validate highlightColor before passing to SystemUI#248
Conversation
Invalid color strings (e.g. "013" without '#' prefix) in theme configs cause SystemUI to crash with IllegalArgumentException in DynamicIslandBaseContentView.updateDarkLightMode() when Color.parseColor() is called. Add toSafeColorHex() validation in resolveColor() that catches IllegalArgumentException from Color.parseColor() and falls back to the default color hex value. This prevents malformed theme data (from imported .hbr files or legacy configs) from crashing SystemUI.
|
It's still unclear how highlight_color ended up with an invalid value ("013"). 06-03 15:00:56.759 1000 25369 25369 D DynamicIslandEventDebug: ExpandedStateHandler handleReplacedState: originState: miui.systemui.dynamicisland.window.content.DynamicIslandContentView{e94f974 I.E...... ......ID 0,0-1220,0 #7f0a0247 app:id/island_content} ---- {"islandProperty":1,"islandPriority":2,"islandOrder":false,"dismissIsland":false,"maxSize":false,"needCloseAnimation":true,"highlightColor":"013","bigIslandArea":{"imageTextInfoLeft":{"type":1,"picInfo":{"type":1,"pic":"miui.focus.pic_pic_-1464440788","loop":false,"autoplay":false,"number":0},"textInfo":{"title":"","content":"","showHighlightColor":false}},"imageTextInfoRight":{"type":1,"picInfo":{"type":1,"pic":"miui.focus.pic_hidden_pixel","loop":false,"autoplay":false,"number":0},"textInfo":{"title":"08 SHARK PERFUMES | PROMO (79 mensagens): ~ EQUIPE SHARK","content":"📷 ➡️ Perfume Fakhar Platin Lattafa 100ml\nOferta no Mercado Livre\n\n💰 De R$ 299,82 por R$169\n🛒https:\/\/meli.la\/1NUCVi2","showHighlightColor":false}}},"smallIslandArea":{"picInfo":{"type":1,"pic":"miui.focus.pic_pic_-1464440788","loop":false,"autoplay":false,"number":0}}}--- tempShow:false, current: null----null, hiddenList: 1}, userSwipe: false , next: miui.systemui.dynamicisland.event.handler.BigIslandStateHandler@f375907 |
Summary
Fixes a SystemUI crash caused by invalid
highlightColorvalues in theme configurations being passed directly toColor.parseColor()in HyperOS's DynamicIsland.Problem
When a theme (imported
.hbrfile or legacy config) contains an invalidhighlight_colorvalue (e.g."013"without#prefix),resolveColor()returns it as-is. SystemUI'sDynamicIslandBaseContentView.updateDarkLightMode()then callshighlightColor.toColorInt(), which throws:This crash only triggers when:
isLight = false)highlightColoris non-empty but unparseableFix
Added
toSafeColorHex()validation at all return paths ofresolveColor()inBaseTranslator. IfColor.parseColor()throwsIllegalArgumentException, it falls back to the provided default hex value and logs a warning.What was tested
"highlight_color": "013"(the exact value from the original bugreport)W/BaseTranslator: Invalid highlight color "013", falling back to "#FFFFFF"