Bug 1102703 - Extend internal interfaces to sync with android lollipop and bluez 5.26 (core). r=btian, f=tzimmermann
☠☠ backed out by b4926227268f ☠ ☠
authorBruce Sun <brsun@mozilla.com>
Thu, 08 Jan 2015 11:44:49 +0800
changeset 248493 50eed0f4edc7036380841901920b4623c7d0f9c9
parent 248492 fa7a1beefeb991bd2bdaf4207963486e58bfff95
child 248494 411ab2917e49547a133d95282849eff928a59344
push id4489
push userraliiev@mozilla.com
push dateMon, 23 Feb 2015 15:17:55 +0000
treeherdermozilla-beta@fd7c3dc24146 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbtian
bugs1102703
milestone37.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 1102703 - Extend internal interfaces to sync with android lollipop and bluez 5.26 (core). r=btian, f=tzimmermann
dom/bluetooth/BluetoothCommon.h
dom/bluetooth/BluetoothInterface.h
dom/bluetooth/bluedroid/BluetoothDaemonInterface.cpp
dom/bluetooth/bluedroid/BluetoothDaemonInterface.h
dom/bluetooth/bluedroid/BluetoothHALInterface.cpp
dom/bluetooth/bluedroid/BluetoothHALInterface.h
dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp
dom/bluetooth/bluedroid/BluetoothServiceBluedroid.h
--- a/dom/bluetooth/BluetoothCommon.h
+++ b/dom/bluetooth/BluetoothCommon.h
@@ -230,16 +230,32 @@ struct BluetoothProperty {
 
   /* PROPERTY_SCAN_MODE */
   BluetoothScanMode mScanMode;
 
   /* PROPERTY_REMOTE_VERSION_INFO */
   BluetoothRemoteInfo mRemoteInfo;
 };
 
+/* Physical transport for GATT connections to remote dual-mode devices */
+enum BluetoothTransport {
+  TRANSPORT_AUTO,   /* No preference of physical transport */
+  TRANSPORT_BREDR,  /* Prefer BR/EDR transport */
+  TRANSPORT_LE      /* Prefer LE transport */
+};
+
+struct BluetoothActivityEnergyInfo {
+  uint8_t mStatus;
+  uint8_t mStackState;  /* stack reported state */
+  uint64_t mTxTime;     /* in ms */
+  uint64_t mRxTime;     /* in ms */
+  uint64_t mIdleTime;   /* in ms */
+  uint64_t mEnergyUsed; /* a product of mA, V and ms */
+};
+
 enum BluetoothSocketType {
   RFCOMM = 1,
   SCO    = 2,
   L2CAP  = 3,
   EL2CAP = 4
 };
 
 enum BluetoothHandsfreeAtResponse {
--- a/dom/bluetooth/BluetoothInterface.h
+++ b/dom/bluetooth/BluetoothInterface.h
@@ -490,16 +490,19 @@ public:
                                            const nsAString& aRemoteBdAddr,
                                            bool aState) { }
 
   virtual void DutModeRecvNotification(uint16_t aOpcode,
                                        const uint8_t* aBuf, uint8_t aLen) { }
   virtual void LeTestModeNotification(BluetoothStatus aStatus,
                                       uint16_t aNumPackets) { }
 
