kopia lustrzana https://github.com/ryukoposting/Signal-Android
Fix crash when bluetooth is unavailable for calling.
rodzic
9c59d6a69b
commit
c4d317b33e
|
@ -131,7 +131,6 @@ public final class WebRtcCallService extends Service implements BluetoothStateMa
|
||||||
wiredHeadsetStateReceiver = null;
|
wiredHeadsetStateReceiver = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
unregisterNetworkReceiver();
|
|
||||||
unregisterNetworkReceiver();
|
unregisterNetworkReceiver();
|
||||||
|
|
||||||
TelephonyUtil.getManager(this)
|
TelephonyUtil.getManager(this)
|
||||||
|
|
|
@ -44,16 +44,22 @@ public class BluetoothStateManager {
|
||||||
private boolean wantsConnection = false;
|
private boolean wantsConnection = false;
|
||||||
|
|
||||||
public BluetoothStateManager(@NonNull Context context, @Nullable BluetoothStateListener listener) {
|
public BluetoothStateManager(@NonNull Context context, @Nullable BluetoothStateListener listener) {
|
||||||
this.context = context.getApplicationContext();
|
this.context = context.getApplicationContext();
|
||||||
this.bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
|
||||||
|
BluetoothAdapter localAdapter = BluetoothAdapter.getDefaultAdapter();
|
||||||
|
if (localAdapter == null) {
|
||||||
|
this.bluetoothAdapter = null;
|
||||||
|
this.listener = null;
|
||||||
|
this.destroyed = new AtomicBoolean(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.bluetoothAdapter = localAdapter;
|
||||||
this.bluetoothScoReceiver = new BluetoothScoReceiver();
|
this.bluetoothScoReceiver = new BluetoothScoReceiver();
|
||||||
this.bluetoothConnectionReceiver = new BluetoothConnectionReceiver();
|
this.bluetoothConnectionReceiver = new BluetoothConnectionReceiver();
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
this.destroyed = new AtomicBoolean(false);
|
this.destroyed = new AtomicBoolean(false);
|
||||||
|
|
||||||
if (this.bluetoothAdapter == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
requestHeadsetProxyProfile();
|
requestHeadsetProxyProfile();
|
||||||
|
|
||||||
this.context.registerReceiver(bluetoothConnectionReceiver, new IntentFilter(BluetoothHeadset.ACTION_CONNECTION_STATE_CHANGED));
|
this.context.registerReceiver(bluetoothConnectionReceiver, new IntentFilter(BluetoothHeadset.ACTION_CONNECTION_STATE_CHANGED));
|
||||||
|
@ -226,7 +232,7 @@ public class BluetoothStateManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface BluetoothStateListener {
|
public interface BluetoothStateListener {
|
||||||
public void onBluetoothStateChanged(boolean isAvailable);
|
void onBluetoothStateChanged(boolean isAvailable);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue