Bug 1029386: Asynchronous Bluedroid DUT and LE interfaces, r=shuang
authorThomas Zimmermann <tdz@users.sourceforge.net>
Thu, 03 Jul 2014 09:53:39 +0200
changeset 205893 7b49b12aab6a27415ac7249713771ab035d162e6
parent 205892 46fcef086ee231a74af8df45404f06e7a28aa9ad
child 205894 c7a5bf97b05898944975132547f52394308bcd0c
push idunknown
push userunknown
push dateunknown
reviewersshuang
bugs1029386
milestone33.0a1
Bug 1029386: Asynchronous Bluedroid DUT and LE interfaces, r=shuang
dom/bluetooth/bluedroid/BluetoothInterface.cpp
dom/bluetooth/bluedroid/BluetoothInterface.h
--- a/dom/bluetooth/bluedroid/BluetoothInterface.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothInterface.cpp
@@ -778,34 +778,59 @@ BluetoothInterface::SspReply(const bt_bd
     DispatchBluetoothResult(aRes,
                             &BluetoothResultHandler::SspReply,
                             status);
   }
 }
 
 /* DUT Mode */
 
-int
-BluetoothInterface::DutModeConfigure(uint8_t aEnable)
+void
+BluetoothInterface::DutModeConfigure(uint8_t aEnable,
+                                     BluetoothResultHandler* aRes)
 {
-  return mInterface->dut_mode_configure(aEnable);
+  int status = mInterface->dut_mode_configure(aEnable);
+
+  if (aRes) {
+    DispatchBluetoothResult(aRes,
+                            &BluetoothResultHandler::DutModeConfigure,
+                            status);
+  }
 }
 
-int
-BluetoothInterface::DutModeSend(uint16_t aOpcode, uint8_t* aBuf, uint8_t aLen)
+void
+BluetoothInterface::DutModeSend(uint16_t aOpcode, uint8_t* aBuf, uint8_t aLen,
+                                BluetoothResultHandler* aRes)
 {
-  return mInterface->dut_mode_send(aOpcode, aBuf, aLen);
+  int status = mInterface->dut_mode_send(aOpcode, aBuf, aLen);
+
+  if (aRes) {
+    DispatchBluetoothResult(aRes,
+                            &BluetoothResultHandler::DutModeSend,
+                            status);
+  }
 }
 
 /* LE Mode */
 
-int
-BluetoothInterface::LeTestMode(uint16_t aOpcode, uint8_t* aBuf, uint8_t aLen)
+void
+BluetoothInterface::LeTestMode(uint16_t aOpcode, uint8_t* aBuf, uint8_t aLen,
+                               BluetoothResultHandler* aRes)
 {
-  return mInterface->le_test_mode(aOpcode, aBuf, aLen);
+#if ANDROID_VERSION >= 18
+  int status = mInterface->le_test_mode(aOpcode, aBuf, aLen);
+#else
+  int status = BT_STATUS_UNSUPPORTED;
+#endif
+
+  if (aRes) {
+    DispatchBluetoothResult(aRes,
+                            &BluetoothResultHandler::LeTestMode,
+                            status);
+  }
 }
 
 /* Profile Interfaces */
 
 template <class T>
 T*
 BluetoothInterface::GetProfileInterface()
 {
--- a/dom/bluetooth/bluedroid/BluetoothInterface.h
+++ b/dom/bluetooth/bluedroid/BluetoothInterface.h
@@ -282,22 +282,24 @@ public:
                 BluetoothResultHandler* aRes);
 
   void SspReply(const bt_bdaddr_t* aBdAddr, bt_ssp_variant_t aVariant,
                 uint8_t aAccept, uint32_t aPasskey,
                 BluetoothResultHandler* aRes);
 
   /* DUT Mode */
 
-  int DutModeConfigure(uint8_t aEnable);
-  int DutModeSend(uint16_t aOpcode, uint8_t* aBuf, uint8_t aLen);
+  void DutModeConfigure(uint8_t aEnable, BluetoothResultHandler* aRes);
+  void DutModeSend(uint16_t aOpcode, uint8_t* aBuf, uint8_t aLen,
+                   BluetoothResultHandler* aRes);
 
   /* LE Mode */
 
-  int LeTestMode(uint16_t aOpcode, uint8_t* aBuf, uint8_t aLen);
+  void LeTestMode(uint16_t aOpcode, uint8_t* aBuf, uint8_t aLen,
+                  BluetoothResultHandler* aRes);
 
   /* Profile Interfaces */
 
   BluetoothSocketInterface* GetBluetoothSocketInterface();
   BluetoothHandsfreeInterface* GetBluetoothHandsfreeInterface();
   BluetoothA2dpInterface* GetBluetoothA2dpInterface();
   BluetoothAvrcpInterface* GetBluetoothAvrcpInterface();