Fix do not unregister bluetooth receiver if it was not registered
Bug: webrtc:7890 Change-Id: Ib46b4a4407fa030500930ed03a093b26c71f8963 Reviewed-on: https://chromium-review.googlesource.com/550617 Commit-Queue: Henrik Andreasson <henrika@webrtc.org> Reviewed-by: Henrik Andreasson <henrika@webrtc.org> Cr-Commit-Position: refs/heads/master@{#18892}
This commit is contained in:
committed by
Commit Bot
parent
cc8856c9c2
commit
c43f68e52c
@ -276,23 +276,25 @@ public class AppRTCBluetoothManager {
|
||||
/** Stops and closes all components related to Bluetooth audio. */
|
||||
public void stop() {
|
||||
ThreadUtils.checkIsOnMainThread();
|
||||
unregisterReceiver(bluetoothHeadsetReceiver);
|
||||
Log.d(TAG, "stop: BT state=" + bluetoothState);
|
||||
if (bluetoothAdapter != null) {
|
||||
// Stop BT SCO connection with remote device if needed.
|
||||
stopScoAudio();
|
||||
// Close down remaining BT resources.
|
||||
if (bluetoothState != State.UNINITIALIZED) {
|
||||
cancelTimer();
|
||||
if (bluetoothHeadset != null) {
|
||||
bluetoothAdapter.closeProfileProxy(BluetoothProfile.HEADSET, bluetoothHeadset);
|
||||
bluetoothHeadset = null;
|
||||
}
|
||||
bluetoothAdapter = null;
|
||||
bluetoothDevice = null;
|
||||
bluetoothState = State.UNINITIALIZED;
|
||||
}
|
||||
if (bluetoothAdapter == null) {
|
||||
return;
|
||||
}
|
||||
// Stop BT SCO connection with remote device if needed.
|
||||
stopScoAudio();
|
||||
// Close down remaining BT resources.
|
||||
if (bluetoothState == State.UNINITIALIZED) {
|
||||
return;
|
||||
}
|
||||
unregisterReceiver(bluetoothHeadsetReceiver);
|
||||
cancelTimer();
|
||||
if (bluetoothHeadset != null) {
|
||||
bluetoothAdapter.closeProfileProxy(BluetoothProfile.HEADSET, bluetoothHeadset);
|
||||
bluetoothHeadset = null;
|
||||
}
|
||||
bluetoothAdapter = null;
|
||||
bluetoothDevice = null;
|
||||
bluetoothState = State.UNINITIALIZED;
|
||||
Log.d(TAG, "stop done: BT state=" + bluetoothState);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user