From d7ad74056d4aaedbefd30d773e459a75c98ad0a4 Mon Sep 17 00:00:00 2001 From: p5nbTgip0r Date: Mon, 1 Aug 2022 20:13:05 -0700 Subject: [PATCH] fix: don't restart alarm sound service automatically This sets the alarm sound service to not be sticky. If AAPS is stopped while an alarm is playing, the alarm sound service will be started again by the system but there's no built-in way to stop it after this happens. This commit makes it so the alarm sound service won't be restarted by Android, thereby avoiding the aforementioned issue. --- .../info/nightscout/androidaps/services/AlarmSoundService.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/info/nightscout/androidaps/services/AlarmSoundService.kt b/core/src/main/java/info/nightscout/androidaps/services/AlarmSoundService.kt index 5fbe786c73..8b10cb6a97 100644 --- a/core/src/main/java/info/nightscout/androidaps/services/AlarmSoundService.kt +++ b/core/src/main/java/info/nightscout/androidaps/services/AlarmSoundService.kt @@ -74,7 +74,7 @@ class AlarmSoundService : DaggerService() { if (intent?.hasExtra(ErrorHelperActivity.SOUND_ID) == true) resourceId = intent.getIntExtra(ErrorHelperActivity.SOUND_ID, R.raw.error) player = MediaPlayer() try { - val afd = rh.openRawResourceFd(resourceId) ?: return START_STICKY + val afd = rh.openRawResourceFd(resourceId) ?: return START_NOT_STICKY player?.setDataSource(afd.fileDescriptor, afd.startOffset, afd.length) afd.close() player?.isLooping = true @@ -94,7 +94,7 @@ class AlarmSoundService : DaggerService() { aapsLogger.error("Unhandled exception", e) } aapsLogger.debug(LTag.CORE, "onStartCommand End") - return START_STICKY + return START_NOT_STICKY } override fun onDestroy() {