fix(calendar): don't register calendar observer before permission granted
All checks were successful
CI / ci (push) Successful in 4m15s
All checks were successful
CI / ci (push) Successful in 4m15s
The repository registers a ContentObserver on the calendar provider eagerly in its init block, and an activity-scoped SettingsViewModel (which drives the theme) injects that repository — so the @Singleton is constructed at launch, above RootScreen's permission gate. On newer Android, registering an observer on a provider you lack permission for throws SecurityException instead of silently no-op'ing, so the app crashed instantly on every launch whenever calendar access wasn't granted (fresh install or revoked permission), before the permission screen could ever appear. Guard the registration behind a calendar-permission check and re-attach the observer lazily on the first calendars()/instances() read, which runs once the gate opens and screens subscribe. Access to the observer collections is now synchronized since registration can happen on the main thread (repo init) or the IO dispatcher (query re-attach). Verified on-device: permission-denied launch shows the permission screen instead of crashing; granting it proceeds to the calendar with live updates. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
10
CHANGELOG.md
10
CHANGELOG.md
@@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [2.7.1] — 2026-06-21
|
||||
|
||||
### Fixed
|
||||
- Fixed the app crashing immediately on launch whenever calendar access hadn't
|
||||
been granted yet (a fresh install, or after revoking the permission). The app
|
||||
set up its live calendar-change listener before the permission screen could
|
||||
appear, which newer Android versions reject outright — so the app died before
|
||||
you could grant access. The listener now waits for the permission and attaches
|
||||
itself the moment it's granted.
|
||||
|
||||
## [2.7.0] — 2026-06-18
|
||||
|
||||
### Added
|
||||
|
||||
Reference in New Issue
Block a user