From 00f13d04793d2fa3b6086a6103db34324dec8d0f Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Sun, 17 Dec 2017 01:40:27 +0100 Subject: [PATCH] refactor cancelAlarm back to KeepAliveReceiver --- app/src/main/java/info/nightscout/androidaps/MainApp.java | 3 +-- .../nightscout/androidaps/receivers/KeepAliveReceiver.java | 7 +++++++ .../main/java/info/nightscout/utils/LocalAlertUtils.java | 7 ------- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/MainApp.java b/app/src/main/java/info/nightscout/androidaps/MainApp.java index 603c74da4d..bd0ba7695e 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainApp.java +++ b/app/src/main/java/info/nightscout/androidaps/MainApp.java @@ -69,7 +69,6 @@ import info.nightscout.androidaps.plugins.XDripStatusline.StatuslinePlugin; import info.nightscout.androidaps.receivers.DataReceiver; import info.nightscout.androidaps.receivers.KeepAliveReceiver; import info.nightscout.androidaps.receivers.NSAlarmReceiver; -import info.nightscout.utils.LocalAlertUtils; import info.nightscout.utils.NSUpload; import io.fabric.sdk.android.Fabric; @@ -214,7 +213,7 @@ public class MainApp extends Application { public void stopKeepAliveService() { if (keepAliveReceiver != null) - LocalAlertUtils.cancelAlarm(this); + KeepAliveReceiver.cancelAlarm(this); } public static Bus bus() { diff --git a/app/src/main/java/info/nightscout/androidaps/receivers/KeepAliveReceiver.java b/app/src/main/java/info/nightscout/androidaps/receivers/KeepAliveReceiver.java index fc411372a3..44d0da2c55 100644 --- a/app/src/main/java/info/nightscout/androidaps/receivers/KeepAliveReceiver.java +++ b/app/src/main/java/info/nightscout/androidaps/receivers/KeepAliveReceiver.java @@ -27,6 +27,13 @@ public class KeepAliveReceiver extends BroadcastReceiver { private static Logger log = LoggerFactory.getLogger(KeepAliveReceiver.class); public static final long STATUS_UPDATE_FREQUENCY = 15 * 60 * 1000L; + public static void cancelAlarm(Context context) { + Intent intent = new Intent(context, KeepAliveReceiver.class); + PendingIntent sender = PendingIntent.getBroadcast(context, 0, intent, 0); + AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); + alarmManager.cancel(sender); + } + @Override public void onReceive(Context context, Intent rIntent) { PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); diff --git a/app/src/main/java/info/nightscout/utils/LocalAlertUtils.java b/app/src/main/java/info/nightscout/utils/LocalAlertUtils.java index a872b1d9ec..e74818d447 100644 --- a/app/src/main/java/info/nightscout/utils/LocalAlertUtils.java +++ b/app/src/main/java/info/nightscout/utils/LocalAlertUtils.java @@ -57,13 +57,6 @@ public class LocalAlertUtils { } } - public static void cancelAlarm(Context context) { - Intent intent = new Intent(context, KeepAliveReceiver.class); - PendingIntent sender = PendingIntent.getBroadcast(context, 0, intent, 0); - AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); - alarmManager.cancel(sender); - } - public static void shortenSnoozeInterval() { //shortens alarm times in case of setting changes or future data long nextMissedReadingsAlarm = SP.getLong("nextMissedReadingsAlarm", 0L);