Merge pull request #323 from MilosKozak/nsclient-local-second

Nsclient local broadcasts
This commit is contained in:
Milos Kozak 2017-07-25 19:51:57 +02:00 committed by GitHub
commit 4bb3b7c11d
19 changed files with 310 additions and 99 deletions

View file

@ -56,16 +56,6 @@
android:enabled="true" android:enabled="true"
android:exported="true"> android:exported="true">
<intent-filter> <intent-filter>
<!-- Receiver from NSClient -->
<action android:name="info.nightscout.client.NEW_SGV" />
<action android:name="info.nightscout.client.NEW_TREATMENT" />
<action android:name="info.nightscout.client.CHANGED_TREATMENT" />
<action android:name="info.nightscout.client.REMOVED_TREATMENT" />
<action android:name="info.nightscout.client.NEW_PROFILE" />
<action android:name="info.nightscout.client.NEW_STATUS" />
<action android:name="info.nightscout.client.NEW_MBG" />
<action android:name="info.nightscout.client.NEW_DEVICESTATUS" />
<action android:name="info.nightscout.client.NEW_CAL" />
<!-- Receive new SMS messages --> <!-- Receive new SMS messages -->
<action android:name="android.provider.Telephony.SMS_RECEIVED" /> <action android:name="android.provider.Telephony.SMS_RECEIVED" />
<!-- Receiver from xDrip --> <!-- Receiver from xDrip -->
@ -76,20 +66,6 @@
<action android:name="it.ct.glicemia.ACTION_GLUCOSE_MEASURED" /> <action android:name="it.ct.glicemia.ACTION_GLUCOSE_MEASURED" />
</intent-filter> </intent-filter>
</receiver> </receiver>
<receiver
android:name=".receivers.NSAlarmReceiver"
android:enabled="true"
android:exported="true">
<intent-filter>
<!-- Receiver from NSClient -->
<action android:name="info.nightscout.client.ANNOUNCEMENT" />
<action android:name="info.nightscout.client.ALARM" />
<action android:name="info.nightscout.client.URGENT_ALARM" />
<action android:name="info.nightscout.client.CLEAR_ALARM" />
</intent-filter>
</receiver>
<!-- Receiver keepalive, scheduled every 30 min --> <!-- Receiver keepalive, scheduled every 30 min -->
<receiver android:name=".receivers.KeepAliveReceiver" /> <receiver android:name=".receivers.KeepAliveReceiver" />
@ -120,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

View file

