Insight async add wake locking

This commit is contained in:
Jamorham 2018-01-26 10:31:11 +00:00
parent 11fcfb88d4
commit 8fa0de19c2
No known key found for this signature in database
GPG key ID: 0BC5C3E0AAD64DF9

View file

@ -1,5 +1,7 @@
package info.nightscout.androidaps.plugins.PumpInsight; package info.nightscout.androidaps.plugins.PumpInsight;
import android.os.PowerManager;
import com.squareup.otto.Subscribe; import com.squareup.otto.Subscribe;
import java.util.UUID; import java.util.UUID;
@ -8,7 +10,9 @@ import java.util.concurrent.ConcurrentHashMap;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.plugins.PumpInsight.events.EventInsightPumpCallback; import info.nightscout.androidaps.plugins.PumpInsight.events.EventInsightPumpCallback;
import static info.nightscout.androidaps.plugins.PumpInsight.utils.Helpers.getWakeLock;
import static info.nightscout.androidaps.plugins.PumpInsight.utils.Helpers.msSince; import static info.nightscout.androidaps.plugins.PumpInsight.utils.Helpers.msSince;
import static info.nightscout.androidaps.plugins.PumpInsight.utils.Helpers.releaseWakeLock;
import static info.nightscout.androidaps.plugins.PumpInsight.utils.Helpers.tsl; import static info.nightscout.androidaps.plugins.PumpInsight.utils.Helpers.tsl;
/** /**
@ -53,6 +57,8 @@ public class InsightPumpAsyncAdapter {
// blocking call to wait for result callback // blocking call to wait for result callback
Cstatus busyWaitForCommandResult(final UUID uuid, long wait_time) { Cstatus busyWaitForCommandResult(final UUID uuid, long wait_time) {
final PowerManager.WakeLock wl = getWakeLock("insight-wait-cmd", 60000);
try {
log("busy wait for command " + uuid); log("busy wait for command " + uuid);
if (uuid == null) return Cstatus.FAILURE; if (uuid == null) return Cstatus.FAILURE;
final long start_time = tsl(); final long start_time = tsl();
@ -71,6 +77,9 @@ public class InsightPumpAsyncAdapter {
} else { } else {
return status; return status;
} }
} finally {
releaseWakeLock(wl);
}
} }
// commend field preparation for results // commend field preparation for results