Kaydet (Commit) 661b0329 authored tarafından Andrzej J.R. Hunt's avatar Andrzej J.R. Hunt

Prevent deadlock on pairing.

Change-Id: I1c746861e1e5c6625e03f4761ecf2fd641fcf071
üst 516c4f2a
......@@ -3,7 +3,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dip"
android:gravity="left"
android:gravity="center_vertical"
android:orientation="vertical" >
<ImageView
......
......@@ -40,7 +40,11 @@ public class BluetoothFinder {
public void stopFinding() {
mAdapter.cancelDiscovery();
mContext.unregisterReceiver(mReceiver);
try {
mContext.unregisterReceiver(mReceiver);
} catch (IllegalArgumentException e) {
// The receiver wasn't registered
}
}
private HashMap<String, Server> mServerList = new HashMap<String, Server>();
......
......@@ -85,23 +85,13 @@ public class CommunicationService extends Service implements Runnable {
}
public void startSearching() {
synchronized (mConnectionVariableMutex) {
if (mState == State.CONNECTING || mState == State.CONNECTED) {
disconnect();
}
mNetworkFinder.startFinding();
mBluetoothFinder.startFinding();
mState = State.SEARCHING;
}
new BluetoothFinder(this);
mNetworkFinder.startFinding();
mBluetoothFinder.startFinding();
}
public void stopSearching() {
synchronized (mConnectionVariableMutex) {
mNetworkFinder.stopFinding();
mBluetoothFinder.stopFinding();
mState = State.DISCONNECTED;
}
mNetworkFinder.stopFinding();
mBluetoothFinder.stopFinding();
}
public void connectTo(Server aServer) {
......
......@@ -63,7 +63,7 @@ public class ServerFinder {
return;
}
Server aServer = new Server(Server.Protocol.NETWORK, aPacket
.getAddress().toString(), aName,
.getAddress().getHostAddress(), aName,
System.currentTimeMillis());
mServerList.put(aServer.getAddress(), aServer);
......
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