@ -2,8 +2,10 @@ package info.nightscout.androidaps;
import android.app.Application; import android.app.Application;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Resources; import android.content.res.Resources;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v4.content.LocalBroadcastManager;
import com.crashlytics.android.Crashlytics; import com.crashlytics.android.Crashlytics;
import com.crashlytics.android.answers.Answers; import com.crashlytics.android.answers.Answers;
@ -17,6 +19,7 @@ import org.slf4j.LoggerFactory;
import java.util.ArrayList; import java.util.ArrayList;
import info.nightscout.androidaps.Services.Intents;
import info.nightscout.androidaps.db.DatabaseHelper; import info.nightscout.androidaps.db.DatabaseHelper;
import info.nightscout.androidaps.interfaces.InsulinInterface; import info.nightscout.androidaps.interfaces.InsulinInterface;
import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginBase;
@ -32,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;
@ -59,7 +63,9 @@ import info.nightscout.androidaps.plugins.SourceXdrip.SourceXdripPlugin;
import info.nightscout.androidaps.plugins.Treatments.TreatmentsFragment; import info.nightscout.androidaps.plugins.Treatments.TreatmentsFragment;
import info.nightscout.androidaps.plugins.Wear.WearFragment; import info.nightscout.androidaps.plugins.Wear.WearFragment;
import info.nightscout.androidaps.plugins.XDripStatusline.StatuslinePlugin; import info.nightscout.androidaps.plugins.XDripStatusline.StatuslinePlugin;
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.utils.NSUpload; import info.nightscout.utils.NSUpload;
import io.fabric.sdk.android.Fabric; import io.fabric.sdk.android.Fabric;
@ -77,6 +83,11 @@ public class MainApp extends Application {
private static ArrayList<PluginBase> pluginsList = null; private static ArrayList<PluginBase> pluginsList = null;
private static DataReceiver dataReceiver = new DataReceiver();
private static NSAlarmReceiver alarmReciever = new NSAlarmReceiver();
private static AckAlarmReceiver ackAlarmReciever = new AckAlarmReceiver();
private LocalBroadcastManager lbm;
@Override @Override
public void onCreate() { public void onCreate() {
super.onCreate(); super.onCreate();
@ -92,6 +103,8 @@ public class MainApp extends Application {
sInstance = this; sInstance = this;
sResources = getResources(); sResources = getResources();
registerLocalBroadcastReceiver();
if (pluginsList == null) { if (pluginsList == null) {
pluginsList = new ArrayList<>(); pluginsList = new ArrayList<>();
// Register all tabs in app here // Register all tabs in app here
@ -155,6 +168,29 @@ public class MainApp extends Application {
} }
}); });
t.start(); t.start();
}
private void registerLocalBroadcastReceiver() {
lbm = LocalBroadcastManager.getInstance(this);
lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_NEW_TREATMENT));
lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_CHANGED_TREATMENT));
lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_REMOVED_TREATMENT));
lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_NEW_SGV));
lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_NEW_PROFILE));
lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_NEW_STATUS));
lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_NEW_MBG));
lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_NEW_DEVICESTATUS));
lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_NEW_CAL));
//register alarms
lbm.registerReceiver(alarmReciever, new IntentFilter(Intents.ACTION_ALARM));
lbm.registerReceiver(alarmReciever, new IntentFilter(Intents.ACTION_ANNOUNCEMENT));
lbm.registerReceiver(alarmReciever, new IntentFilter(Intents.ACTION_CLEAR_ALARM));
lbm.registerReceiver(alarmReciever, new IntentFilter(Intents.ACTION_URGENT_ALARM));
//register ack alarm
lbm.registerReceiver(ackAlarmReciever, new IntentFilter(Intents.ACTION_ACK_ALARM));
} }
private void startKeepAliveService() { private void startKeepAliveService() {

View file

@ -506,7 +506,7 @@ public class DataService extends IntentService {
MainApp.getDbHelper().createCareportalEventFromJsonIfNotExists(trJson); MainApp.getDbHelper().createCareportalEventFromJsonIfNotExists(trJson);
} }
if (trJson.getString("eventType").equals(CareportalEvent.ANNOUNCEMENT)) { if (trJson.has("eventType") && trJson.getString("eventType").equals(CareportalEvent.ANNOUNCEMENT)) {
long date = trJson.getLong("mills"); long date = trJson.getLong("mills");
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
if (date > now - 15 * 60 * 1000L && trJson.has("notes")) { if (date > now - 15 * 60 * 1000L && trJson.has("notes")) {

View file

@ -4,12 +4,15 @@ 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.R;
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 +25,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 +33,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(R.string.key_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);
}
} }
} }

View file

@ -4,6 +4,7 @@ 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.json.JSONObject; import org.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -11,6 +12,8 @@ import org.slf4j.LoggerFactory;
import java.util.List; import java.util.List;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.Services.Intents; import info.nightscout.androidaps.Services.Intents;
import info.nightscout.utils.SP; import info.nightscout.utils.SP;
@ -21,14 +24,20 @@ public class BroadcastAlarm {
private static Logger log = LoggerFactory.getLogger(BroadcastAlarm.class); private static Logger log = LoggerFactory.getLogger(BroadcastAlarm.class);
public static void handleAlarm(JSONObject alarm, Context context) { public static void handleAlarm(JSONObject alarm, Context context) {
if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString("data", alarm.toString()); bundle.putString("data", alarm.toString());
Intent intent = new Intent(Intents.ACTION_ALARM); Intent intent = new Intent(Intents.ACTION_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(R.string.key_nsclient_localbroadcasts, true)) {
bundle = new Bundle();
bundle.putString("data", alarm.toString());
intent = new Intent(Intents.ACTION_ALARM);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
context.sendBroadcast(intent);
}
} }
} }

