Bug 1209469: Expose |BluetoothAclState| in Bluetooth backend interface, r=brsun
authorThomas Zimmermann <tdz@users.sourceforge.net>
Fri, 02 Oct 2015 11:07:47 +0200
changeset 265808 b0ead0d45e13b8cdea19455cf601ff5b19a653b3
parent 265807 48dfb07204e30ef627509394a5e95cac9f416fe8
child 265809 c12ac1a74a8f9230306953ee7098854134259986
push id66032
push userkwierso@gmail.com
push dateFri, 02 Oct 2015 20:43:24 +0000
treeherdermozilla-inbound@03e8acfc181f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbrsun
bugs1209469
milestone44.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 1209469: Expose |BluetoothAclState| in Bluetooth backend interface, r=brsun
dom/bluetooth/bluedroid/BluetoothDaemonCoreInterface.cpp
dom/bluetooth/bluedroid/BluetoothDaemonCoreInterface.h
dom/bluetooth/bluedroid/BluetoothDaemonHelpers.cpp
dom/bluetooth/bluedroid/BluetoothDaemonHelpers.h
dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp
dom/bluetooth/bluedroid/BluetoothServiceBluedroid.h
dom/bluetooth/common/BluetoothCommon.h
dom/bluetooth/common/BluetoothInterface.cpp
dom/bluetooth/common/BluetoothInterface.h
--- a/dom/bluetooth/bluedroid/BluetoothDaemonCoreInterface.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothDaemonCoreInterface.cpp
@@ -1108,35 +1108,34 @@ class BluetoothDaemonCoreModule::AclStat
 {
 public:
   AclStateChangedInitOp(DaemonSocketPDU& aPDU)
     : PDUInitOp(aPDU)
   { }
 
   nsresult
   operator () (BluetoothStatus& aArg1, BluetoothAddress& aArg2,
-               bool& aArg3) const
+               BluetoothAclState& aArg3) const
   {
     DaemonSocketPDU& pdu = GetPDU();
 
     /* Read status */
     nsresult rv = UnpackPDU(pdu, aArg1);
     if (NS_FAILED(rv)) {
       return rv;
     }
 
     /* Read remote address */
     rv = UnpackPDU(pdu, aArg2);
     if (NS_FAILED(rv)) {
       return rv;
     }
 
     /* Read ACL state */
-    rv = UnpackPDU(
-      pdu, UnpackConversion<BluetoothAclState, bool>(aArg3));
+    rv = UnpackPDU(pdu, aArg3);
     if (NS_FAILED(rv)) {
       return rv;
     }
     WarnAboutTrailingData();
     return NS_OK;
   }
 };
 
--- a/dom/bluetooth/bluedroid/BluetoothDaemonCoreInterface.h
+++ b/dom/bluetooth/bluedroid/BluetoothDaemonCoreInterface.h
@@ -276,17 +276,18 @@ private:
     SspRequestNotification;
 
   typedef mozilla::ipc::DaemonNotificationRunnable3<
     NotificationHandlerWrapper, void, BluetoothStatus, BluetoothAddress,
     BluetoothBondState, BluetoothStatus, const BluetoothAddress&>
     BondStateChangedNotification;
 
   typedef mozilla::ipc::DaemonNotificationRunnable3<
-    NotificationHandlerWrapper, void, BluetoothStatus, BluetoothAddress, bool,
+    NotificationHandlerWrapper, void,
+    BluetoothStatus, BluetoothAddress, BluetoothAclState,
     BluetoothStatus, const BluetoothAddress&>
     AclStateChangedNotification;
 
   typedef mozilla::ipc::DaemonNotificationRunnable3<
     NotificationHandlerWrapper, void, uint16_t, nsAutoArrayPtr<uint8_t>,
     uint8_t, uint16_t, const uint8_t*>
     DutModeRecvNotification;
 
--- a/dom/bluetooth/bluedroid/BluetoothDaemonHelpers.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothDaemonHelpers.cpp
@@ -587,31 +587,16 @@ Convert(nsresult aIn, BluetoothStatus& a
     aOut = STATUS_NOMEM;
   } else {
     aOut = STATUS_FAIL;
   }
   return NS_OK;
 }
 
 nsresult
-Convert(BluetoothAclState aIn, bool& aOut)
-{
-  static const bool sBool[] = {
-    [ACL_STATE_CONNECTED] = true,
-    [ACL_STATE_DISCONNECTED] = false
-  };
-  if (MOZ_HAL_IPC_CONVERT_WARN_IF(
-        aIn >= MOZ_ARRAY_LENGTH(sBool), BluetoothAclState, bool)) {
-    return NS_ERROR_ILLEGAL_VALUE;
-  }
-  aOut = sBool[aIn];
-  return NS_OK;
-}
-
-nsresult
 Convert(const BluetoothAttributeHandle& aIn, int32_t& aOut)
 {
   aOut = static_cast<int32_t>(aIn.mHandle);
   return NS_OK;
 }
 
 nsresult
 Convert(BluetoothAvrcpEvent aIn, uint8_t& aOut)
--- a/dom/bluetooth/bluedroid/BluetoothDaemonHelpers.h
+++ b/dom/bluetooth/bluedroid/BluetoothDaemonHelpers.h
@@ -22,21 +22,16 @@ using mozilla::ipc::DaemonSocketPDUHelpe
 using mozilla::ipc::DaemonSocketPDUHelpers::UnpackPDU;
 
 using namespace mozilla::ipc::DaemonSocketPDUHelpers;
 
 //
 // Helper structures
 //
 
