fix(android): battery usage while the app is in the background#20882
fix(android): battery usage while the app is in the background#20882alexjba wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
Bumps status-go to a version that pauses MVDS message-sending loops while the app is backgrounded (to reduce Android battery drain) and adds Android-side glue so notification reply / contact-request actions can briefly wake the messaging service to push the user's reply through, then re-pause it.
Changes:
- Add
scheduleMessagingRepause()toStatusGoServicewith a 60s coalesced re-pause runnable on the mainHandler, plussInstanceplumbing and cleanup inonCreate/onDestroy/applyUiVisibility. - In
NotificationReplyReceiver, callResumeService("messaging")before sending the chat / contact-request RPC and schedule a re-pause in thefinallyblock.
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| mobile/android/qt6/src/app/status/mobile/ipc/StatusGoService.java | Adds singleton instance, main-thread handler, and a coalesced re-pause runnable for the "messaging" service used by background notification actions. |
| mobile/android/qt6/src/app/status/mobile/ipc/NotificationReplyReceiver.java | Resumes "messaging" before background send, schedules re-pause in finally for both reply and contact-request paths. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Jenkins BuildsClick to see older builds (29)
|
82a0bd3 to
53356d4
Compare
53356d4 to
d559641
Compare
|
Tested the battery usage by these two Status app versions:
My phone device shows 4% battery usage since last fully charged for this build.
If the data above is right (will try to monitor these two app versions to see if I spot anything different in terms of battery data usage), then this PR brings 3x improvements in terms of battery usage by the app. |
This commit bumps status-go to include status-im/status-go#7440. As a result the message sending is paused while in the background to stop the high frequency mvds loops that will prevent Android from going into sleep. To preserve message sending while the app is in the background/killed we'll have to wake messenger briefly on the OS intent. We'll resume messenger for 60 seconds - enough to push the message through and then it will be paused again unless the app goes back to foreground. This results in less battery usage and less events piling up in the qt event loop while the app is in the background.
d559641 to
0fcfe0d
Compare


What does the PR do
This commit bumps status-go to include status-im/status-go#7440. As a result the message sending is paused while in the background to stop the high frequency mvds loops that will prevent Android from going into sleep. To preserve message sending while the app is in the background/killed we'll have to wake messenger briefly on the OS intent. We'll resume messenger for 60 seconds - enough to push the message through and then it will be paused again unless the app goes back to foreground.
This results in less battery usage and less events piling up in the qt event loop while the app is in the background.
Closes: #20742
Affected areas
Actions within the push notifications on android. E.g. Reply, accept contact request
Quality checklist
My PR is consistent with this document: QML Architecture Guidelines
Screencapture of the functionality
Impact on end user
The battery usage is reduced while status-go runs in the background.
Restoring the app will be faster after running in the background for a long time.
How to test
Login and kill the app.
Let it there for a few hours and compare the battery usage.
Receive contact request and message push notifications and respond from within the android notification.
Risk
Risk of breaking the push notifications actions.