Synchronize modification of list in OmnipodPumpPlugin
This commit is contained in:
parent
025f25fb27
commit
b474e72a53
1 changed files with 41 additions and 37 deletions
|
@ -462,44 +462,46 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
if (firstRun) {
|
if (firstRun) {
|
||||||
initializeAfterRileyLinkConnection();
|
initializeAfterRileyLinkConnection();
|
||||||
} else if (!statusRequestList.isEmpty()) {
|
} else if (!statusRequestList.isEmpty()) {
|
||||||
Iterator<OmnipodStatusRequestType> iterator = statusRequestList.iterator();
|
synchronized (statusRequestList) {
|
||||||
|
Iterator<OmnipodStatusRequestType> iterator = statusRequestList.iterator();
|
||||||
|
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
OmnipodStatusRequestType statusRequest = iterator.next();
|
OmnipodStatusRequestType statusRequest = iterator.next();
|
||||||
switch (statusRequest) {
|
switch (statusRequest) {
|
||||||
case GET_PULSE_LOG:
|
case GET_PULSE_LOG:
|
||||||
try {
|
try {
|
||||||
PodInfoRecentPulseLog result = executeCommand(OmnipodCommandType.GET_POD_PULSE_LOG, aapsOmnipodManager::readPulseLog);
|
PodInfoRecentPulseLog result = executeCommand(OmnipodCommandType.GET_POD_PULSE_LOG, aapsOmnipodManager::readPulseLog);
|
||||||
Intent i = new Intent(context, ErrorHelperActivity.class);
|
Intent i = new Intent(context, ErrorHelperActivity.class);
|
||||||
i.putExtra("soundid", 0);
|
i.putExtra("soundid", 0);
|
||||||
i.putExtra("status", "Pulse Log (copied to clipboard):\n" + result.toString());
|
i.putExtra("status", "Pulse Log (copied to clipboard):\n" + result.toString());
|
||||||
i.putExtra("title", resourceHelper.gs(R.string.omnipod_warning));
|
i.putExtra("title", resourceHelper.gs(R.string.omnipod_warning));
|
||||||
i.putExtra("clipboardContent", result.toString());
|
i.putExtra("clipboardContent", result.toString());
|
||||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
context.startActivity(i);
|
context.startActivity(i);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
aapsLogger.warn(LTag.PUMP, "Failed to retrieve pulse log", ex);
|
aapsLogger.warn(LTag.PUMP, "Failed to retrieve pulse log", ex);
|
||||||
Intent i = new Intent(context, ErrorHelperActivity.class);
|
Intent i = new Intent(context, ErrorHelperActivity.class);
|
||||||
i.putExtra("soundid", 0);
|
i.putExtra("soundid", 0);
|
||||||
i.putExtra("status", "Failed to retrieve pulse log");
|
i.putExtra("status", "Failed to retrieve pulse log");
|
||||||
i.putExtra("title", resourceHelper.gs(R.string.omnipod_warning));
|
i.putExtra("title", resourceHelper.gs(R.string.omnipod_warning));
|
||||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
context.startActivity(i);
|
context.startActivity(i);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ACKNOWLEDGE_ALERTS:
|
case ACKNOWLEDGE_ALERTS:
|
||||||
executeCommand(OmnipodCommandType.ACKNOWLEDGE_ALERTS, aapsOmnipodManager::acknowledgeAlerts);
|
executeCommand(OmnipodCommandType.ACKNOWLEDGE_ALERTS, aapsOmnipodManager::acknowledgeAlerts);
|
||||||
break;
|
break;
|
||||||
case GET_POD_STATE:
|
case GET_POD_STATE:
|
||||||
executeCommand(OmnipodCommandType.GET_POD_STATUS, aapsOmnipodManager::getPodStatus);
|
executeCommand(OmnipodCommandType.GET_POD_STATUS, aapsOmnipodManager::getPodStatus);
|
||||||
break;
|
break;
|
||||||
case SUSPEND_DELIVERY:
|
case SUSPEND_DELIVERY:
|
||||||
executeCommand(OmnipodCommandType.SUSPEND_DELIVERY, aapsOmnipodManager::suspendDelivery);
|
executeCommand(OmnipodCommandType.SUSPEND_DELIVERY, aapsOmnipodManager::suspendDelivery);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
aapsLogger.error(LTag.PUMP, "Unknown status request: " + statusRequest.name());
|
aapsLogger.error(LTag.PUMP, "Unknown status request: " + statusRequest.name());
|
||||||
|
}
|
||||||
|
iterator.remove();
|
||||||
}
|
}
|
||||||
iterator.remove();
|
|
||||||
}
|
}
|
||||||
} else if (this.hasTimeDateOrTimeZoneChanged) {
|
} else if (this.hasTimeDateOrTimeZoneChanged) {
|
||||||
PumpEnactResult result = executeCommand(OmnipodCommandType.SET_TIME, aapsOmnipodManager::setTime);
|
PumpEnactResult result = executeCommand(OmnipodCommandType.SET_TIME, aapsOmnipodManager::setTime);
|
||||||
|
@ -830,7 +832,9 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPodStatusRequest(OmnipodStatusRequestType pumpStatusRequest) {
|
public void addPodStatusRequest(OmnipodStatusRequestType pumpStatusRequest) {
|
||||||
statusRequestList.add(pumpStatusRequest);
|
synchronized (statusRequestList) {
|
||||||
|
statusRequestList.add(pumpStatusRequest);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue