Bug 1146923: Pass SSP variant as enum instead of string, r=btian
authorThomas Zimmermann <tdz@users.sourceforge.net>
Thu, 26 Mar 2015 10:29:58 +0100
changeset 265984 e81e1da40a9c9086c9b4519f4358f2be296cda41
parent 265983 ad9d80aa4f2c1e4ccbfc934bf6e5055e55331cbc
child 265985 74adb8958269c814987bc9afc223763b8996b949
push id830
push userraliiev@mozilla.com
push dateFri, 19 Jun 2015 19:24:37 +0000
treeherdermozilla-release@932614382a68 [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;