View file

@ -4,6 +4,7 @@ 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.json.JSONArray; import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
@ -12,6 +13,8 @@ import org.slf4j.LoggerFactory;
import java.util.List; import java.util.List;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.Services.Intents; import info.nightscout.androidaps.Services.Intents;
import info.nightscout.utils.SP; import info.nightscout.utils.SP;
@ -22,14 +25,20 @@ public class BroadcastAnnouncement {
private static Logger log = LoggerFactory.getLogger(BroadcastAnnouncement.class); private static Logger log = LoggerFactory.getLogger(BroadcastAnnouncement.class);
public static void handleAnnouncement(JSONObject announcement, Context context) { public static void handleAnnouncement(JSONObject announcement, Context context) {
if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString("data", announcement.toString()); bundle.putString("data", announcement.toString());
Intent intent = new Intent(Intents.ACTION_ANNOUNCEMENT); Intent intent = new Intent(Intents.ACTION_ANNOUNCEMENT);
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(R.string.key_nsclient_localbroadcasts, true)) {
bundle = new Bundle();
bundle.putString("data", announcement.toString());
intent = new Intent(Intents.ACTION_ANNOUNCEMENT);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
context.sendBroadcast(intent);
}
} }
} }

View file

@ -4,6 +4,7 @@ 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.json.JSONArray; import org.json.JSONArray;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -11,6 +12,8 @@ import org.slf4j.LoggerFactory;
import java.util.List; import java.util.List;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.Services.Intents; import info.nightscout.androidaps.Services.Intents;
import info.nightscout.utils.SP; import info.nightscout.utils.SP;
@ -22,14 +25,22 @@ public class BroadcastCals {
public static void handleNewCal(JSONArray cals, Context context, boolean isDelta) { public static void handleNewCal(JSONArray cals, Context context, boolean isDelta) {
if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString("cals", cals.toString()); bundle.putString("cals", cals.toString());
bundle.putBoolean("delta", isDelta); bundle.putBoolean("delta", isDelta);
Intent intent = new Intent(Intents.ACTION_NEW_CAL); Intent intent = new Intent(Intents.ACTION_NEW_CAL);
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(R.string.key_nsclient_localbroadcasts, true)) {
bundle = new Bundle();
bundle.putString("cals", cals.toString());
bundle.putBoolean("delta", isDelta);
intent = new Intent(Intents.ACTION_NEW_CAL);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
context.sendBroadcast(intent);
}
} }
} }

View file

@ -4,6 +4,7 @@ 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.json.JSONObject; import org.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -11,6 +12,8 @@ import org.slf4j.LoggerFactory;
import java.util.List; import java.util.List;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.Services.Intents; import info.nightscout.androidaps.Services.Intents;
import info.nightscout.utils.SP; import info.nightscout.utils.SP;
@ -21,14 +24,20 @@ public class BroadcastClearAlarm {
private static Logger log = LoggerFactory.getLogger(BroadcastClearAlarm.class); private static Logger log = LoggerFactory.getLogger(BroadcastClearAlarm.class);
public static void handleClearAlarm(JSONObject clearalarm, Context context) { public static void handleClearAlarm(JSONObject clearalarm, Context context) {
if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString("data", clearalarm.toString()); bundle.putString("data", clearalarm.toString());
Intent intent = new Intent(Intents.ACTION_CLEAR_ALARM); Intent intent = new Intent(Intents.ACTION_CLEAR_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(R.string.key_nsclient_localbroadcasts, true)) {
bundle = new Bundle();
bundle.putString("data", clearalarm.toString());
intent = new Intent(Intents.ACTION_CLEAR_ALARM);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
context.sendBroadcast(intent);
}
} }
} }

