From b8a41e5f5b5cdee65173810cf916c61f9d2b10aa Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sat, 28 Jul 2018 13:55:16 +0200 Subject: [PATCH] ALARM logging --- .../java/info/nightscout/androidaps/Config.java | 1 + .../java/info/nightscout/androidaps/Constants.java | 1 + .../androidaps/Services/AlarmSoundService.java | 14 ++++++++++---- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/Config.java b/app/src/main/java/info/nightscout/androidaps/Config.java index 04f40669e7..3612ee8898 100644 --- a/app/src/main/java/info/nightscout/androidaps/Config.java +++ b/app/src/main/java/info/nightscout/androidaps/Config.java @@ -39,6 +39,7 @@ public class Config { public static final boolean logBgSource = true; public static final boolean logOverview = true; public static final boolean logNotification = true; + public static final boolean logAlarm = false; // DanaR specific public static final boolean logDanaBTComm = true; diff --git a/app/src/main/java/info/nightscout/androidaps/Constants.java b/app/src/main/java/info/nightscout/androidaps/Constants.java index 6b2f3d4ac1..0b9c0a408e 100644 --- a/app/src/main/java/info/nightscout/androidaps/Constants.java +++ b/app/src/main/java/info/nightscout/androidaps/Constants.java @@ -75,4 +75,5 @@ public class Constants { public static final String BGSOURCE = "BGSOURCE"; public static final String OVERVIEW = "OVERVIEW"; public static final String NOTIFICATION = "NOTIFICATION"; + public static final String ALARM = "ALARM"; } diff --git a/app/src/main/java/info/nightscout/androidaps/Services/AlarmSoundService.java b/app/src/main/java/info/nightscout/androidaps/Services/AlarmSoundService.java index f453b04d36..87fd77ca04 100644 --- a/app/src/main/java/info/nightscout/androidaps/Services/AlarmSoundService.java +++ b/app/src/main/java/info/nightscout/androidaps/Services/AlarmSoundService.java @@ -13,11 +13,13 @@ import org.slf4j.LoggerFactory; import java.io.IOException; +import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; public class AlarmSoundService extends Service { - private static Logger log = LoggerFactory.getLogger(AlarmSoundService.class); + private static Logger log = LoggerFactory.getLogger(Constants.ALARM); MediaPlayer player; int resourceId = R.raw.error; @@ -34,13 +36,15 @@ public class AlarmSoundService extends Service { @Override public void onCreate() { super.onCreate(); - log.debug("onCreate"); + if (Config.logAlarm) + log.debug("onCreate"); } public int onStartCommand(Intent intent, int flags, int startId) { if (player != null && player.isPlaying()) player.stop(); - log.debug("onStartCommand"); + if (Config.logAlarm) + log.debug("onStartCommand"); if (intent != null && intent.hasExtra("soundid")) resourceId = intent.getIntExtra("soundid", R.raw.error); @@ -55,7 +59,7 @@ public class AlarmSoundService extends Service { log.error("Unhandled exception", e); } player.setLooping(true); // Set looping - AudioManager manager = (AudioManager)this.getSystemService(Context.AUDIO_SERVICE); + AudioManager manager = (AudioManager) this.getSystemService(Context.AUDIO_SERVICE); if (manager == null || !manager.isMusicActive()) { player.setVolume(100, 100); } @@ -74,5 +78,7 @@ public class AlarmSoundService extends Service { public void onDestroy() { player.stop(); player.release(); + if (Config.logAlarm) + log.debug("onDestroy"); } }