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}
diff --git a/AUTHORS b/AUTHORS
index cb537cf..3a17351 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -19,6 +19,7 @@
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>
diff --git a/webrtc/examples/androidapp/src/org/appspot/apprtc/AppRTCBluetoothManager.java b/webrtc/examples/androidapp/src/org/appspot/apprtc/AppRTCBluetoothManager.java
index 10b1a5c..99979a3 100644
--- a/webrtc/examples/androidapp/src/org/appspot/apprtc/AppRTCBluetoothManager.java
+++ b/webrtc/examples/androidapp/src/org/appspot/apprtc/AppRTCBluetoothManager.java
@@ -276,23 +276,25 @@
/** 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);
}