Skip to content

Commit

Permalink
Bug hopefully fixed: #55
Browse files Browse the repository at this point in the history
  • Loading branch information
philips77 committed Aug 31, 2017
1 parent a41ff75 commit b7d123b
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion dfu/src/main/java/no/nordicsemi/android/dfu/DfuBaseService.java
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,14 @@ public void onReceive(final Context context, final Intent intent) {

logi("Action received: " + action);
sendLogBroadcast(LOG_LEVEL_DEBUG, "[Broadcast] Action received: " + action);
/*
Handling the disconnection event here could lead to race conditions, as it also may (most probably will)
be delivered to onConnectionStateChange below.
See: https://github.com/NordicSemiconductor/Android-DFU-Library/issues/55
Note: This broadcast is now received on all 3 ACL events!
Don't assume DISCONNECT here.
mConnectionState = STATE_DISCONNECTED;
if (mDfuServiceImpl != null)
Expand All @@ -695,6 +703,7 @@ public void onReceive(final Context context, final Intent intent) {
synchronized (mLock) {
mLock.notifyAll();
}
*/
}
};

Expand Down Expand Up @@ -840,7 +849,11 @@ public void onCreate() {
manager.registerReceiver(mDfuActionReceiver, actionFilter);
registerReceiver(mDfuActionReceiver, actionFilter); // Additionally we must register this receiver as a non-local to get broadcasts from the notification actions

final IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_ACL_DISCONNECTED);
final IntentFilter filter = new IntentFilter();
// As we no longer perform any action based on this broadcast, we may log all ACL events
filter.addAction(BluetoothDevice.ACTION_ACL_CONNECTED);
filter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECT_REQUESTED);
filter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECTED);
registerReceiver(mConnectionStateBroadcastReceiver, filter);

final IntentFilter bondFilter = new IntentFilter(BluetoothDevice.ACTION_BOND_STATE_CHANGED);
Expand Down

0 comments on commit b7d123b

Please sign in to comment.