Bug 1146923: Pass SSP variant as enum instead of string, r=btian
☠☠ backed out by 8f132c4bba3d ☠ ☠
authorThomas Zimmermann <tdz@users.sourceforge.net>
Wed, 25 Mar 2015 10:38:00 +0100
changeset 264454 926351238914109ad550f1588e831a1750daa27b
parent 264453 7d8eb56f1e2402e86e6114d85d2839ecca748dd3
child 264455 1563e6dd4864828f3412ec864d3f0c3fa24e00ec
push id4718
push userraliiev@mozilla.com
push dateMon, 11 May 2015 18:39:53 +0000
treeherdermozilla-beta@c20c4ef55f08 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbtian
bugs1146923
milestone39.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 1146923: Pass SSP variant as enum instead of string, r=btian
dom/bluetooth/BluetoothInterface.h
dom/bluetooth/bluedroid/BluetoothDaemonInterface.cpp
dom/bluetooth/bluedroid/BluetoothHALHelpers.h
dom/bluetooth/bluedroid/BluetoothHALInterface.cpp
dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp
dom/bluetooth/bluedroid/BluetoothServiceBluedroid.h
--- a/dom/bluetooth/BluetoothInterface.h
+++ b/dom/bluetooth/BluetoothInterface.h
@@ -509,17 +509,17 @@ public:
 
   virtual void DiscoveryStateChangedNotification(bool aState) { }
 
   virtual void PinRequestNotification(const nsAString& aRemoteBdAddr,
                                       const nsAString& aBdName, uint32_t aCod) { }
   virtual void SspRequestNotification(const nsAString& aRemoteBdAddr,
                                       const nsAString& aBdName,
                                       uint32_t aCod,
-                                      const nsAString& aPairingVariant,
+                                      BluetoothSspVariant aPairingVariant,
                                       uint32_t aPassKey) { }
 
   virtual void BondStateChangedNotification(BluetoothStatus aStatus,
                                             const nsAString& aRemoteBdAddr,
                                             BluetoothBondState aState) { }
   virtual void AclStateChangedNotification(BluetoothStatus aStatus,
                                            const nsAString& aRemoteBdAddr,
                                            bool aState) { }
--- a/dom/bluetooth/bluedroid/BluetoothDaemonInterface.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothDaemonInterface.cpp
@@ -908,19 +908,18 @@ private:
 
   typedef BluetoothNotificationRunnable3<NotificationHandlerWrapper, void,
                                          nsString, nsString, uint32_t,
                                          const nsAString&, const nsAString&>
     PinRequestNotification;
 
   typedef BluetoothNotificationRunnable5<NotificationHandlerWrapper, void,
                                          nsString, nsString, uint32_t,
-                                         nsString, uint32_t,
-                                         const nsAString&, const nsAString&,
-                                         uint32_t, const nsAString&>
+                                         BluetoothSspVariant, uint32_t,
+                                         const nsAString&, const nsAString&>
     SspRequestNotification;
 
   typedef BluetoothNotificationRunnable3<NotificationHandlerWrapper, void,
                                          BluetoothStatus, nsString,
                                          BluetoothBondState,
                                          BluetoothStatus, const nsAString&>
     BondStateChangedNotification;
 
