nsclient devicestatus local
This commit is contained in:
parent
fe57d4a61d
commit
194a817332
3 changed files with 28 additions and 11 deletions
|
@ -57,7 +57,6 @@
|
|||
android:exported="true">
|
||||
<intent-filter>
|
||||
<!-- Receiver from NSClient -->
|
||||
<action android:name="info.nightscout.client.NEW_DEVICESTATUS" />
|
||||
<action android:name="info.nightscout.client.NEW_CAL" />
|
||||
<!-- Receive new SMS messages -->
|
||||
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
|
||||
|
|
|
@ -176,10 +176,7 @@ public class MainApp extends Application {
|
|||
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));
|
||||
}
|
||||
|
||||
private void startKeepAliveService() {
|
||||
|
|
|
@ -4,6 +4,7 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.content.LocalBroadcastManager;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
@ -12,6 +13,7 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.Services.Intents;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
|
@ -26,14 +28,20 @@ public class BroadcastDeviceStatus {
|
|||
Intent intent = new Intent(Intents.ACTION_NEW_DEVICESTATUS);
|
||||
intent.putExtras(bundle);
|
||||
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.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) {
|
||||
|
||||
|
||||
if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
|
||||
|
||||
|
||||
List<JSONArray> splitted = BroadcastTreatment.splitArray(statuses);
|
||||
for (JSONArray part: splitted) {
|
||||
Bundle bundle = new Bundle();
|
||||
|
@ -42,7 +50,20 @@ public class BroadcastDeviceStatus {
|
|||
Intent intent = new Intent(Intents.ACTION_NEW_DEVICESTATUS);
|
||||
intent.putExtras(bundle);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
context.sendBroadcast(intent);
|
||||
LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
|
||||
}
|
||||
|
||||
if(SP.getBoolean("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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue