Return false in isConnected and isConnecting when connection lock is not held.
This commit is contained in:
parent
317f171286
commit
7a7bebc5fe
2 changed files with 9 additions and 3 deletions
|
@ -261,13 +261,15 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
|
|||
|
||||
@Override
|
||||
public boolean isConnected() {
|
||||
if (connectionService == null || alertService == null) return false;
|
||||
return connectionService.getState() == InsightState.CONNECTED;
|
||||
return connectionService != null
|
||||
&& alertService != null
|
||||
&& connectionService.hasRequestedConnection(this)
|
||||
&& connectionService.getState() == InsightState.CONNECTED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConnecting() {
|
||||
if (connectionService == null || alertService == null) return false;
|
||||
if (connectionService == null || alertService == null || !connectionService.hasRequestedConnection(this)) return false;
|
||||
InsightState state = connectionService.getState();
|
||||
return state == InsightState.CONNECTING
|
||||
|| state == InsightState.APP_CONNECT_MESSAGE
|
||||
|
|
|
@ -277,6 +277,10 @@ public class InsightConnectionService extends Service implements ConnectionEstab
|
|||
}
|
||||
}
|
||||
|
||||
public synchronized boolean hasRequestedConnection(Object lock) {
|
||||
return connectionRequests.contains(lock);
|
||||
}
|
||||
|
||||
private void cleanup() {
|
||||
messageQueue.completeActiveRequest(new ConnectionLostException());
|
||||
messageQueue.completePendingRequests(new ConnectionLostException());
|
||||
|
|
Loading…
Reference in a new issue