fix crash with Bluetooth on android-10

android.bluetooth.BluetoothSocket.isConnected() is only 14+

java.lang.NoSuchMethodError: android.bluetooth.BluetoothSocket.isConnected
  at org.fdroid.fdroid.net.bluetooth.BluetoothConnection.open(BluetoothConnection.java:37)
  at org.fdroid.fdroid.net.bluetooth.BluetoothClient.openConnection(BluetoothClient.java:31)
  at org.fdroid.fdroid.net.BluetoothDownloader.<init>(BluetoothDownloader.java:30)
  at org.fdroid.fdroid.net.DownloaderFactory.create(DownloaderFactory.java:56)
  at org.fdroid.fdroid.RepoUpdater.downloadIndex(RepoUpdater.java:97)
  at org.fdroid.fdroid.RepoUpdater.update(RepoUpdater.java:131)
  at org.fdroid.fdroid.UpdateService.onHandleIntent(UpdateService.java:377)
  at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:59)
  at android.os.Handler.dispatchMessage(Handler.java:99)
  at android.os.Looper.loop(Looper.java:130)
  at android.os.HandlerThread.run(HandlerThread.java:60)
This commit is contained in:
Hans-Christoph Steiner 2016-05-24 20:20:00 +02:00
parent 3f525c9bae
commit fb3dcb293d

View File

@ -34,7 +34,7 @@ public class BluetoothConnection {
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
public void open() throws IOException {
if (!socket.isConnected()) {
if (Build.VERSION.SDK_INT >= 14 && !socket.isConnected()) {
// Server sockets will already be connected when they are passed to us,
// client sockets require us to call connect().
socket.connect();