nsclient ackAlarm local
This commit is contained in:
parent
d60321b4d1
commit
3500e92a41
3 changed files with 18 additions and 13 deletions
|
@ -96,14 +96,6 @@
|
||||||
<action android:name="info.nightscout.client.DBACCESS" />
|
<action android:name="info.nightscout.client.DBACCESS" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</receiver>
|
</receiver>
|
||||||
<receiver
|
|
||||||
android:name=".plugins.NSClientInternal.receivers.AckAlarmReceiver"
|
|
||||||
android:enabled="true"
|
|
||||||
android:exported="true">
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="info.nightscout.client.ACK_ALARM" />
|
|
||||||
</intent-filter>
|
|
||||||
</receiver>
|
|
||||||
|
|
||||||
<!-- Service processing incomming data -->
|
<!-- Service processing incomming data -->
|
||||||
<service
|
<service
|
||||||
|
|
|
@ -35,6 +35,7 @@ import info.nightscout.androidaps.plugins.InsulinFastactingProlonged.InsulinFast
|
||||||
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Loop.LoopFragment;
|
import info.nightscout.androidaps.plugins.Loop.LoopFragment;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.NSClientInternalFragment;
|
import info.nightscout.androidaps.plugins.NSClientInternal.NSClientInternalFragment;
|
||||||
|
import info.nightscout.androidaps.plugins.NSClientInternal.receivers.AckAlarmReceiver;
|
||||||
import info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAFragment;
|
import info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAFragment;
|
||||||
import info.nightscout.androidaps.plugins.OpenAPSMA.OpenAPSMAFragment;
|
import info.nightscout.androidaps.plugins.OpenAPSMA.OpenAPSMAFragment;
|
||||||
import info.nightscout.androidaps.plugins.Overview.OverviewFragment;
|
import info.nightscout.androidaps.plugins.Overview.OverviewFragment;
|
||||||
|
@ -84,7 +85,7 @@ public class MainApp extends Application {
|
||||||
|
|
||||||
private static DataReceiver dataReceiver = new DataReceiver();
|
private static DataReceiver dataReceiver = new DataReceiver();
|
||||||
private static NSAlarmReceiver alarmReciever = new NSAlarmReceiver();
|
private static NSAlarmReceiver alarmReciever = new NSAlarmReceiver();
|
||||||
|
private static AckAlarmReceiver ackAlarmReciever = new AckAlarmReceiver();
|
||||||
private LocalBroadcastManager lbm;
|
private LocalBroadcastManager lbm;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -188,9 +189,8 @@ public class MainApp extends Application {
|
||||||
lbm.registerReceiver(alarmReciever, new IntentFilter(Intents.ACTION_CLEAR_ALARM));
|
lbm.registerReceiver(alarmReciever, new IntentFilter(Intents.ACTION_CLEAR_ALARM));
|
||||||
lbm.registerReceiver(alarmReciever, new IntentFilter(Intents.ACTION_URGENT_ALARM));
|
lbm.registerReceiver(alarmReciever, new IntentFilter(Intents.ACTION_URGENT_ALARM));
|
||||||
|
|
||||||
|
|
||||||
//register ack alarm
|
//register ack alarm
|
||||||
|
lbm.registerReceiver(ackAlarmReciever, new IntentFilter(Intents.ACTION_ACK_ALARM));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startKeepAliveService() {
|
private void startKeepAliveService() {
|
||||||
|
|
|
@ -4,12 +4,14 @@ import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.ResolveInfo;
|
import android.content.pm.ResolveInfo;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.content.LocalBroadcastManager;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.Services.Intents;
|
import info.nightscout.androidaps.Services.Intents;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSAlarm;
|
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSAlarm;
|
||||||
import info.nightscout.utils.SP;
|
import info.nightscout.utils.SP;
|
||||||
|
@ -22,7 +24,7 @@ public class BroadcastAckAlarm {
|
||||||
private static Logger log = LoggerFactory.getLogger(BroadcastAckAlarm.class);
|
private static Logger log = LoggerFactory.getLogger(BroadcastAckAlarm.class);
|
||||||
|
|
||||||
public static void handleClearAlarm(NSAlarm originalAlarm, Context context, long silenceTimeInMsec) {
|
public static void handleClearAlarm(NSAlarm originalAlarm, Context context, long silenceTimeInMsec) {
|
||||||
if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
|
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putInt("level", originalAlarm.getLevel());
|
bundle.putInt("level", originalAlarm.getLevel());
|
||||||
bundle.putString("group", originalAlarm.getGroup());
|
bundle.putString("group", originalAlarm.getGroup());
|
||||||
|
@ -30,7 +32,18 @@ public class BroadcastAckAlarm {
|
||||||
Intent intent = new Intent(Intents.ACTION_ACK_ALARM);
|
Intent intent = new Intent(Intents.ACTION_ACK_ALARM);
|
||||||
intent.putExtras(bundle);
|
intent.putExtras(bundle);
|
||||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||||
context.sendBroadcast(intent);
|
LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
|
||||||
|
|
||||||
|
if(SP.getBoolean("nsclient_localbroadcasts", true)) {
|
||||||
|
bundle = new Bundle();
|
||||||
|
bundle.putInt("level", originalAlarm.getLevel());
|
||||||
|
bundle.putString("group", originalAlarm.getGroup());
|
||||||
|
bundle.putLong("silenceTime", silenceTimeInMsec);
|
||||||
|
intent = new Intent(Intents.ACTION_ACK_ALARM);
|
||||||
|
intent.putExtras(bundle);
|
||||||
|
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||||
|
context.sendBroadcast(intent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue