Skip to content

Commit

Permalink
Fix Bluetooth Manager close all bug
Browse files Browse the repository at this point in the history
  • Loading branch information
harryjph committed Feb 6, 2019
1 parent ec5ef2b commit 213b4c5
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
import android.util.ArrayMap;

import java.io.Closeable;
import java.io.InputStream;
import java.io.StringWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.UUID;
Expand Down Expand Up @@ -118,10 +122,12 @@ public void closeDevice(SimpleBluetoothDeviceInterface deviceInterface) {
*/
@Override
public void close() {
for (Map.Entry<String, BluetoothSerialDevice> d : devices.entrySet()) {
for (Iterator<Map.Entry<String, BluetoothSerialDevice>> iterator = devices.entrySet().iterator(); iterator.hasNext();) {
Map.Entry<String, BluetoothSerialDevice> deviceEntry = iterator.next();
try {
d.getValue().close();
} catch (Exception ignored) {}
deviceEntry.getValue().close();
} catch (Throwable ignored) {}
iterator.remove();
}
}
}

0 comments on commit 213b4c5

Please sign in to comment.