synchronized connectifnotconnected

This commit is contained in:
Milos Kozak 2016-07-13 14:46:08 +02:00
parent a10a819a9d
commit b818027b02

View file

@ -68,6 +68,8 @@ public class DanaConnection {
PowerManager.WakeLock mWakeLock;
private Treatment bolusingTreatment = null;
private static Object connectionInProgress = new Object();
private DanaRFragment danaRFragment;
private DanaRPump danaRPump;
@ -77,7 +79,7 @@ public class DanaConnection {
private static final UUID SPP_UUID = UUID.fromString("00001101-0000-1000-8000-00805f9b34fb");
// TODO: keepalive kills active connection
// TODO: keepalive kills active connection
public DanaConnection(Bus bus) {
danaRFragment = (DanaRFragment) MainActivity.getSpecificPlugin(DanaRFragment.class);
danaRFragment.setDanaConnection(this);
@ -159,6 +161,7 @@ public class DanaConnection {
}
public synchronized void connectIfNotConnected(String callerName) {
synchronized (connectionInProgress) {
mWakeLock.acquire();
long startTime = System.currentTimeMillis();
short connectionAttemptCount = 0;
@ -191,6 +194,7 @@ public class DanaConnection {
}
mWakeLock.release();
}
}
private synchronized void connectBT() {
if (mDevice == null) {