Skip to content

fix: validate highlightColor before passing to SystemUI#248

Open
Wangtaotaoo wants to merge 1 commit into
D4vidDf:masterfrom
Wangtaotaoo:fix/validate-highlight-color
Open

fix: validate highlightColor before passing to SystemUI#248
Wangtaotaoo wants to merge 1 commit into
D4vidDf:masterfrom
Wangtaotaoo:fix/validate-highlight-color

Conversation

@Wangtaotaoo

Copy link
Copy Markdown
Contributor

Summary

Fixes a SystemUI crash caused by invalid highlightColor values in theme configurations being passed directly to Color.parseColor() in HyperOS's DynamicIsland.

Problem

When a theme (imported .hbr file or legacy config) contains an invalid highlight_color value (e.g. "013" without # prefix), resolveColor() returns it as-is. SystemUI's DynamicIslandBaseContentView.updateDarkLightMode() then calls highlightColor.toColorInt(), which throws:

FATAL EXCEPTION: main
Process: com.android.systemui
java.lang.IllegalArgumentException: Unknown color
    at android.graphics.Color.parseColor(Color.java:1402)
    at miui.systemui.dynamicisland.window.content.DynamicIslandBaseContentView.updateDarkLightMode

This crash only triggers when:

  • The island region background is dark (isLight = false)
  • The island is in BigIsland state (not Expanded)
  • highlightColor is non-empty but unparseable

Fix

Added toSafeColorHex() validation at all return paths of resolveColor() in BaseTranslator. If Color.parseColor() throws IllegalArgumentException, it falls back to the provided default hex value and logs a warning.

What was tested

  • Injected a theme with "highlight_color": "013" (the exact value from the original bugreport)
  • Sent notifications with dark wallpaper active
  • Confirmed SystemUI no longer crashes
  • Confirmed logcat shows: W/BaseTranslator: Invalid highlight color "013", falling back to "#FFFFFF"

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.
@Wangtaotaoo

Copy link
Copy Markdown
Contributor Author

It's still unclear how highlight_color ended up with an invalid value ("013").
I couldn't find the root cause of the config corruption.
However, from the user's bugreport log, it's confirmed that SystemUI crashed because HyperBridge passed this invalid value to the DynamicIsland.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant