mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 10:49:06 +01:00
Check if Bluetooth is supported before requesting discoverability
This commit is contained in:
@@ -143,17 +143,13 @@ public class AddNearbyContactActivity extends BriarActivity
|
||||
}
|
||||
|
||||
private void requestBluetoothDiscoverable() {
|
||||
if (!viewModel.isBluetoothSupported()) {
|
||||
viewModel.setBluetoothDecision(BluetoothDecision.NO_ADAPTER);
|
||||
Intent i = new Intent(ACTION_REQUEST_DISCOVERABLE);
|
||||
if (i.resolveActivity(getPackageManager()) != null) {
|
||||
LOG.info("Asking for Bluetooth discoverability");
|
||||
viewModel.setBluetoothDecision(BluetoothDecision.WAITING);
|
||||
bluetoothLauncher.launch(120); // 2min discoverable
|
||||
} else {
|
||||
Intent i = new Intent(ACTION_REQUEST_DISCOVERABLE);
|
||||
if (i.resolveActivity(getPackageManager()) != null) {
|
||||
LOG.info("Asking for Bluetooth discoverability");
|
||||
viewModel.setBluetoothDecision(BluetoothDecision.WAITING);
|
||||
bluetoothLauncher.launch(120); // 2min discoverable
|
||||
} else {
|
||||
viewModel.setBluetoothDecision(BluetoothDecision.NO_ADAPTER);
|
||||
}
|
||||
viewModel.setBluetoothDecision(BluetoothDecision.NO_ADAPTER);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -84,6 +84,7 @@ import static org.briarproject.bramble.api.plugin.Plugin.State.STARTING_STOPPING
|
||||
import static org.briarproject.bramble.util.LogUtils.logException;
|
||||
import static org.briarproject.briar.android.contact.add.nearby.AddNearbyContactPermissionManager.areEssentialPermissionsGranted;
|
||||
import static org.briarproject.briar.android.contact.add.nearby.AddNearbyContactPermissionManager.isLocationEnabled;
|
||||
import static org.briarproject.briar.android.contact.add.nearby.AddNearbyContactViewModel.BluetoothDecision.NO_ADAPTER;
|
||||
import static org.briarproject.briar.android.contact.add.nearby.AddNearbyContactViewModel.BluetoothDecision.REFUSED;
|
||||
import static org.briarproject.briar.android.contact.add.nearby.AddNearbyContactViewModel.BluetoothDecision.UNKNOWN;
|
||||
|
||||
@@ -375,7 +376,11 @@ class AddNearbyContactViewModel extends AndroidViewModel
|
||||
} else {
|
||||
enableWifiIfWeShould();
|
||||
if (bluetoothDecision == UNKNOWN) {
|
||||
requestBluetoothDiscoverable.setEvent(true);
|
||||
if (isBluetoothSupported()) {
|
||||
requestBluetoothDiscoverable.setEvent(true);
|
||||
} else {
|
||||
bluetoothDecision = NO_ADAPTER;
|
||||
}
|
||||
} else if (bluetoothDecision == REFUSED) {
|
||||
// Ask again when the user clicks "continue"
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user