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 164741 59e7a57ee3e178bcd2b28a0d84a69b13155e7062
parent 164740 fa94b385f0dc78d22fc6feedb203947557821508
child 164742 720859a0231da4734d985b53a8b901c91b90b219
push id4088
push userbtian@mozilla.com
push dateThu, 23 Jan 2014 02:47:40 +0000
treeherderb2g-inbound@59e7a57ee3e1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgyeh
bugs921999
milestone29.0a1
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