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