Extract SensorReceiverBase update logic into SensorUpdater - #7107
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors sensor update/sync responsibilities by extracting the SensorReceiverBase update logic into a new injectable SensorUpdater, removing reliance on system-instantiated receiver instances, and separating beacon stop handling into a dedicated receiver.
Changes:
- Introduce
SensorUpdaterand route broadcast/worker-driven updates through it. - Consolidate periodic sensor WorkManager logic into
commonand remove app/wear wrapper workers. - Move beacon “Disable” notification action handling into
StopBeaconScanningReceiver, and rework Bluetooth update triggers to avoid broadcasting to removed receivers.
Reviewed changes
Copilot reviewed 24 out of 24 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| wear/src/main/kotlin/io/homeassistant/companion/android/sensors/WearSensorModule.kt | Provides wear-specific SensorSettingsIntentProvider for permission-missing notifications |
| wear/src/main/kotlin/io/homeassistant/companion/android/sensors/SensorWorker.kt | Removed wear wrapper worker in favor of common worker |
| wear/src/main/kotlin/io/homeassistant/companion/android/sensors/SensorReceiver.kt | Simplifies wear receiver; delegates update logic to base/updater |
| wear/src/main/kotlin/io/homeassistant/companion/android/notifications/MessagingManager.kt | Updates device command wiring to new Bluetooth command APIs |
| wear/src/main/kotlin/io/homeassistant/companion/android/home/HomeActivity.kt | Switches to using common SensorWorker |
| common/src/test/kotlin/io/homeassistant/companion/android/common/sensors/SensorUpdaterTest.kt | Adds basic unit tests for SensorUpdater update entrypoints |
| common/src/test/kotlin/io/homeassistant/companion/android/common/CommonTestModule.kt | Adds test binding for SensorSettingsIntentProvider |
| common/src/main/kotlin/io/homeassistant/companion/android/common/sensors/StopBeaconScanningReceiver.kt | New receiver dedicated to stopping beacon scanning from notification action |
| common/src/main/kotlin/io/homeassistant/companion/android/common/sensors/SensorWorker.kt | Replaces SensorWorkerBase with concrete worker + start() scheduling |
| common/src/main/kotlin/io/homeassistant/companion/android/common/sensors/SensorUpdateReceiver.kt | Removed common-module update receiver |
| common/src/main/kotlin/io/homeassistant/companion/android/common/sensors/SensorUpdater.kt | New central implementation of update + per-server sync/registration logic |
| common/src/main/kotlin/io/homeassistant/companion/android/common/sensors/SensorReceiverBase.kt | Delegates update paths to SensorUpdater and removes embedded sync logic |
| common/src/main/kotlin/io/homeassistant/companion/android/common/sensors/BluetoothSensorManager.kt | Moves enable/disable helpers into manager and triggers Bluetooth-only sync via updater |
| common/src/main/kotlin/io/homeassistant/companion/android/common/notifications/DeviceCommands.kt | Updates BLE/beacon device commands to call Bluetooth manager directly |
| common/src/main/kotlin/io/homeassistant/companion/android/common/bluetooth/ble/MonitoringManager.kt | Updates “Disable” action to target the new stop-scanning receiver |
| common/src/main/kotlin/io/homeassistant/companion/android/common/bluetooth/ble/IBeaconMonitor.kt | Removes need for Context in beacon updates; triggers Bluetooth-only sync via manager |
| common/src/main/AndroidManifest.xml | Removes SensorUpdateReceiver registration; registers StopBeaconScanningReceiver |
| app/src/test/kotlin/io/homeassistant/companion/android/launch/LaunchActivityTest.kt | Switches to using common SensorWorker import |
| app/src/main/kotlin/io/homeassistant/companion/android/webview/WebViewActivity.kt | Switches to using common SensorWorker import |
| app/src/main/kotlin/io/homeassistant/companion/android/sensors/SensorWorker.kt | Removed app wrapper worker in favor of common worker |
| app/src/main/kotlin/io/homeassistant/companion/android/sensors/SensorReceiver.kt | Simplifies app receiver; delegates update logic to base/updater |
| app/src/main/kotlin/io/homeassistant/companion/android/sensors/AppSensorModule.kt | Provides app-specific SensorSettingsIntentProvider for permission-missing notifications |
| app/src/main/kotlin/io/homeassistant/companion/android/notifications/MessagingManager.kt | Updates device command wiring to new Bluetooth command APIs |
| app/src/main/kotlin/io/homeassistant/companion/android/launch/LaunchActivity.kt | Switches to using common SensorWorker |
TimoPtr
force-pushed
the
feature/remove_database_entrypoint
branch
from
June 30, 2026 14:13
f389973 to
96d87fb
Compare
TimoPtr
force-pushed
the
feature/rework_sensor_worker_receiver
branch
from
June 30, 2026 14:13
eafad21 to
46d86fb
Compare
TimoPtr
force-pushed
the
feature/remove_database_entrypoint
branch
from
July 1, 2026 10:11
96d87fb to
d87a5fa
Compare
TimoPtr
force-pushed
the
feature/rework_sensor_worker_receiver
branch
from
July 1, 2026 10:11
46d86fb to
845bdd3
Compare
jpelgrom
reviewed
Jul 1, 2026
jpelgrom
left a comment
Member
There was a problem hiding this comment.
Already tested functionality with previous PRs, as the other sensor PRs need this to build. Only one minor comment about the use of "update" which now can mean two things.
Copilot/Lint can be ignored for now as you've copied it, I would like to avoid any functional changes we don't need.
Merged
jpelgrom
approved these changes
Jul 1, 2026
4 tasks
TimoPtr
force-pushed
the
feature/remove_database_entrypoint
branch
from
July 2, 2026 09:05
d87a5fa to
581bdf2
Compare
TimoPtr
force-pushed
the
feature/rework_sensor_worker_receiver
branch
2 times, most recently
from
July 2, 2026 09:43
835ac9d to
7a727d4
Compare
TimoPtr
force-pushed
the
feature/rework_sensor_worker_receiver
branch
from
July 2, 2026 10:10
7a727d4 to
e2f5a72
Compare
TimoPtr
enabled auto-merge (squash)
July 2, 2026 10:11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR is a wider refactor required to merge at the same time as #7106 and #7040, it fixes issues where we were using
SensorReceiverinstance, we shouldn't because it's android components instantiated by the system. To achieve that I had to modify the bluetooth manager and remove the companion function that are now within the manager directly, so that we can use a newSensorUpdater. TheSensorUpdateris a class that we can inject and use to require an update of sensors.I had also to move the stop of the beacon into its own receiver it was mixed within the
SensorReceiver.Overall it simplifies a bit the code by removing some parameters and split responsibilities, I did add some very basic tests but it doesn't cover everything in the
SensorUpdater.Checklist
Any other notes
We could merge this one onto the base one if we want only one commit.