-enum BluetoothAclState {
-  ACL_STATE_CONNECTED,
-  ACL_STATE_DISCONNECTED
-};
-
 struct BluetoothAvrcpAttributeTextPairs {
   BluetoothAvrcpAttributeTextPairs(const uint8_t* aAttr,
                                    const char** aText,
                                    size_t aLength)
     : mAttr(aAttr)
     , mText(aText)
     , mLength(aLength)
   { }
@@ -205,19 +200,16 @@ Convert(const nsAString& aIn, BluetoothP
 
 nsresult
 Convert(const nsAString& aIn, BluetoothPropertyType& aOut);
 
 nsresult
 Convert(const nsAString& aIn, BluetoothServiceName& aOut);
 
 nsresult
-Convert(BluetoothAclState aIn, bool& aOut);
-
-nsresult
 Convert(const BluetoothAttributeHandle& aIn, int32_t& aOut);
 
 nsresult
 Convert(BluetoothAvrcpEvent aIn, uint8_t& aOut);
 
 nsresult
 Convert(BluetoothAvrcpNotification aIn, uint8_t& aOut);
 
--- a/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp
@@ -2455,17 +2455,18 @@ BluetoothServiceBluedroid::BondStateChan
   } else if (!bonded && !mRemoveBondRunnables.IsEmpty()) {
     DispatchReplySuccess(mRemoveBondRunnables[0]);
     mRemoveBondRunnables.RemoveElementAt(0);
   }
 }
 
 void
 BluetoothServiceBluedroid::AclStateChangedNotification(
-  BluetoothStatus aStatus, const BluetoothAddress& aRemoteBdAddr, bool aState)
+  BluetoothStatus aStatus, const BluetoothAddress& aRemoteBdAddr,
+  BluetoothAclState aState)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   // FIXME: This will be implemented in the later patchset
 }
 
 void
 BluetoothServiceBluedroid::DutModeRecvNotification(uint16_t aOpcode,
--- a/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.h
+++ b/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.h
@@ -406,17 +406,17 @@ public:
                                       BluetoothSspVariant aPairingVariant,
                                       uint32_t aPasskey) override;
 
   virtual void BondStateChangedNotification(
     BluetoothStatus aStatus, const BluetoothAddress& aRemoteBdAddr,
     BluetoothBondState aState) override;
   virtual void AclStateChangedNotification(
     BluetoothStatus aStatus, const BluetoothAddress& aRemoteBdAddr,
-    bool aState) override;
+    BluetoothAclState aState) override;
 
   virtual void DutModeRecvNotification(uint16_t aOpcode,
                                        const uint8_t* aBuf,
                                        uint8_t aLen) override;
   virtual void LeTestModeNotification(BluetoothStatus aStatus,
                                       uint16_t aNumPackets) override;
 
   virtual void EnergyInfoNotification(
--- a/dom/bluetooth/common/BluetoothCommon.h
+++ b/dom/bluetooth/common/BluetoothCommon.h
@@ -307,16 +307,21 @@ enum BluetoothStatus {
   STATUS_UNSUPPORTED,
   STATUS_PARM_INVALID,
   STATUS_UNHANDLED,
   STATUS_AUTH_FAILURE,
   STATUS_RMT_DEV_DOWN,
   NUM_STATUS
 };
 
+enum BluetoothAclState {
+  ACL_STATE_CONNECTED,
+  ACL_STATE_DISCONNECTED
+};
+
 enum BluetoothBondState {
   BOND_STATE_NONE,
   BOND_STATE_BONDING,
   BOND_STATE_BONDED
 };
 
 /* Physical transport for GATT connections to remote dual-mode devices */
 enum BluetoothTransport {
--- a/dom/bluetooth/common/BluetoothInterface.cpp
+++ b/dom/bluetooth/common/BluetoothInterface.cpp
@@ -889,17 +889,18 @@ BluetoothNotificationHandler::SspRequest
 void
 BluetoothNotificationHandler::BondStateChangedNotification(
   BluetoothStatus aStatus, const BluetoothAddress& aRemoteBdAddr,
   BluetoothBondState aState)
 { }
 
 void
 BluetoothNotificationHandler::AclStateChangedNotification(
-  BluetoothStatus aStatus, const BluetoothAddress& aRemoteBdAddr, bool aState)
+  BluetoothStatus aStatus, const BluetoothAddress& aRemoteBdAddr,
+  BluetoothAclState aState)
 { }
 
 void
 BluetoothNotificationHandler::DutModeRecvNotification(uint16_t aOpcode,
                                                       const uint8_t* aBuf,
                                                       uint8_t aLen)
 { }
 
--- a/dom/bluetooth/common/BluetoothInterface.h
+++ b/dom/bluetooth/common/BluetoothInterface.h
@@ -957,17 +957,17 @@ public:
                                       BluetoothSspVariant aPairingVariant,
                                       uint32_t aPassKey);
 
   virtual void BondStateChangedNotification(
     BluetoothStatus aStatus, const BluetoothAddress& aRemoteBdAddr,
     BluetoothBondState aState);
   virtual void AclStateChangedNotification(
     BluetoothStatus aStatus, const BluetoothAddress& aRemoteBdAddr,
-    bool aState);
+    BluetoothAclState 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);