detect bg source in nsclient

This commit is contained in:
Milos Kozak 2018-06-22 22:30:03 +02:00
parent 7bed827f4b
commit 8e08a293c1
2 changed files with 15 additions and 1 deletions

View file

@ -604,6 +604,7 @@ public class DataService extends IntentService {
NSSgv nsSgv = new NSSgv(sgvJson);
BgReading bgReading = new BgReading(nsSgv);
MainApp.getDbHelper().createIfNotExists(bgReading, "NS");
SourceNSClientPlugin.getPlugin().detectSource(JsonHelper.safeGetString(sgvJson, "device"), JsonHelper.safeGetLong(sgvJson, "mills"));
}
private void handleNewSMS(Intent intent) {

View file

@ -20,6 +20,9 @@ public class SourceNSClientPlugin extends PluginBase implements BgSourceInterfac
return plugin;
}
private long lastBGTimeStamp = 0;
private boolean isAdvancedFilteringEnabled = false;
private SourceNSClientPlugin() {
super(new PluginDescription()
.mainType(PluginType.BGSOURCE)
@ -33,6 +36,16 @@ public class SourceNSClientPlugin extends PluginBase implements BgSourceInterfac
@Override
public boolean advancedFilteringSupported() {
return false;
return isAdvancedFilteringEnabled;
}
public void detectSource(String source, long timeStamp) {
if (timeStamp > lastBGTimeStamp) {
if (source.contains("G5 Native") || source.contains("AndroidAPS-DexcomG5"))
isAdvancedFilteringEnabled = true;
else
isAdvancedFilteringEnabled = false;
lastBGTimeStamp = timeStamp;
}
}
}