mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 02:39:05 +01:00
Reset BluetoothPlugin reference
When it is assigned before we are signed-in in (like when returning to a killed activity), it would be null and without a reset, we would consider Bluetooth to not be supported.
This commit is contained in:
@@ -47,11 +47,13 @@ class BluetoothConnecter {
|
||||
}
|
||||
|
||||
private final Application app;
|
||||
private final PluginManager pluginManager;
|
||||
private final Executor ioExecutor;
|
||||
private final AndroidExecutor androidExecutor;
|
||||
private final ConnectionRegistry connectionRegistry;
|
||||
private final BluetoothAdapter bt = BluetoothAdapter.getDefaultAdapter();
|
||||
private final Plugin bluetoothPlugin;
|
||||
|
||||
private volatile Plugin bluetoothPlugin;
|
||||
|
||||
private Permission locationPermission = Permission.UNKNOWN;
|
||||
|
||||
@@ -62,6 +64,7 @@ class BluetoothConnecter {
|
||||
AndroidExecutor androidExecutor,
|
||||
ConnectionRegistry connectionRegistry) {
|
||||
this.app = app;
|
||||
this.pluginManager = pluginManager;
|
||||
this.ioExecutor = ioExecutor;
|
||||
this.androidExecutor = androidExecutor;
|
||||
this.bluetoothPlugin = pluginManager.getPlugin(BluetoothConstants.ID);
|
||||
@@ -81,8 +84,12 @@ class BluetoothConnecter {
|
||||
* Call this when the using activity or fragment starts,
|
||||
* because permissions might have changed while it was stopped.
|
||||
*/
|
||||
void resetPermissions() {
|
||||
void reset() {
|
||||
locationPermission = Permission.UNKNOWN;
|
||||
// When this class is instantiated before we are logged in
|
||||
// (like when returning to a killed activity), bluetoothPlugin would be
|
||||
// null and we consider bluetooth not supported. So reset here.
|
||||
bluetoothPlugin = pluginManager.getPlugin(BluetoothConstants.ID);
|
||||
}
|
||||
|
||||
@UiThread
|
||||
@@ -99,9 +106,6 @@ class BluetoothConnecter {
|
||||
}
|
||||
|
||||
boolean isBluetoothNotSupported() {
|
||||
// When this class is instantiated before we are logged in
|
||||
// (like when returning to a killed activity), bluetoothPlugin will be
|
||||
// null and we consider bluetooth not supported.
|
||||
return bt == null || bluetoothPlugin == null;
|
||||
}
|
||||
|
||||
|
||||
@@ -75,6 +75,7 @@ public class BluetoothConnecterDialogFragment extends DialogFragment {
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
bluetoothConnecter.reset();
|
||||
if (bluetoothConnecter.isBluetoothNotSupported()) {
|
||||
showToast(R.string.toast_connect_via_bluetooth_error);
|
||||
dismiss();
|
||||
@@ -92,9 +93,7 @@ public class BluetoothConnecterDialogFragment extends DialogFragment {
|
||||
if (bluetoothConnecter.isDiscovering()) {
|
||||
// TODO showToast(R.string.toast_connect_via_bluetooth_discovering);
|
||||
dismiss();
|
||||
return;
|
||||
}
|
||||
bluetoothConnecter.resetPermissions();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user