Log exceptions that occur in alert service
This commit is contained in:
parent
a4312acb3e
commit
e49cc10e1c
|
@ -17,6 +17,10 @@ import android.os.Looper;
|
||||||
import android.os.Vibrator;
|
import android.os.Vibrator;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.activities.InsightAlertActivity;
|
import info.nightscout.androidaps.plugins.PumpInsightLocal.activities.InsightAlertActivity;
|
||||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.app_layer.remote_control.ConfirmAlertMessage;
|
import info.nightscout.androidaps.plugins.PumpInsightLocal.app_layer.remote_control.ConfirmAlertMessage;
|
||||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.app_layer.remote_control.SnoozeAlertMessage;
|
import info.nightscout.androidaps.plugins.PumpInsightLocal.app_layer.remote_control.SnoozeAlertMessage;
|
||||||
|
@ -26,10 +30,14 @@ import info.nightscout.androidaps.plugins.PumpInsightLocal.descriptors.Alert;
|
||||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.descriptors.AlertStatus;
|
import info.nightscout.androidaps.plugins.PumpInsightLocal.descriptors.AlertStatus;
|
||||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.descriptors.AlertType;
|
import info.nightscout.androidaps.plugins.PumpInsightLocal.descriptors.AlertType;
|
||||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.descriptors.InsightState;
|
import info.nightscout.androidaps.plugins.PumpInsightLocal.descriptors.InsightState;
|
||||||
|
import info.nightscout.androidaps.plugins.PumpInsightLocal.exceptions.InsightException;
|
||||||
|
import info.nightscout.androidaps.plugins.PumpInsightLocal.exceptions.app_layer_errors.AppLayerErrorException;
|
||||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.utils.ExceptionTranslator;
|
import info.nightscout.androidaps.plugins.PumpInsightLocal.utils.ExceptionTranslator;
|
||||||
|
|
||||||
public class InsightAlertService extends Service implements InsightConnectionService.StateCallback {
|
public class InsightAlertService extends Service implements InsightConnectionService.StateCallback {
|
||||||
|
|
||||||
|
private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
|
||||||
|
|
||||||
private LocalBinder localBinder = new LocalBinder();
|
private LocalBinder localBinder = new LocalBinder();
|
||||||
private boolean connectionRequested;
|
private boolean connectionRequested;
|
||||||
private final Object $alertLock = new Object[0];
|
private final Object $alertLock = new Object[0];
|
||||||
|
@ -164,7 +172,12 @@ public class InsightAlertService extends Service implements InsightConnectionSer
|
||||||
} catch (InterruptedException ignored) {
|
} catch (InterruptedException ignored) {
|
||||||
connectionService.withdrawConnectionRequest(thread);
|
connectionService.withdrawConnectionRequest(thread);
|
||||||
break;
|
break;
|
||||||
} catch (Exception ignored) {
|
} catch (AppLayerErrorException e) {
|
||||||
|
log.info("Exception while fetching alert: " + e.getClass().getCanonicalName() + " (" + e.getErrorCode() + ")");
|
||||||
|
} catch (InsightException e) {
|
||||||
|
log.info("Exception while fetching alert: " + e.getClass().getSimpleName());
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("Exception while fetching alert", e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
|
@ -207,7 +220,14 @@ public class InsightAlertService extends Service implements InsightConnectionSer
|
||||||
SnoozeAlertMessage snoozeAlertMessage = new SnoozeAlertMessage();
|
SnoozeAlertMessage snoozeAlertMessage = new SnoozeAlertMessage();
|
||||||
snoozeAlertMessage.setAlertID(alert.getAlertId());
|
snoozeAlertMessage.setAlertID(alert.getAlertId());
|
||||||
connectionService.requestMessage(snoozeAlertMessage).await();
|
connectionService.requestMessage(snoozeAlertMessage).await();
|
||||||
|
} catch (AppLayerErrorException e) {
|
||||||
|
log.info("Exception while muting alert: " + e.getClass().getCanonicalName() + " (" + e.getErrorCode() + ")");
|
||||||
|
ExceptionTranslator.makeToast(InsightAlertService.this, e);
|
||||||
|
} catch (InsightException e) {
|
||||||
|
log.info("Exception while muting alert: " + e.getClass().getSimpleName());
|
||||||
|
ExceptionTranslator.makeToast(InsightAlertService.this, e);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
log.error("Exception while muting alert", e);
|
||||||
ExceptionTranslator.makeToast(InsightAlertService.this, e);
|
ExceptionTranslator.makeToast(InsightAlertService.this, e);
|
||||||
}
|
}
|
||||||
}).start();
|
}).start();
|
||||||
|
@ -219,7 +239,14 @@ public class InsightAlertService extends Service implements InsightConnectionSer
|
||||||
ConfirmAlertMessage confirmAlertMessage = new ConfirmAlertMessage();
|
ConfirmAlertMessage confirmAlertMessage = new ConfirmAlertMessage();
|
||||||
confirmAlertMessage.setAlertID(alert.getAlertId());
|
confirmAlertMessage.setAlertID(alert.getAlertId());
|
||||||
connectionService.requestMessage(confirmAlertMessage).await();
|
connectionService.requestMessage(confirmAlertMessage).await();
|
||||||
|
} catch (AppLayerErrorException e) {
|
||||||
|
log.info("Exception while confirming alert: " + e.getClass().getCanonicalName() + " (" + e.getErrorCode() + ")");
|
||||||
|
ExceptionTranslator.makeToast(InsightAlertService.this, e);
|
||||||
|
} catch (InsightException e) {
|
||||||
|
log.info("Exception while confirming alert: " + e.getClass().getSimpleName());
|
||||||
|
ExceptionTranslator.makeToast(InsightAlertService.this, e);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
log.error("Exception while confirming alert", e);
|
||||||
ExceptionTranslator.makeToast(InsightAlertService.this, e);
|
ExceptionTranslator.makeToast(InsightAlertService.this, e);
|
||||||
}
|
}
|
||||||
}).start();
|
}).start();
|
||||||
|
|
Loading…
Reference in a new issue