refactor cancelAlarm back to KeepAliveReceiver
This commit is contained in:
parent
14810a142d
commit
ca9b68da0d
3 changed files with 8 additions and 9 deletions
|
@ -70,7 +70,6 @@ import info.nightscout.androidaps.plugins.XDripStatusline.StatuslinePlugin;
|
||||||
import info.nightscout.androidaps.receivers.DataReceiver;
|
import info.nightscout.androidaps.receivers.DataReceiver;
|
||||||
import info.nightscout.androidaps.receivers.KeepAliveReceiver;
|
import info.nightscout.androidaps.receivers.KeepAliveReceiver;
|
||||||
import info.nightscout.androidaps.receivers.NSAlarmReceiver;
|
import info.nightscout.androidaps.receivers.NSAlarmReceiver;
|
||||||
import info.nightscout.utils.LocalAlertUtils;
|
|
||||||
import info.nightscout.utils.NSUpload;
|
import info.nightscout.utils.NSUpload;
|
||||||
import io.fabric.sdk.android.Fabric;
|
import io.fabric.sdk.android.Fabric;
|
||||||
|
|
||||||
|
@ -216,7 +215,7 @@ public class MainApp extends Application {
|
||||||
|
|
||||||
public void stopKeepAliveService() {
|
public void stopKeepAliveService() {
|
||||||
if (keepAliveReceiver != null)
|
if (keepAliveReceiver != null)
|
||||||
LocalAlertUtils.cancelAlarm(this);
|
KeepAliveReceiver.cancelAlarm(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Bus bus() {
|
public static Bus bus() {
|
||||||
|
|
|
@ -27,6 +27,13 @@ public class KeepAliveReceiver extends BroadcastReceiver {
|
||||||
private static Logger log = LoggerFactory.getLogger(KeepAliveReceiver.class);
|
private static Logger log = LoggerFactory.getLogger(KeepAliveReceiver.class);
|
||||||
public static final long STATUS_UPDATE_FREQUENCY = 15 * 60 * 1000L;
|
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
|
@Override
|
||||||
public void onReceive(Context context, Intent rIntent) {
|
public void onReceive(Context context, Intent rIntent) {
|
||||||
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
||||||
|
|
|
@ -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() {
|
public static void shortenSnoozeInterval() {
|
||||||
//shortens alarm times in case of setting changes or future data
|
//shortens alarm times in case of setting changes or future data
|
||||||
long nextMissedReadingsAlarm = SP.getLong("nextMissedReadingsAlarm", 0L);
|
long nextMissedReadingsAlarm = SP.getLong("nextMissedReadingsAlarm", 0L);
|
||||||
|
|
Loading…
Reference in a new issue