@@ -1145,17 +1144,17 @@ private:
   {
   public:
     SspRequestInitOp(BluetoothDaemonPDU& aPDU)
     : PDUInitOp(aPDU)
     { }
 
     nsresult
     operator () (nsString& aArg1, nsString& aArg2, uint32_t& aArg3,
-                 nsString& aArg4, uint32_t& aArg5) const
+                 BluetoothSspVariant aArg4, uint32_t& aArg5) const
     {
       BluetoothDaemonPDU& pdu = GetPDU();
 
       /* Read remote address */
       nsresult rv = UnpackPDU(
         pdu, UnpackConversion<BluetoothAddress, nsAString>(aArg1));
       if (NS_FAILED(rv)) {
         return rv;
@@ -1170,18 +1169,17 @@ private:
 
       /* Read CoD */
       rv = UnpackPDU(pdu, aArg3);
       if (NS_FAILED(rv)) {
         return rv;
       }
 
       /* Read pairing variant */
-      rv = UnpackPDU(
-        pdu, UnpackConversion<BluetoothSspVariant, nsAString>(aArg4));
+      rv = UnpackPDU(pdu, aArg4);
       if (NS_FAILED(rv)) {
         return rv;
       }
 
       /* Read passkey */
       rv = UnpackPDU(pdu, aArg5);
       if (NS_FAILED(rv)) {
         return rv;
--- a/dom/bluetooth/bluedroid/BluetoothHALHelpers.h
+++ b/dom/bluetooth/bluedroid/BluetoothHALHelpers.h
@@ -106,28 +106,30 @@ Convert(ConvertNamedValue& aIn, bt_prope
 
 nsresult
 Convert(const nsAString& aIn, bt_bdaddr_t& aOut);
 
 nsresult
 Convert(const nsAString& aIn, bt_ssp_variant_t& aOut);
 
 inline nsresult
-Convert(const bt_ssp_variant_t& aIn, nsAString& aOut)
+Convert(const bt_ssp_variant_t& aIn, BluetoothSspVariant& aOut)
 {
-  static const char * const sSspVariant[] = {
-    CONVERT(BT_SSP_VARIANT_PASSKEY_CONFIRMATION, "PasskeyConfirmation"),
-    CONVERT(BT_SSP_VARIANT_PASSKEY_ENTRY, "PasskeyEntry"),
-    CONVERT(BT_SSP_VARIANT_CONSENT, "Consent"),
-    CONVERT(BT_SSP_VARIANT_PASSKEY_NOTIFICATION, "PasskeyNotification")
+  static const BluetoothSspVariant sSspVariant[] = {
+    CONVERT(BT_SSP_VARIANT_PASSKEY_CONFIRMATION,
+      SSP_VARIANT_PASSKEY_CONFIRMATION),
+    CONVERT(BT_SSP_VARIANT_PASSKEY_ENTRY, SSP_VARIANT_PASSKEY_ENTRY),
+    CONVERT(BT_SSP_VARIANT_CONSENT, SSP_VARIANT_CONSENT),
+    CONVERT(BT_SSP_VARIANT_PASSKEY_NOTIFICATION,
+      SSP_VARIANT_PASSKEY_NOTIFICATION)
   };
   if (aIn >= MOZ_ARRAY_LENGTH(sSspVariant)) {
     return NS_ERROR_ILLEGAL_VALUE;
   }
-  aOut = NS_ConvertUTF8toUTF16(sSspVariant[aIn]);
+  aOut = sSspVariant[aIn];
   return NS_OK;
 }
 
 inline nsresult
 Convert(const bool& aIn, uint8_t& aOut)
 {
   // casting converts true/false to either 1 or 0
   aOut = static_cast<uint8_t>(aIn);
--- a/dom/bluetooth/bluedroid/BluetoothHALInterface.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothHALInterface.cpp
@@ -146,19 +146,18 @@ struct BluetoothCallback
 
   typedef BluetoothNotificationHALRunnable3<NotificationHandlerWrapper, void,
                                             nsString, nsString, uint32_t,
                                             const nsAString&, const nsAString&>
     PinRequestNotification;
 
   typedef BluetoothNotificationHALRunnable5<NotificationHandlerWrapper, void,
                                             nsString, nsString, uint32_t,
-                                            nsString, uint32_t,
-                                            const nsAString&, const nsAString&,
-                                            uint32_t, const nsAString&>
+                                            BluetoothSspVariant, uint32_t,
+                                            const nsAString&, const nsAString&>
     SspRequestNotification;
 
   typedef BluetoothNotificationHALRunnable3<NotificationHandlerWrapper, void,
                                             BluetoothStatus, nsString,
                                             BluetoothBondState,
                                             BluetoothStatus, const nsAString&>
     BondStateChangedNotification;
 
--- a/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp
@@ -1488,17 +1488,17 @@ BluetoothServiceBluedroid::PinRequestNot
   DistributeSignal(BluetoothSignal(NS_LITERAL_STRING("RequestPinCode"),
                                    NS_LITERAL_STRING(KEY_LOCAL_AGENT),
                                    BluetoothValue(propertiesArray)));
 }
 
 void
 BluetoothServiceBluedroid::SspRequestNotification(
   const nsAString& aRemoteBdAddr, const nsAString& aBdName, uint32_t aCod,
-  const nsAString& aPairingaVariant, uint32_t aPassKey)
+  BluetoothSspVariant aPairingVariant, uint32_t aPassKey)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   InfallibleTArray<BluetoothNamedValue> propertiesArray;
 
   BT_APPEND_NAMED_VALUE(propertiesArray, "address", nsString(aRemoteBdAddr));
   BT_APPEND_NAMED_VALUE(propertiesArray, "method",
                         NS_LITERAL_STRING("confirmation"));
--- a/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.h
+++ b/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.h
@@ -191,17 +191,17 @@ public:
   virtual void DiscoveryStateChangedNotification(bool aState) override;
 
   virtual void PinRequestNotification(const nsAString& aRemoteBdAddr,
                                       const nsAString& aBdName,
                                       uint32_t aCod) override;
   virtual void SspRequestNotification(const nsAString& aRemoteBdAddr,
                                       const nsAString& aBdName,
                                       uint32_t aCod,
-                                      const nsAString& aPairingaVariant,
+                                      BluetoothSspVariant aPairingVariant,
                                       uint32_t aPassKey) override;
 
   virtual void BondStateChangedNotification(
     BluetoothStatus aStatus, const nsAString& aRemoteBdAddr,
     BluetoothBondState aState) override;
   virtual void AclStateChangedNotification(BluetoothStatus aStatus,
                                            const nsAString& aRemoteBdAddr,
                                            bool aState) override;