Bug 1156503 - Update device name from |RemoteDevicePropertiesNotification| during discovery. r=shuang, a=kkuo
authorBen Tian <btian@mozilla.com>
Thu, 30 Apr 2015 16:47:57 +0800
changeset 238356 70782f19acbfc2f1d7c74444b9d9cd027a7e56f6
parent 238355 ae7e61e290cbc76b4cc966a95a3dae27bd54e964
child 238357 7e776e5febe500e19072199d2b72558c92ca65c1
push id586
push userryanvm@gmail.com
push dateMon, 11 May 2015 21:56:27 +0000
treeherdermozilla-b2g37_v2_2@70782f19acbf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersshuang, kkuo
bugs1156503
milestone37.0
Bug 1156503 - Update device name from |RemoteDevicePropertiesNotification| during discovery. r=shuang, a=kkuo
dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp
--- a/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp
@@ -1378,17 +1378,18 @@ BluetoothServiceBluedroid::AdapterProper
     sSetPropertyRunnableArray.RemoveElementAt(0);
   }
 }
 
 /**
  * RemoteDevicePropertiesNotification will be called
  *
  *   (1) automatically by Bluedroid when BT is turning on, or
- *   (2) as result of GetRemoteDeviceProperties.
+ *   (2) as result of remote device properties update during discovery, or
+ *   (3) as result of GetRemoteDeviceProperties.
  */
 void
 BluetoothServiceBluedroid::RemoteDevicePropertiesNotification(
   BluetoothStatus aStatus, const nsAString& aBdAddr,
   int aNumProperties, const BluetoothProperty* aProperties)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
@@ -1457,18 +1458,28 @@ BluetoothServiceBluedroid::RemoteDeviceP
     }
   }
 
   // BlueDroid wouldn't notify the status of connection, therefore, query the
   // connection state and append to properties array
   BT_APPEND_NAMED_VALUE(props, "Connected", IsConnected(aBdAddr));
 
   if (sRequestedDeviceCountArray.IsEmpty()) {
-    // This is possible because the callback would be called after turning
-    // Bluetooth on.
+    /**
+     * This is possible when
+     *
+     *  (1) the callback is called after Bluetooth is turned on, or
+     *  (2) remote device properties get updated during discovery.
+     *
+     * For (2), fire 'devicefound' again to update device name.
+     * See bug 1076553 for more information.
+     */
+    DistributeSignal(BluetoothSignal(NS_LITERAL_STRING("DeviceFound"),
+                                     NS_LITERAL_STRING(KEY_ADAPTER),
+                                     BluetoothValue(props)));
     return;
   }
 
   // Use address as the index
   sRemoteDevicesPack.AppendElement(
     BluetoothNamedValue(nsString(aBdAddr), props));
 
   if (--sRequestedDeviceCountArray[0] == 0) {