fix: [SDK-4901] skip ShortcutBadger on API 26+ to prevent SIGSEGV on Xiaomi devices#2570
fix: [SDK-4901] skip ShortcutBadger on API 26+ to prevent SIGSEGV on Xiaomi devices#2570fadi-george wants to merge 1 commit into
Conversation
26c7e3a to
905aefb
Compare
📊 Diff Coverage ReportDiff Coverage Report (Changed Lines Only)Gate: aggregate coverage on changed executable lines must be ≥ 80% (JaCoCo line data for lines touched in the diff). Changed Files Coverage
Overall (aggregate gate)1831/3685 touched executable lines covered (49.7% — requires ≥ 80%) Per-file detail (informational; gate is aggregate above):
❌ Coverage Check FailedAggregate coverage on touched lines is 49.7% (minimum 80%). |
905aefb to
5139ef3
Compare
5139ef3 to
4a6177c
Compare
On Android 8+ (API 26), notification channels handle app icon badges natively, making ShortcutBadger unnecessary. ShortcutBadger's DefaultBadger fallback causes native SIGSEGV crashes on certain Xiaomi devices (Redmi 10C, Redmi 9A) where MIUI's broadcast receiver has buggy native code that cannot be caught at the Java level. Fixes OneSignal/react-native-onesignal#1766 Made-with: Cursor Co-authored-by: Cursor <cursoragent@cursor.com>
4a6177c to
3c784ce
Compare
Description
One Line Summary
Skip ShortcutBadger badge updates on Android 8+ (API 26) to prevent native SIGSEGV crashes on Xiaomi devices.
Details
Motivation
ShortcutBadger causes a native SIGSEGV on certain Xiaomi devices (Redmi 10C, Redmi 9A) running Android 11-13. The crash occurs while updating the legacy launcher badge. Since SIGSEGV is a native crash, Java exception handling cannot intercept it.
Android 8+ handles app icon badges through notification channels and active notifications, so the legacy ShortcutBadger path is unnecessary on those versions.
Reported in OneSignal/react-native-onesignal#1766 and #2222. Tracked by SDK-4901.
Scope
On API 26+, skip both automatic and explicit ShortcutBadger updates. Pre-API 26 devices continue using ShortcutBadger unchanged.
Testing
Unit testing
Added
BadgeCountUpdaterTestscovering:update()does not invoke ShortcutBadger on API 26.updateCount()does not invoke ShortcutBadger on API 26.updateCount()continues invoking ShortcutBadger before API 26.Local validation:
Manual testing
The affected Xiaomi hardware was not available locally. The regression tests prevent the crashing code path from being reached on the reported Android versions.
Affected code checklist
Checklist
Overview
Testing
Final pass