Skip to content

fix: Harden battery display against native crashes#377

Merged
d4rken merged 1 commit intomainfrom
fix/battery-native-crash-hardening
Feb 8, 2026
Merged

fix: Harden battery display against native crashes#377
d4rken merged 1 commit intomainfrom
fix/battery-native-crash-hardening

Conversation

@d4rken
Copy link
Copy Markdown
Member

@d4rken d4rken commented Feb 8, 2026

Summary

  • Fix thread-unsafe shared RelativeDateTimeFormatter instance that caused memory corruption when accessed from multiple threads concurrently
  • Cache battery percentage values to local variables before passing to both icon and label functions, reducing repeated interface dispatch chains
  • Replace per-type getBatteryLevel* extension functions with a single formatBatteryPercent helper

Context

Multiple native crashes (SIGSEGV in ART) were reported in PodDeviceExtensionsKt functions during RecyclerView binding and notification building on background threads. The shared static RelativeDateTimeFormatter is not thread-safe and was the most likely cause of heap corruption. Battery percentage caching is an additional hardening measure.

Test plan

  • ./gradlew assembleFossDebug compiles
  • ./gradlew testFossDebugUnitTest passes
  • Verify battery icons/labels in overview, notification, popup, and widget

Remove thread-unsafe shared RelativeDateTimeFormatter instance and cache
battery percentage values to local variables at all call sites.
@d4rken d4rken added the bug Something isn't working label Feb 8, 2026
@d4rken d4rken merged commit 5aa36b1 into main Feb 8, 2026
13 checks passed
@d4rken d4rken deleted the fix/battery-native-crash-hardening branch February 8, 2026 03:25
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.

1 participant