Fix crash when notification button tapped after service restart#26
Conversation
Move pendingActionsWakeLock initialization from onDeviceAppeared() to onCreate() so it is always initialized before onStartCommand() is called. Previously, if the service was killed and restarted by Android, a notification button tap would trigger onStartCommand() before onDeviceAppeared(), causing an UninitializedPropertyAccessException in cancelPendingActionSteps(). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Thanks a lot, looks like a clean an simple solution. I wanted to look into the app (and this issue) soon anyway and will do some testing. The companion device service is a mess across different Android versions with very different behaviors in calling the various callback, so I want to test on a few real devices before a release - but I do not see an issue with this PR. When I am back from my family vacation I will look into it. |
|
Finally did some testing and not surprisingly it works perfectly. Since I have not seen the original bug on any of my devices I cannot say for sure that it fixes it, but I would be surprised if it didn't. Thanks again. I plan to implement one or two other things from my todo list in the next days (which usually turns our as weeks) and then make a release. |
Summary
pendingActionsWakeLockwas initialized inonDeviceAppeared(), but Android can callonStartCommand()beforeonDeviceAppeared()when the service is killed and restartedcancelPendingActionSteps()→UninitializedPropertyAccessException→ crashonCreate(), which is always called beforeonStartCommand()Root cause
Verified on my phone, Oppo A53, Android 12, I think this will also solve #25
🤖 Generated with Claude Code