View file

@ -4,6 +4,7 @@ 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.json.JSONArray; import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
@ -12,6 +13,8 @@ import org.slf4j.LoggerFactory;
import java.util.List; import java.util.List;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.Services.Intents; import info.nightscout.androidaps.Services.Intents;
import info.nightscout.utils.SP; import info.nightscout.utils.SP;
@ -26,14 +29,20 @@ public class BroadcastDeviceStatus {
Intent intent = new Intent(Intents.ACTION_NEW_DEVICESTATUS); Intent intent = new Intent(Intents.ACTION_NEW_DEVICESTATUS);
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(R.string.key_nsclient_localbroadcasts, true)) {
bundle = new Bundle();
bundle.putString("devicestatus", status.toString());
bundle.putBoolean("delta", isDelta);
intent = new Intent(Intents.ACTION_NEW_DEVICESTATUS);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
context.sendBroadcast(intent);
}
} }
public static void handleNewDeviceStatus(JSONArray statuses, Context context, boolean isDelta) { public static void handleNewDeviceStatus(JSONArray statuses, Context context, boolean isDelta) {
if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
List<JSONArray> splitted = BroadcastTreatment.splitArray(statuses); List<JSONArray> splitted = BroadcastTreatment.splitArray(statuses);
for (JSONArray part: splitted) { for (JSONArray part: splitted) {
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
@ -42,7 +51,20 @@ public class BroadcastDeviceStatus {
Intent intent = new Intent(Intents.ACTION_NEW_DEVICESTATUS); Intent intent = new Intent(Intents.ACTION_NEW_DEVICESTATUS);
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(R.string.key_nsclient_localbroadcasts, true)) {
splitted = BroadcastTreatment.splitArray(statuses);
for (JSONArray part : splitted) {
Bundle bundle = new Bundle();
bundle.putString("devicestatuses", part.toString());
bundle.putBoolean("delta", isDelta);
Intent intent = new Intent(Intents.ACTION_NEW_DEVICESTATUS);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
context.sendBroadcast(intent);
}
} }
} }
} }

View file

@ -4,6 +4,7 @@ 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.json.JSONArray; import org.json.JSONArray;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -11,6 +12,8 @@ import org.slf4j.LoggerFactory;
import java.util.List; import java.util.List;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.Services.Intents; import info.nightscout.androidaps.Services.Intents;
import info.nightscout.utils.SP; import info.nightscout.utils.SP;
@ -22,14 +25,22 @@ public class BroadcastMbgs {
public static void handleNewMbg(JSONArray mbgs, Context context, boolean isDelta) { public static void handleNewMbg(JSONArray mbgs, Context context, boolean isDelta) {
if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString("mbgs", mbgs.toString()); bundle.putString("mbgs", mbgs.toString());
bundle.putBoolean("delta", isDelta); bundle.putBoolean("delta", isDelta);
Intent intent = new Intent(Intents.ACTION_NEW_MBG); Intent intent = new Intent(Intents.ACTION_NEW_MBG);
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(R.string.key_nsclient_localbroadcasts, true)) {
bundle = new Bundle();
bundle.putString("mbgs", mbgs.toString());
bundle.putBoolean("delta", isDelta);
intent = new Intent(Intents.ACTION_NEW_MBG);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
context.sendBroadcast(intent);
}
} }
} }

View file

