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
1
AUTHORS
1
AUTHORS
@ -19,6 +19,7 @@ Eric Rescorla, RTFM Inc. <ekr@rtfm.com>
|
||||
Frederik Riedel, Frogg GmbH <frederik.riedel@frogg.io>
|
||||
Giji Gangadharan <giji.g@samsung.com>
|
||||
Graham Yoakum <gyoakum@skobalt.com>
|
||||
Gustavo Garcia <gustavogb@gmail.com>
|
||||
Hugues Ekra <hekra01@gmail.com>
|
||||
Jake Hilton <jakehilton@gmail.com>
|
||||
James H. Brown <jbrown@burgoyne.com>
|
||||
|
@ -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