+  virtual void EnergyInfoNotification(const BluetoothActivityEnergyInfo& aInfo)
+  { }
+
 protected:
   BluetoothNotificationHandler()
   { }
 };
 
 class BluetoothResultHandler
 {
 public:
@@ -530,23 +533,27 @@ public:
 
   virtual void StartDiscovery() { }
   virtual void CancelDiscovery() { }
 
   virtual void CreateBond() { }
   virtual void RemoveBond() { }
   virtual void CancelBond() { }
 
+  virtual void GetConnectionState() { }
+
   virtual void PinReply() { }
   virtual void SspReply() { }
 
   virtual void DutModeConfigure() { }
   virtual void DutModeSend() { }
 
   virtual void LeTestMode() { }
+
+  virtual void ReadEnergyInfo() { }
 };
 
 class BluetoothInterface
 {
 public:
   static BluetoothInterface* GetInstance();
 
   virtual void Init(BluetoothNotificationHandler* aNotificationHandler,
@@ -586,22 +593,28 @@ public:
   /* Discovery */
 
   virtual void StartDiscovery(BluetoothResultHandler* aRes) = 0;
   virtual void CancelDiscovery(BluetoothResultHandler* aRes) = 0;
 
   /* Bonds */
 
   virtual void CreateBond(const nsAString& aBdAddr,
+                          BluetoothTransport aTransport,
                           BluetoothResultHandler* aRes) = 0;
   virtual void RemoveBond(const nsAString& aBdAddr,
                           BluetoothResultHandler* aRes) = 0;
   virtual void CancelBond(const nsAString& aBdAddr,
                           BluetoothResultHandler* aRes) = 0;
 
+  /* Connection */
+
+  virtual void GetConnectionState(const nsAString& aBdAddr,
+                                  BluetoothResultHandler* aRes) = 0;
+
   /* Authentication */
 
   virtual void PinReply(const nsAString& aBdAddr, bool aAccept,
                         const nsAString& aPinCode,
                         BluetoothResultHandler* aRes) = 0;
 
   virtual void SspReply(const nsAString& aBdAddr, const nsAString& aVariant,
                         bool aAccept, uint32_t aPasskey,
@@ -614,16 +627,20 @@ public:
   virtual void DutModeSend(uint16_t aOpcode, uint8_t* aBuf, uint8_t aLen,
                            BluetoothResultHandler* aRes) = 0;
 
   /* LE Mode */
 
   virtual void LeTestMode(uint16_t aOpcode, uint8_t* aBuf, uint8_t aLen,
                           BluetoothResultHandler* aRes) = 0;
 
+  /* Energy Info */
+
+  virtual void ReadEnergyInfo(BluetoothResultHandler* aRes) = 0;
+
   /* Profile Interfaces */
 
   virtual BluetoothSocketInterface* GetBluetoothSocketInterface() = 0;
   virtual BluetoothHandsfreeInterface* GetBluetoothHandsfreeInterface() = 0;
   virtual BluetoothA2dpInterface* GetBluetoothA2dpInterface() = 0;
   virtual BluetoothAvrcpInterface* GetBluetoothAvrcpInterface() = 0;
 
 protected:
--- a/dom/bluetooth/bluedroid/BluetoothDaemonInterface.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothDaemonInterface.cpp
@@ -401,16 +401,17 @@ public:
     if (NS_FAILED(rv)) {
       return rv;
     }
     unused << pdu.forget();
     return rv;
   }
 
   nsresult CreateBondCmd(const nsAString& aBdAddr,
+                         BluetoothTransport aTransport,
                          BluetoothResultHandler* aRes)
   {
     MOZ_ASSERT(NS_IsMainThread());
 
     nsAutoPtr<BluetoothDaemonPDU> pdu(new BluetoothDaemonPDU(0x01, 0x0d, 0));
 
     nsresult rv = PackPDU(
       PackConversion<nsAString, BluetoothAddress>(aBdAddr), *pdu);
@@ -2012,20 +2013,21 @@ BluetoothDaemonInterface::CancelDiscover
   static_cast<BluetoothDaemonCoreModule*>
     (mProtocol)->CancelDiscoveryCmd(aRes);
 }
 
 /* Bonds */
 
 void
 BluetoothDaemonInterface::CreateBond(const nsAString& aBdAddr,
+                                     BluetoothTransport aTransport,
                                      BluetoothResultHandler* aRes)
 {
   static_cast<BluetoothDaemonCoreModule*>
-    (mProtocol)->CreateBondCmd(aBdAddr, aRes);
+    (mProtocol)->CreateBondCmd(aBdAddr, aTransport, aRes);
 }
 
 void
 BluetoothDaemonInterface::RemoveBond(const nsAString& aBdAddr,
                                      BluetoothResultHandler* aRes)
 {
   static_cast<BluetoothDaemonCoreModule*>
     (mProtocol)->RemoveBondCmd(aBdAddr, aRes);
@@ -2034,16 +2036,25 @@ BluetoothDaemonInterface::RemoveBond(con
 void
 BluetoothDaemonInterface::CancelBond(const nsAString& aBdAddr,
                                      BluetoothResultHandler* aRes)
 {
   static_cast<BluetoothDaemonCoreModule*>
     (mProtocol)->CancelBondCmd(aBdAddr, aRes);
 }
 
+/* Connection */
+
+void
+BluetoothDaemonInterface::GetConnectionState(const nsAString& aBdAddr,
+                                             BluetoothResultHandler* aRes)
+{
+  // NO-OP: no corresponding interface of current BlueZ
+}
+
 /* Authentication */
 
 void
 BluetoothDaemonInterface::PinReply(const nsAString& aBdAddr, bool aAccept,
                                    const nsAString& aPinCode,
                                    BluetoothResultHandler* aRes)
 {
   static_cast<BluetoothDaemonCoreModule*>
@@ -2085,16 +2096,24 @@ void
 BluetoothDaemonInterface::LeTestMode(uint16_t aOpcode, uint8_t* aBuf,
                                      uint8_t aLen,
                                      BluetoothResultHandler* aRes)
 {
   static_cast<BluetoothDaemonCoreModule*>
     (mProtocol)->LeTestModeCmd(aOpcode, aBuf, aLen, aRes);
 }
 
+/* Energy Information */
+
+void
+BluetoothDaemonInterface::ReadEnergyInfo(BluetoothResultHandler* aRes)
+{
+  // NO-OP: no corresponding interface of current BlueZ
+}
+
 void
 BluetoothDaemonInterface::DispatchError(BluetoothResultHandler* aRes,
                                         BluetoothStatus aStatus)
 {
   BluetoothResultRunnable1<
     BluetoothResultHandler, void, BluetoothStatus, BluetoothStatus>::Dispatch(
     aRes, &BluetoothResultHandler::OnError,
     ConstantInitOp1<BluetoothStatus>(aStatus));
--- a/dom/bluetooth/bluedroid/BluetoothDaemonInterface.h
+++ b/dom/bluetooth/bluedroid/BluetoothDaemonInterface.h
@@ -66,20 +66,26 @@ public:
 
   /* Discovery */
 
   void StartDiscovery(BluetoothResultHandler* aRes);
   void CancelDiscovery(BluetoothResultHandler* aRes);
 
   /* Bonds */
 
-  void CreateBond(const nsAString& aBdAddr, BluetoothResultHandler* aRes);
+  void CreateBond(const nsAString& aBdAddr, BluetoothTransport aTransport,
+                  BluetoothResultHandler* aRes);
   void RemoveBond(const nsAString& aBdAddr, BluetoothResultHandler* aRes);
   void CancelBond(const nsAString& aBdAddr, BluetoothResultHandler* aRes);
 
+  /* Connection */
+
+  void GetConnectionState(const nsAString& aBdAddr,
+                          BluetoothResultHandler* aRes);
+
   /* Authentication */
 
   void PinReply(const nsAString& aBdAddr, bool aAccept,
                 const nsAString& aPinCode,
                 BluetoothResultHandler* aRes);
 
   void SspReply(const nsAString& aBdAddr, const nsAString& aVariant,
                 bool aAccept, uint32_t aPasskey,
@@ -91,16 +97,20 @@ public:
   void DutModeSend(uint16_t aOpcode, uint8_t* aBuf, uint8_t aLen,
                    BluetoothResultHandler* aRes);
 
   /* LE Mode */
 
   void LeTestMode(uint16_t aOpcode, uint8_t* aBuf, uint8_t aLen,
                   BluetoothResultHandler* aRes);
 
+  /* Energy Information */
+
+  void ReadEnergyInfo(BluetoothResultHandler* aRes);
+
   /* Profile Interfaces */
 
   BluetoothSocketInterface* GetBluetoothSocketInterface() MOZ_OVERRIDE;
   BluetoothHandsfreeInterface* GetBluetoothHandsfreeInterface() MOZ_OVERRIDE;
   BluetoothA2dpInterface* GetBluetoothA2dpInterface() MOZ_OVERRIDE;
   BluetoothAvrcpInterface* GetBluetoothAvrcpInterface() MOZ_OVERRIDE;
 
 protected:
--- a/dom/bluetooth/bluedroid/BluetoothHALInterface.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothHALInterface.cpp
@@ -171,16 +171,21 @@ struct BluetoothCallback
                                             uint16_t, nsAutoArrayPtr<uint8_t>,
                                             uint8_t, uint16_t, const uint8_t*>
     DutModeRecvNotification;
 
   typedef BluetoothNotificationHALRunnable2<NotificationHandlerWrapper, void,
                                             BluetoothStatus, uint16_t>
     LeTestModeNotification;
 
+  typedef BluetoothNotificationHALRunnable1<NotificationHandlerWrapper, void,
+                                            BluetoothActivityEnergyInfo,
+                                            const BluetoothActivityEnergyInfo&>
+    EnergyInfoNotification;
+
   // Bluedroid callbacks
 
   static const bt_property_t*
   AlignedProperties(bt_property_t* aProperties, size_t aNumProperties,
                     nsAutoArrayPtr<bt_property_t>& aPropertiesArray)
   {
     // See Bug 989976: consider aProperties address is not aligned. If
     // it is aligned, we return the pointer directly; otherwise we make
@@ -660,16 +665,17 @@ BluetoothHALInterface::CancelDiscovery(B
                                ConvertDefault(status, STATUS_FAIL));
   }
 }
 
 /* Bonds */
 
 void
 BluetoothHALInterface::CreateBond(const nsAString& aBdAddr,
+                                  BluetoothTransport aTransport,
                                   BluetoothResultHandler* aRes)
 {
   bt_bdaddr_t bdAddr;
   int status;
 
   if (NS_SUCCEEDED(Convert(aBdAddr, bdAddr))) {
     status = mInterface->create_bond(&bdAddr);
   } else {
@@ -718,16 +724,33 @@ BluetoothHALInterface::CancelBond(const 
 
   if (aRes) {
     DispatchBluetoothHALResult(aRes,
                                &BluetoothResultHandler::CancelBond,
                                ConvertDefault(status, STATUS_FAIL));
   }
 }
 
+/* Connection */
+
+void
+BluetoothHALInterface::GetConnectionState(const nsAString& aBdAddr,
+                                          BluetoothResultHandler* aRes)
+{
+  // TODO: to be implemented
+
+  int status = BT_STATUS_UNSUPPORTED;
+
+  if (aRes) {
+    DispatchBluetoothHALResult(aRes,
+                               &BluetoothResultHandler::GetConnectionState,
+                               ConvertDefault(status, STATUS_FAIL));
+  }
+}
+
 /* Authentication */
 
 void
 BluetoothHALInterface::PinReply(const nsAString& aBdAddr, bool aAccept,
                                 const nsAString& aPinCode,
                                 BluetoothResultHandler* aRes)
 {
   int status;
@@ -826,16 +849,31 @@ BluetoothHALInterface::LeTestMode(uint16
 
   if (aRes) {
     DispatchBluetoothHALResult(aRes,
                                &BluetoothResultHandler::LeTestMode,
                                ConvertDefault(status, STATUS_FAIL));
   }
 }
 
+/* Energy Information */
+void
+BluetoothHALInterface::ReadEnergyInfo(BluetoothResultHandler* aRes)
+{
+  // TODO: to be implemented
+
+  int status = BT_STATUS_UNSUPPORTED;
+
+  if (aRes) {
+    DispatchBluetoothHALResult(aRes,
+                               &BluetoothResultHandler::ReadEnergyInfo,
+                               ConvertDefault(status, STATUS_FAIL));
+  }
+}
+
 /* Profile Interfaces */
 
 template <class T>
 T*
 BluetoothHALInterface::CreateProfileInterface()
 {
   typename interface_traits<T>::const_interface_type* interface =
     reinterpret_cast<typename interface_traits<T>::const_interface_type*>(
--- a/dom/bluetooth/bluedroid/BluetoothHALInterface.h
+++ b/dom/bluetooth/bluedroid/BluetoothHALInterface.h
@@ -54,20 +54,26 @@ public:
 
   /* Discovery */
 
   void StartDiscovery(BluetoothResultHandler* aRes);
   void CancelDiscovery(BluetoothResultHandler* aRes);
 
   /* Bonds */
 
-  void CreateBond(const nsAString& aBdAddr, BluetoothResultHandler* aRes);
+  void CreateBond(const nsAString& aBdAddr, BluetoothTransport aTransport,
+                  BluetoothResultHandler* aRes);
   void RemoveBond(const nsAString& aBdAddr, BluetoothResultHandler* aRes);
   void CancelBond(const nsAString& aBdAddr, BluetoothResultHandler* aRes);
 
+  /* Connection */
+
+  void GetConnectionState(const nsAString& aBdAddr,
+                          BluetoothResultHandler* aRes);
+
   /* Authentication */
 
   void PinReply(const nsAString& aBdAddr, bool aAccept,
                 const nsAString& aPinCode,
                 BluetoothResultHandler* aRes);
 
   void SspReply(const nsAString& aBdAddr, const nsAString& aVariant,
                 bool aAccept, uint32_t aPasskey,
@@ -79,16 +85,20 @@ public:
   void DutModeSend(uint16_t aOpcode, uint8_t* aBuf, uint8_t aLen,
                    BluetoothResultHandler* aRes);
 
   /* LE Mode */
 
   void LeTestMode(uint16_t aOpcode, uint8_t* aBuf, uint8_t aLen,
                   BluetoothResultHandler* aRes);
 
+  /* Energy Information */
+
+  void ReadEnergyInfo(BluetoothResultHandler* aRes);
+
   /* Profile Interfaces */
 
   BluetoothSocketInterface* GetBluetoothSocketInterface();
   BluetoothHandsfreeInterface* GetBluetoothHandsfreeInterface();
   BluetoothA2dpInterface* GetBluetoothA2dpInterface();
   BluetoothAvrcpInterface* GetBluetoothAvrcpInterface();
 
 protected:
--- a/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp
@@ -688,17 +688,17 @@ BluetoothServiceBluedroid::CreatePairedD
   BluetoothReplyRunnable* aRunnable)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   ENSURE_BLUETOOTH_IS_READY(aRunnable, NS_OK);
 
   sBondingRunnableArray.AppendElement(aRunnable);
 
-  sBtInterface->CreateBond(aDeviceAddress,
+  sBtInterface->CreateBond(aDeviceAddress, TRANSPORT_AUTO,
                            new CreateBondResultHandler(aRunnable));
 
   return NS_OK;
 }
 
 class BluetoothServiceBluedroid::RemoveBondResultHandler MOZ_FINAL
   : public BluetoothResultHandler
 {
@@ -1618,8 +1618,17 @@ BluetoothServiceBluedroid::DutModeRecvNo
 void
 BluetoothServiceBluedroid::LeTestModeNotification(BluetoothStatus aStatus,
                                                   uint16_t aNumPackets)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   // FIXME: This will be implemented in the later patchset
 }
+
+void
+BluetoothServiceBluedroid::EnergyInfoNotification(
+  const BluetoothActivityEnergyInfo& aInfo)
+{
+  MOZ_ASSERT(NS_IsMainThread());
+
+  // FIXME: This will be implemented in the later patchset
+}
--- a/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.h
+++ b/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.h
@@ -207,16 +207,19 @@ public:
                                            bool aState) MOZ_OVERRIDE;
 
   virtual void DutModeRecvNotification(uint16_t aOpcode,
                                        const uint8_t* aBuf,
                                        uint8_t aLen) MOZ_OVERRIDE;
   virtual void LeTestModeNotification(BluetoothStatus aStatus,
                                       uint16_t aNumPackets) MOZ_OVERRIDE;
 
+  virtual void EnergyInfoNotification(
+    const BluetoothActivityEnergyInfo& aInfo) MOZ_OVERRIDE;
+
 protected:
   static nsresult StartGonkBluetooth();
   static nsresult StopGonkBluetooth();
   static bool EnsureBluetoothHalLoad();
 
   static void ClassToIcon(uint32_t aClass, nsAString& aRetIcon);
 
   static ControlPlayStatus PlayStatusStringToControlPlayStatus(