@ -4,12 +4,15 @@ 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.R;
import info.nightscout.androidaps.Services.Intents; import info.nightscout.androidaps.Services.Intents;
import info.nightscout.androidaps.data.ProfileStore; import info.nightscout.androidaps.data.ProfileStore;
import info.nightscout.utils.SP; import info.nightscout.utils.SP;
@ -23,15 +26,23 @@ public class BroadcastProfile {
public static void handleNewTreatment(ProfileStore profile, Context context, boolean isDelta) { public static void handleNewTreatment(ProfileStore profile, Context context, boolean isDelta) {
if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString("profile", profile.getData().toString()); bundle.putString("profile", profile.getData().toString());
bundle.putBoolean("delta", isDelta); bundle.putBoolean("delta", isDelta);
Intent intent = new Intent(Intents.ACTION_NEW_PROFILE); Intent intent = new Intent(Intents.ACTION_NEW_PROFILE);
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(R.string.key_nsclient_localbroadcasts, true)) {
bundle = new Bundle();
bundle.putString("profile", profile.getData().toString());
bundle.putBoolean("delta", isDelta);
intent = new Intent(Intents.ACTION_NEW_PROFILE);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
context.sendBroadcast(intent);
}
} }
} }

View file

@ -5,6 +5,7 @@ import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.os.PowerManager; import android.os.PowerManager;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.Services.Intents; import info.nightscout.androidaps.Services.Intents;
import info.nightscout.utils.SP; import info.nightscout.utils.SP;
@ -14,7 +15,7 @@ import info.nightscout.utils.SP;
public class BroadcastQueueStatus { public class BroadcastQueueStatus {
public static void handleNewStatus(int size, Context context) { public static void handleNewStatus(int size, Context context) {
if(!SP.getBoolean("nsclient_localbroadcasts", true)) return; if(!SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) return;
PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE); PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,

View file

@ -4,6 +4,7 @@ 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.json.JSONArray; import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
@ -12,6 +13,8 @@ import org.slf4j.LoggerFactory;
import java.util.List; import java.util.List;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.Services.Intents; import info.nightscout.androidaps.Services.Intents;
import info.nightscout.utils.SP; import info.nightscout.utils.SP;
@ -23,15 +26,23 @@ public class BroadcastSgvs {
public static void handleNewSgv(JSONObject sgv, Context context, boolean isDelta) { public static void handleNewSgv(JSONObject sgv, Context context, boolean isDelta) {
if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString("sgv", sgv.toString()); bundle.putString("sgv", sgv.toString());
bundle.putBoolean("delta", isDelta); bundle.putBoolean("delta", isDelta);
Intent intent = new Intent(Intents.ACTION_NEW_SGV); Intent intent = new Intent(Intents.ACTION_NEW_SGV);
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(R.string.key_nsclient_localbroadcasts, true)) {
bundle = new Bundle();
bundle.putString("sgv", sgv.toString());
bundle.putBoolean("delta", isDelta);
intent = new Intent(Intents.ACTION_NEW_SGV);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
context.sendBroadcast(intent);
}
} }
public static void handleNewSgv(JSONArray sgvs, Context context, boolean isDelta) { public static void handleNewSgv(JSONArray sgvs, Context context, boolean isDelta) {
@ -41,7 +52,17 @@ public class BroadcastSgvs {
Intent intent = new Intent(Intents.ACTION_NEW_SGV); Intent intent = new Intent(Intents.ACTION_NEW_SGV);
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(R.string.key_nsclient_localbroadcasts, true)) {
bundle = new Bundle();
bundle.putString("sgvs", sgvs.toString());
bundle.putBoolean("delta", isDelta);
intent = new Intent(Intents.ACTION_NEW_SGV);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
context.sendBroadcast(intent);
}
} }
} }

View file

@ -5,6 +5,7 @@ import android.content.Intent;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
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;
@ -12,6 +13,7 @@ import org.slf4j.LoggerFactory;
import java.util.List; import java.util.List;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.Services.Intents; import info.nightscout.androidaps.Services.Intents;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSSettingsStatus; import info.nightscout.androidaps.plugins.NSClientInternal.data.NSSettingsStatus;
import info.nightscout.androidaps.plugins.NSClientInternal.services.NSClientService; import info.nightscout.androidaps.plugins.NSClientInternal.services.NSClientService;
@ -25,8 +27,6 @@ public class BroadcastStatus {
public static void handleNewStatus(NSSettingsStatus status, Context context, boolean isDelta) { public static void handleNewStatus(NSSettingsStatus status, Context context, boolean isDelta) {
if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
try { try {
bundle.putString("nsclientversionname", MainApp.instance().getPackageManager().getPackageInfo(MainApp.instance().getPackageName(), 0).versionName); bundle.putString("nsclientversionname", MainApp.instance().getPackageManager().getPackageInfo(MainApp.instance().getPackageName(), 0).versionName);
@ -41,6 +41,24 @@ public class BroadcastStatus {
Intent intent = new Intent(Intents.ACTION_NEW_STATUS); Intent intent = new Intent(Intents.ACTION_NEW_STATUS);
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(R.string.key_nsclient_localbroadcasts, true)) {
bundle = new Bundle();
try {
bundle.putString("nsclientversionname", MainApp.instance().getPackageManager().getPackageInfo(MainApp.instance().getPackageName(), 0).versionName);
bundle.putInt("nsclientversioncode", MainApp.instance().getPackageManager().getPackageInfo(MainApp.instance().getPackageName(), 0).versionCode);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
bundle.putString("nightscoutversionname", NSClientService.nightscoutVersionName);
bundle.putInt("nightscoutversioncode", NSClientService.nightscoutVersionCode);
bundle.putString("status", status.getData().toString());
bundle.putBoolean("delta", isDelta);
intent = new Intent(Intents.ACTION_NEW_STATUS);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
context.sendBroadcast(intent);
}
} }
} }

View file

@ -5,6 +5,7 @@ import android.content.Intent;
import android.content.pm.ResolveInfo; import android.content.pm.ResolveInfo;
import android.os.Bundle; import android.os.Bundle;
import android.os.TransactionTooLargeException; import android.os.TransactionTooLargeException;
import android.support.v4.content.LocalBroadcastManager;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
@ -15,9 +16,12 @@ import org.slf4j.LoggerFactory;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.Services.Intents; import info.nightscout.androidaps.Services.Intents;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSTreatment; import info.nightscout.androidaps.plugins.NSClientInternal.data.NSTreatment;
import info.nightscout.utils.SP; import info.nightscout.utils.SP;
import info.nightscout.utils.ToastUtils;
/** /**
* Created by mike on 20.02.2016. * Created by mike on 20.02.2016.
@ -27,21 +31,27 @@ public class BroadcastTreatment {
public static void handleNewTreatment(NSTreatment treatment, Context context, boolean isDelta) { public static void handleNewTreatment(NSTreatment treatment, Context context, boolean isDelta) {
if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString("treatment", treatment.getData().toString()); bundle.putString("treatment", treatment.getData().toString());
bundle.putBoolean("delta", isDelta); bundle.putBoolean("delta", isDelta);
Intent intent = new Intent(Intents.ACTION_NEW_TREATMENT); Intent intent = new Intent(Intents.ACTION_NEW_TREATMENT);
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(R.string.key_nsclient_localbroadcasts, true)) {
bundle = new Bundle();
bundle.putString("treatment", treatment.getData().toString());
bundle.putBoolean("delta", isDelta);
intent = new Intent(Intents.ACTION_NEW_TREATMENT);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
context.sendBroadcast(intent);
}
} }
public static void handleNewTreatment(JSONArray treatments, Context context, boolean isDelta) { public static void handleNewTreatment(JSONArray treatments, Context context, boolean isDelta) {
if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
List<JSONArray> splitted = splitArray(treatments); List<JSONArray> splitted = splitArray(treatments);
for (JSONArray part: splitted) { for (JSONArray part: splitted) {
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
@ -50,42 +60,73 @@ public class BroadcastTreatment {
Intent intent = new Intent(Intents.ACTION_NEW_TREATMENT); Intent intent = new Intent(Intents.ACTION_NEW_TREATMENT);
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(R.string.key_nsclient_localbroadcasts, true)){
splitted = splitArray(treatments);
for (JSONArray part: splitted) {
Bundle bundle = new Bundle();
bundle.putString("treatments", part.toString());
bundle.putBoolean("delta", isDelta);
Intent intent = new Intent(Intents.ACTION_NEW_TREATMENT);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
context.sendBroadcast(intent);
}
} }
} }
public void handleChangedTreatment(JSONObject treatment, Context context, boolean isDelta) { public void handleChangedTreatment(JSONObject treatment, Context context, boolean isDelta) {
if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString("treatment", treatment.toString()); bundle.putString("treatment", treatment.toString());
bundle.putBoolean("delta", isDelta); bundle.putBoolean("delta", isDelta);
Intent intent = new Intent(Intents.ACTION_CHANGED_TREATMENT); Intent intent = new Intent(Intents.ACTION_CHANGED_TREATMENT);
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);
}
public static void handleChangedTreatment(JSONArray treatments, Context context, boolean isDelta) {
if(!SP.getBoolean("nsclient_localbroadcasts", true)) return; if(SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
bundle = new Bundle();
List<JSONArray> splitted = splitArray(treatments); bundle.putString("treatment", treatment.toString());
for (JSONArray part: splitted) {
Bundle bundle = new Bundle();
bundle.putString("treatments", part.toString());
bundle.putBoolean("delta", isDelta); bundle.putBoolean("delta", isDelta);
Intent intent = new Intent(Intents.ACTION_CHANGED_TREATMENT); intent = new Intent(Intents.ACTION_CHANGED_TREATMENT);
intent.putExtras(bundle); intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
context.sendBroadcast(intent); context.sendBroadcast(intent);
} }
} }
public static void handleRemovedTreatment(JSONObject treatment, Context context, boolean isDelta) { public static void handleChangedTreatment(JSONArray treatments, Context context, boolean isDelta) {
if(!SP.getBoolean("nsclient_localbroadcasts", true)) return; List<JSONArray> splitted = splitArray(treatments);
for (JSONArray part : splitted) {
Bundle bundle = new Bundle();
bundle.putString("treatments", part.toString());
bundle.putBoolean("delta", isDelta);
Intent intent = new Intent(Intents.ACTION_CHANGED_TREATMENT);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
}
if(SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
splitted = splitArray(treatments);
for (JSONArray part : splitted) {
Bundle bundle = new Bundle();
bundle.putString("treatments", part.toString());
bundle.putBoolean("delta", isDelta);
Intent intent = new Intent(Intents.ACTION_CHANGED_TREATMENT);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
context.sendBroadcast(intent);
}
}
}
public static void handleRemovedTreatment(JSONObject treatment, Context context, boolean isDelta) {
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString("treatment", treatment.toString()); bundle.putString("treatment", treatment.toString());
@ -93,20 +134,40 @@ public class BroadcastTreatment {
Intent intent = new Intent(Intents.ACTION_REMOVED_TREATMENT); Intent intent = new Intent(Intents.ACTION_REMOVED_TREATMENT);
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(R.string.key_nsclient_localbroadcasts, true)) {
bundle = new Bundle();
bundle.putString("treatment", treatment.toString());
bundle.putBoolean("delta", isDelta);
intent = new Intent(Intents.ACTION_REMOVED_TREATMENT);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
context.sendBroadcast(intent);
}
} }
public static void handleRemovedTreatment(JSONArray treatments, Context context, boolean isDelta) { public static void handleRemovedTreatment(JSONArray treatments, Context context, boolean isDelta) {
if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString("treatments", treatments.toString()); bundle.putString("treatments", treatments.toString());
bundle.putBoolean("delta", isDelta); bundle.putBoolean("delta", isDelta);
Intent intent = new Intent(Intents.ACTION_REMOVED_TREATMENT); Intent intent = new Intent(Intents.ACTION_REMOVED_TREATMENT);
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(R.string.key_nsclient_localbroadcasts, true)) {
bundle = new Bundle();
bundle.putString("treatments", treatments.toString());
bundle.putBoolean("delta", isDelta);
intent = new Intent(Intents.ACTION_REMOVED_TREATMENT);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
context.sendBroadcast(intent);
}
} }

View file

@ -4,6 +4,7 @@ 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.json.JSONObject; import org.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -11,6 +12,8 @@ import org.slf4j.LoggerFactory;
import java.util.List; import java.util.List;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.Services.Intents; import info.nightscout.androidaps.Services.Intents;
import info.nightscout.utils.SP; import info.nightscout.utils.SP;
@ -21,14 +24,20 @@ public class BroadcastUrgentAlarm {
private static Logger log = LoggerFactory.getLogger(BroadcastUrgentAlarm.class); private static Logger log = LoggerFactory.getLogger(BroadcastUrgentAlarm.class);
public static void handleUrgentAlarm(JSONObject urgentalarm, Context context) { public static void handleUrgentAlarm(JSONObject urgentalarm, Context context) {
if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString("data", urgentalarm.toString()); bundle.putString("data", urgentalarm.toString());
Intent intent = new Intent(Intents.ACTION_URGENT_ALARM); Intent intent = new Intent(Intents.ACTION_URGENT_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(R.string.key_nsclient_localbroadcasts, true)) {
bundle = new Bundle();
bundle.putString("data", urgentalarm.toString());
intent = new Intent(Intents.ACTION_URGENT_ALARM);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
context.sendBroadcast(intent);
}
} }
} }

View file

@ -649,6 +649,7 @@
<string name="openapsama_autosens_period">Interval for autosens [h]</string> <string name="openapsama_autosens_period">Interval for autosens [h]</string>
<string name="openapsama_autosens_period_summary">Amount of hours in the past for sensitivity detection (carbs absorption time is excluded)</string> <string name="openapsama_autosens_period_summary">Amount of hours in the past for sensitivity detection (carbs absorption time is excluded)</string>
<string name="key_openapsama_autosens_period" translatable="false">openapsama_autosens_period</string> <string name="key_openapsama_autosens_period" translatable="false">openapsama_autosens_period</string>
<string name="key_nsclient_localbroadcasts" translatable="false">nsclient_localbroadcasts</string>
<string name="ratio_short">RAT</string> <string name="ratio_short">RAT</string>
<string name="key_do_not_track_profile_switch">do_not_track_profile_switch</string> <string name="key_do_not_track_profile_switch">do_not_track_profile_switch</string>
<string name="do_not_track_profile_switch">Ignore profile switch events</string> <string name="do_not_track_profile_switch">Ignore profile switch events</string>
@ -686,7 +687,7 @@
<string name="cpp_valuesnotstored">Values not stored!</string> <string name="cpp_valuesnotstored">Values not stored!</string>
<string name="wear_overviewnotifications">Overview Notifications</string> <string name="wear_overviewnotifications">Overview Notifications</string>
<string name="wear_overviewnotifications_summary">Pass the Overview Notifications through as wear confirmation messages.</string> <string name="wear_overviewnotifications_summary">Pass the Overview Notifications through as wear confirmation messages.</string>
<string name="ns_localbroadcasts">Enable loacal broadcasts to other apps (like xDrip).</string> <string name="ns_localbroadcasts">Enable broadcasts to other apps (like xDrip).</string>
<string name="ns_localbroadcasts_title">Enable local Broadcasts.</string> <string name="ns_localbroadcasts_title">Enable local Broadcasts.</string>
<string name="careportal_activity_label">ACTIVITY &amp; FEEDBACK</string> <string name="careportal_activity_label">ACTIVITY &amp; FEEDBACK</string>
<string name="careportal_carbsandbolus_label">CARBS &amp; BOLUS</string> <string name="careportal_carbsandbolus_label">CARBS &amp; BOLUS</string>