Bug 921999 - Bluetooth Device connection status in Settings is incorrect if remote headset restores connection, r=gyeh
authorBen Tian <btian@mozilla.com>
Thu, 23 Jan 2014 10:46:45 +0800
changeset 164819 59e7a57ee3e178bcd2b28a0d84a69b13155e7062
parent 164818 fa94b385f0dc78d22fc6feedb203947557821508
child 164820 720859a0231da4734d985b53a8b901c91b90b219
push id26062
push usercbook@mozilla.com
push dateThu, 23 Jan 2014 09:21:18 +0000
treeherdermozilla-central@1a75d37e1e39 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgyeh
bugs921999
milestone29.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 921999 - Bluetooth Device connection status in Settings is incorrect if remote headset restores connection, r=gyeh
dom/bluetooth/bluedroid/BluetoothA2dpManager.cpp
dom/bluetooth/bluez/BluetoothA2dpManager.cpp
--- a/dom/bluetooth/bluedroid/BluetoothA2dpManager.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothA2dpManager.cpp
@@ -671,16 +671,24 @@ BluetoothA2dpManager::OnDisconnect(const
 void
 BluetoothA2dpManager::HandleSinkPropertyChanged(const BluetoothSignal& aSignal)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(aSignal.value().type() ==
              BluetoothValue::TArrayOfBluetoothNamedValue);
 
   const nsString& address = aSignal.path();
+  /**
+   * Update sink property only if
+   * - mDeviceAddress is empty (A2dp is disconnected), or
+   * - this property change is from the connected sink.
+   */
+  NS_ENSURE_TRUE_VOID(mDeviceAddress.IsEmpty() ||
+                      mDeviceAddress.Equals(address));
+
   const InfallibleTArray<BluetoothNamedValue>& arr =
     aSignal.value().get_ArrayOfBluetoothNamedValue();
   MOZ_ASSERT(arr.Length() == 1);
 
   /**
    * There are three properties:
    * - "State": a string
    * - "Connected": a boolean value
--- a/dom/bluetooth/bluez/BluetoothA2dpManager.cpp
+++ b/dom/bluetooth/bluez/BluetoothA2dpManager.cpp
@@ -252,16 +252,24 @@ BluetoothA2dpManager::OnDisconnect(const
  */
 void
 BluetoothA2dpManager::HandleSinkPropertyChanged(const BluetoothSignal& aSignal)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(aSignal.value().type() == BluetoothValue::TArrayOfBluetoothNamedValue);
 
   const nsString& address = aSignal.path();
+  /**
+   * Update sink property only if
+   * - mDeviceAddress is empty (A2dp is disconnected), or
+   * - this property change is from the connected sink.
+   */
+  NS_ENSURE_TRUE_VOID(mDeviceAddress.IsEmpty() ||
+                      mDeviceAddress.Equals(address));
+
   const InfallibleTArray<BluetoothNamedValue>& arr =
     aSignal.value().get_ArrayOfBluetoothNamedValue();
   MOZ_ASSERT(arr.Length() == 1);
 
   /**
    * There are three properties:
    * - "State": a string
    * - "Connected": a boolean value