Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Fixed
- Fixed alarms not stopping when dismissed or snoozed after being deleted while ringing ([#406])

## [1.6.0] - 2026-01-30
### Added
Expand Down Expand Up @@ -111,6 +113,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[#247]: https://github.com/FossifyOrg/Clock/issues/247
[#335]: https://github.com/FossifyOrg/Clock/issues/335
[#346]: https://github.com/FossifyOrg/Clock/issues/346
[#406]: https://github.com/FossifyOrg/Clock/issues/406

[Unreleased]: https://github.com/FossifyOrg/Clock/compare/1.6.0...HEAD
[1.6.0]: https://github.com/FossifyOrg/Clock/compare/1.5.0...1.6.0
Expand Down
17 changes: 14 additions & 3 deletions app/src/main/kotlin/org/fossify/clock/services/AlarmService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,25 @@ class AlarmService : Service() {
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
val action = intent?.action ?: ACTION_START_ALARM
val alarmId = intent?.getIntExtra(ALARM_ID, -1) ?: -1
val newAlarm = applicationContext.dbHelper.getAlarmWithId(alarmId)
if (alarmId == -1 || newAlarm == null) {
if (alarmId == -1) {
stopSelfIfIdle()
return START_NOT_STICKY
}

when (action) {
ACTION_START_ALARM -> startNewAlarm(newAlarm)
ACTION_START_ALARM -> {
// Starting requires the alarm to still exist in the DB.
val newAlarm = applicationContext.dbHelper.getAlarmWithId(alarmId)
if (newAlarm == null) {
stopSelfIfIdle()
return START_NOT_STICKY
}

startNewAlarm(newAlarm)
}

// Stopping only needs the id, so an alarm deleted while ringing
// can still be dismissed/snoozed. See issue #406.
ACTION_STOP_ALARM -> stopActiveAlarm(alarmId)
else -> throw IllegalArgumentException("Unknown action: $action")
}
Expand Down
Loading