From 5e85566fc3ecbb1e88603d8851de27991042fdcc Mon Sep 17 00:00:00 2001 From: Torsten Grote Date: Tue, 5 Nov 2019 12:54:02 -0300 Subject: [PATCH] [android] check if REQUEST_BLUETOOTH_DISCOVERABLE is available before launching --- .../android/keyagreement/KeyAgreementActivity.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/briar-android/src/main/java/org/briarproject/briar/android/keyagreement/KeyAgreementActivity.java b/briar-android/src/main/java/org/briarproject/briar/android/keyagreement/KeyAgreementActivity.java index 4298e89c6..05c2546e6 100644 --- a/briar-android/src/main/java/org/briarproject/briar/android/keyagreement/KeyAgreementActivity.java +++ b/briar-android/src/main/java/org/briarproject/briar/android/keyagreement/KeyAgreementActivity.java @@ -183,10 +183,14 @@ public abstract class KeyAgreementActivity extends BriarActivity implements if (bt == null) { setBluetoothState(BluetoothState.NO_ADAPTER); } else { - setBluetoothState(BluetoothState.WAITING); - wasAdapterEnabled = bt.isEnabled(); Intent i = new Intent(ACTION_REQUEST_DISCOVERABLE); - startActivityForResult(i, REQUEST_BLUETOOTH_DISCOVERABLE); + if (i.resolveActivity(getPackageManager()) != null) { + setBluetoothState(BluetoothState.WAITING); + wasAdapterEnabled = bt.isEnabled(); + startActivityForResult(i, REQUEST_BLUETOOTH_DISCOVERABLE); + } else { + setBluetoothState(BluetoothState.NO_ADAPTER); + } } }