Skip to content

Widget: Keep theme and transparency after device reboot#552

Merged
d4rken merged 1 commit into
mainfrom
fix/widget-theme-reboot
Apr 25, 2026
Merged

Widget: Keep theme and transparency after device reboot#552
d4rken merged 1 commit into
mainfrom
fix/widget-theme-reboot

Conversation

@d4rken

@d4rken d4rken commented Apr 25, 2026

Copy link
Copy Markdown
Member

What changed

Widget theme settings (Dark/Light/Custom presets, background transparency, label visibility) were lost after rebooting the device. Previously, configured widgets reverted to "Material You" with full background opacity on the next boot. The selected device profile already survived reboot; now the rest of the configuration does too.

Closes #549

Technical Context

  • Root cause: theme was stored in AppWidgetManager.getAppWidgetOptions(). Per AOSP AppWidgetServiceImpl.serializeAppWidget(...), only the five standard OPTION_APPWIDGET_* system keys are written to appwidgets.xml; arbitrary custom keys are silently dropped at boot. Universal Android behavior, not Samsung- or launcher-specific.
  • The widget profile survived because it already lived in WidgetSettings' own DataStore, which the system widget service does not touch.
  • Fix moves all per-widget configuration (profile + theme) into one JSON-serialized WidgetConfig under widget_config_<id> in the existing widget_preferences DataStore.
  • Migration is one-shot per widget, guarded inside the same dataStore.edit {} block as the write so a concurrent save cannot be overwritten by stale legacy data. The legacy options bundle is parsed via a new WidgetTheme.fromLegacyBundleOrNull() that returns null on a system-only bundle — avoiding a false "Material You + 255" migration read.
  • Users upgrading without rebooting first keep their existing theme (legacy bundle is still in memory). Users who already lost their theme keep their profile and reconfigure the theme once — it then sticks permanently.
  • Verified on a Pixel 8 across a real device reboot: post-boot the widget rendered with the saved Dark theme and configured transparency, and getWidgetConfig(widgetId=15) returned the same values that were saved before the reboot.

@d4rken d4rken added the bug Something isn't working label Apr 25, 2026
@d4rken d4rken merged commit 97f294e into main Apr 25, 2026
10 checks passed
@d4rken d4rken deleted the fix/widget-theme-reboot branch April 25, 2026 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Widget] Theme selection for the 2x1 widget doesn't stick after a phone reboot

1 participant