accept local NS data broadcast even when ns_upload_only is selected
This commit is contained in:
parent
de1475dbba
commit
4643cdc3b9
|
@ -96,7 +96,12 @@ public class DataService extends IntentService {
|
|||
|
||||
boolean isNSProfile = ConfigBuilderPlugin.getActiveProfileInterface().getClass().equals(NSProfilePlugin.class);
|
||||
|
||||
boolean nsUploadOnly = SP.getBoolean(R.string.key_ns_upload_only, false);
|
||||
boolean acceptNSData = !SP.getBoolean(R.string.key_ns_upload_only, false);
|
||||
Bundle bundles = intent.getExtras();
|
||||
if (bundles != null && bundles.containsKey("islocal")) {
|
||||
acceptNSData = acceptNSData || bundles.getBoolean("islocal");
|
||||
}
|
||||
|
||||
|
||||
if (intent != null) {
|
||||
final String action = intent.getAction();
|
||||
|
@ -125,7 +130,7 @@ public class DataService extends IntentService {
|
|||
} else if (isNSProfile && Intents.ACTION_NEW_PROFILE.equals(action) || Intents.ACTION_NEW_DEVICESTATUS.equals(action)) {
|
||||
// always handle Profile if NSProfile is enabled without looking at nsUploadOnly
|
||||
handleNewDataFromNSClient(intent);
|
||||
} else if (!nsUploadOnly &&
|
||||
} else if (acceptNSData &&
|
||||
(Intents.ACTION_NEW_TREATMENT.equals(action) ||
|
||||
Intents.ACTION_CHANGED_TREATMENT.equals(action) ||
|
||||
Intents.ACTION_REMOVED_TREATMENT.equals(action) ||
|
||||
|
|
|
@ -24,11 +24,12 @@ import info.nightscout.utils.SP;
|
|||
public class BroadcastTreatment {
|
||||
private static Logger log = LoggerFactory.getLogger(BroadcastTreatment.class);
|
||||
|
||||
public static void handleNewTreatment(JSONObject treatment, boolean isDelta) {
|
||||
public static void handleNewTreatment(JSONObject treatment, boolean isDelta, boolean isLocalBypass) {
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("treatment", treatment.toString());
|
||||
bundle.putBoolean("delta", isDelta);
|
||||
bundle.putBoolean("islocal", isLocalBypass);
|
||||
Intent intent = new Intent(Intents.ACTION_NEW_TREATMENT);
|
||||
intent.putExtras(bundle);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
|
|
|
@ -110,7 +110,7 @@ public class DBAccessReceiver extends BroadcastReceiver {
|
|||
JSONObject data = new JSONObject(request.data);
|
||||
data.put("mills", DateUtil.fromISODateString(data.getString("created_at")).getTime());
|
||||
data.put("_id", data.get("NSCLIENT_ID")); // this is only fake id
|
||||
BroadcastTreatment.handleNewTreatment(data, false);
|
||||
BroadcastTreatment.handleNewTreatment(data, false, true);
|
||||
} catch (Exception e) {
|
||||
log.error("Unhadled exception", e);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue