diff --git a/F-Droid/src/org/fdroid/fdroid/net/bluetooth/BluetoothClient.java b/F-Droid/src/org/fdroid/fdroid/net/bluetooth/BluetoothClient.java index fe45b8ee3..3179c259e 100644 --- a/F-Droid/src/org/fdroid/fdroid/net/bluetooth/BluetoothClient.java +++ b/F-Droid/src/org/fdroid/fdroid/net/bluetooth/BluetoothClient.java @@ -17,7 +17,7 @@ public class BluetoothClient { } public BluetoothConnection openConnection() throws IOException { - BluetoothSocket socket = device.createRfcommSocketToServiceRecord(BluetoothConstants.fdroidUuid()); + BluetoothSocket socket = device.createInsecureRfcommSocketToServiceRecord(BluetoothConstants.fdroidUuid()); BluetoothConnection connection = new BluetoothConnection(socket); connection.open(); return connection; diff --git a/F-Droid/src/org/fdroid/fdroid/views/swap/BluetoothDeviceListView.java b/F-Droid/src/org/fdroid/fdroid/views/swap/BluetoothDeviceListView.java index 00c4a48c5..66b1bd462 100644 --- a/F-Droid/src/org/fdroid/fdroid/views/swap/BluetoothDeviceListView.java +++ b/F-Droid/src/org/fdroid/fdroid/views/swap/BluetoothDeviceListView.java @@ -31,6 +31,7 @@ import org.fdroid.fdroid.localrepo.SwapManager; import org.fdroid.fdroid.net.BluetoothDownloader; import org.fdroid.fdroid.net.bluetooth.BluetoothClient; import org.fdroid.fdroid.net.bluetooth.BluetoothConnection; +import org.fdroid.fdroid.net.bluetooth.BluetoothServer; import org.fdroid.fdroid.views.fragments.ThemeableListFragment; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -134,13 +135,15 @@ public class BluetoothDeviceListView extends ListView implements final BluetoothAdapter bluetooth = BluetoothAdapter.getDefaultAdapter(); - final TextView deviceName = (TextView)headerView.findViewById(R.id.device_name); + final TextView deviceName = (TextView) headerView.findViewById(R.id.device_name); deviceName.setText(bluetooth.getName()); - final TextView address = (TextView)headerView.findViewById(R.id.device_address); + final TextView address = (TextView) headerView.findViewById(R.id.device_address); address.setText(bluetooth.getAddress()); - populateBondedDevices(); + initiateBluetoothScan(); + + // populateBondedDevices(); } @@ -166,8 +169,10 @@ public class BluetoothDeviceListView extends ListView implements { Log.d(TAG, "Starting bluetooth scan..."); - cancelMenuItem.setVisible(true); - scanMenuItem.setVisible(false); + if (cancelMenuItem != null) { + cancelMenuItem.setVisible(true); + scanMenuItem.setVisible(false); + } final ContentLoadingProgressBar loadingBar = getLoadingIndicator(); @@ -181,17 +186,21 @@ public class BluetoothDeviceListView extends ListView implements if (BluetoothDevice.ACTION_FOUND.equals(intent.getAction())) { BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); Log.d(TAG, "Found bluetooth device: " + device.toString()); - boolean exists = false; - for (int i = 0; i < adapter.getCount(); i ++) { - if (adapter.getItem(i).getAddress().equals(device.getAddress())) { - exists = true; - break; - } - } - if (!exists) { - adapter.add(device); - } + if (device != null && device.getName() != null) + if (device.getName().contains(BluetoothServer.BLUETOOTH_NAME_TAG)) { + boolean exists = false; + for (int i = 0; i < adapter.getCount(); i++) { + if (adapter.getItem(i).getAddress().equals(device.getAddress())) { + exists = true; + break; + } + } + + if (!exists) { + adapter.add(device); + } + } } } };