Kaydet (Commit) 871712ad authored tarafından Tor Lillqvist's avatar Tor Lillqvist

Don't return from the CommunicationService.run() method

This fixes connecting to one computer after connecting to another failed.

Change-Id: I5b13d186d32690a91e4290c81c8d2e12a0a1f2be
üst 30791330
...@@ -76,6 +76,7 @@ public class CommunicationService extends Service implements Runnable { ...@@ -76,6 +76,7 @@ public class CommunicationService extends Service implements Runnable {
@Override @Override
public void run() { public void run() {
Log.i(Globals.TAG, "CommunicationService.run()");
synchronized (this) { synchronized (this) {
while (true) { while (true) {
// Condition // Condition
...@@ -86,6 +87,7 @@ public class CommunicationService extends Service implements Runnable { ...@@ -86,6 +87,7 @@ public class CommunicationService extends Service implements Runnable {
return; return;
} }
// Work // Work
Log.i(Globals.TAG, "CommunicationService.run: at \"Work\"");
synchronized (mConnectionVariableMutex) { synchronized (mConnectionVariableMutex) {
if ((mStateDesired == State.CONNECTED && mState == State.CONNECTED) if ((mStateDesired == State.CONNECTED && mState == State.CONNECTED)
|| (mStateDesired == State.DISCONNECTED && mState == State.CONNECTED)) { || (mStateDesired == State.DISCONNECTED && mState == State.CONNECTED)) {
...@@ -107,23 +109,21 @@ public class CommunicationService extends Service implements Runnable { ...@@ -107,23 +109,21 @@ public class CommunicationService extends Service implements Runnable {
mBluetoothPreviouslyEnabled); mBluetoothPreviouslyEnabled);
break; break;
} }
mTransmitter = new Transmitter(mClient);
mState = State.CONNECTED;
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); Log.i(Globals.TAG, "CommunicationService.run: " + e);
mClient = null; mClient = null;
mState = State.DISCONNECTED; mState = State.DISCONNECTED;
Intent aIntent = new Intent( Intent aIntent = new Intent(
CommunicationService.STATUS_CONNECTION_FAILED); CommunicationService.STATUS_CONNECTION_FAILED);
LocalBroadcastManager.getInstance(this) LocalBroadcastManager.getInstance(this)
.sendBroadcast(aIntent); .sendBroadcast(aIntent);
return;
} }
mTransmitter = new Transmitter(mClient);
mState = State.CONNECTED;
} }
} }
} }
} }
} }
private boolean mBluetoothPreviouslyEnabled; private boolean mBluetoothPreviouslyEnabled;
...@@ -156,6 +156,7 @@ public class CommunicationService extends Service implements Runnable { ...@@ -156,6 +156,7 @@ public class CommunicationService extends Service implements Runnable {
} }
public void connectTo(Server aServer) { public void connectTo(Server aServer) {
Log.i(Globals.TAG, "CommunicationService.connectTo(" + aServer + ")");
synchronized (mConnectionVariableMutex) { synchronized (mConnectionVariableMutex) {
if (mState == State.SEARCHING) { if (mState == State.SEARCHING) {
mNetworkFinder.stopFinding(); mNetworkFinder.stopFinding();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment