Backed out changeset 3a16edeb9ed2 (bug 1153796) for bustage on a CLOSED TREE
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Wed, 15 Apr 2015 11:33:02 +0200
changeset 258174 4fefcef6eb37cb1676de37a965a0ef75a3d3d175
parent 258173 a1ecd8ddd186bad3ec972f00e7e7fc1c09cec946
child 258175 08499ede9432299b3904473e0b19d4e4aa5510a0
push id8007
push userraliiev@mozilla.com
push dateMon, 11 May 2015 19:23:16 +0000
treeherdermozilla-aurora@e2ce1aac996e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1153796
milestone40.0a1
backs out3a16edeb9ed281e75645ec9ffea86f869f5c00c0
Backed out changeset 3a16edeb9ed2 (bug 1153796) for bustage on a CLOSED TREE
dom/bluetooth/bluedroid/BluetoothDaemonHelpers.cpp
dom/bluetooth/bluedroid/BluetoothDaemonHelpers.h
dom/bluetooth/bluedroid/BluetoothDaemonInterface.cpp
dom/bluetooth/bluedroid/BluetoothDaemonInterface.h
dom/bluetooth/bluedroid/BluetoothHALHelpers.cpp
dom/bluetooth/bluedroid/BluetoothHALHelpers.h
dom/bluetooth/bluedroid/BluetoothHALInterface.cpp
dom/bluetooth/bluedroid/BluetoothHALInterface.h
dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp
dom/bluetooth/bluetooth1/BluetoothInterface.h
--- a/dom/bluetooth/bluedroid/BluetoothDaemonHelpers.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothDaemonHelpers.cpp
@@ -593,16 +593,39 @@ Convert(const nsAString& aIn, BluetoothS
   }
 
   memcpy(aOut.mName, str, len);
   memset(aOut.mName + len, 0, sizeof(aOut.mName) - len);
 
   return NS_OK;
 }
 
+#ifdef MOZ_B2G_BT_API_V2
+// Removed in bluetooth2
+#else
+nsresult
+Convert(const nsAString& aIn, BluetoothSspVariant& aOut)
+{
+  if (aIn.EqualsLiteral("PasskeyConfirmation")) {
+    aOut = SSP_VARIANT_PASSKEY_CONFIRMATION;
+  } else if (aIn.EqualsLiteral("PasskeyEntry")) {
+    aOut = SSP_VARIANT_PASSKEY_ENTRY;
+  } else if (aIn.EqualsLiteral("Consent")) {
+    aOut = SSP_VARIANT_CONSENT;
+  } else if (aIn.EqualsLiteral("PasskeyNotification")) {
+    aOut = SSP_VARIANT_PASSKEY_NOTIFICATION;
+  } else {
+    BT_LOGR("Invalid SSP variant name: %s", NS_ConvertUTF16toUTF8(aIn).get());
+    aOut = SSP_VARIANT_PASSKEY_CONFIRMATION; // silences compiler warning
+    return NS_ERROR_ILLEGAL_VALUE;
+  }
+  return NS_OK;
+}
+#endif
+
 nsresult
 Convert(BluetoothAclState aIn, bool& aOut)
 {
   static const bool sBool[] = {
     CONVERT(ACL_STATE_CONNECTED, true),
     CONVERT(ACL_STATE_DISCONNECTED, false)
   };
   if (NS_WARN_IF(aIn >= MOZ_ARRAY_LENGTH(sBool))) {
@@ -935,16 +958,32 @@ Convert(BluetoothSspVariant aIn, uint8_t
     aOut = 0; // silences compiler warning
     return NS_ERROR_ILLEGAL_VALUE;
   }
   aOut = sValue[aIn];
   return NS_OK;
 }
 
 nsresult
+Convert(BluetoothSspVariant aIn, nsAString& aOut)
+{
+  static const char* const sString[] = {
+    CONVERT(SSP_VARIANT_PASSKEY_CONFIRMATION, "PasskeyConfirmation"),
+    CONVERT(SSP_VARIANT_PASSKEY_ENTRY, "PasskeyEntry"),
+    CONVERT(SSP_VARIANT_CONSENT, "Consent"),
+    CONVERT(SSP_VARIANT_PASSKEY_NOTIFICATION, "PasskeyNotification")
+  };
+  if (NS_WARN_IF(aIn >= MOZ_ARRAY_LENGTH(sString))) {
+    return NS_ERROR_ILLEGAL_VALUE;
+  }
+  aOut = NS_ConvertUTF8toUTF16(sString[aIn]);
+  return NS_OK;
+}
+
+nsresult
 Convert(ControlPlayStatus aIn, uint8_t& aOut)
 {
   static const uint8_t sValue[] = {
     CONVERT(PLAYSTATUS_STOPPED, 0x00),
     CONVERT(PLAYSTATUS_PLAYING, 0x01),
     CONVERT(PLAYSTATUS_PAUSED, 0x02),
     CONVERT(PLAYSTATUS_FWD_SEEK, 0x03),
     CONVERT(PLAYSTATUS_REV_SEEK, 0x04)
--- a/dom/bluetooth/bluedroid/BluetoothDaemonHelpers.h
+++ b/dom/bluetooth/bluedroid/BluetoothDaemonHelpers.h
@@ -256,16 +256,23 @@ nsresult
 Convert(const nsAString& aIn, BluetoothPinCode& aOut);
 
 nsresult
 Convert(const nsAString& aIn, BluetoothPropertyType& aOut);
 
 nsresult
 Convert(const nsAString& aIn, BluetoothServiceName& aOut);
 
+#ifdef MOZ_B2G_BT_API_V2
+// Removed in bluetooth2
+#else
+nsresult
+Convert(const nsAString& aIn, BluetoothSspVariant& aOut);
+#endif
+
 nsresult
 Convert(BluetoothAclState aIn, bool& aOut);
 
 nsresult
 Convert(const BluetoothAddress& aIn, nsAString& aOut);
 
 nsresult
 Convert(BluetoothAvrcpEvent aIn, uint8_t& aOut);
@@ -323,16 +330,19 @@ Convert(BluetoothScanMode aIn, uint8_t& 
 
 nsresult
 Convert(BluetoothSocketType aIn, uint8_t& aOut);
 
 nsresult
 Convert(BluetoothSspVariant aIn, uint8_t& aOut);
 
 nsresult
+Convert(BluetoothSspVariant aIn, nsAString& aOut);
+
+nsresult
 Convert(ControlPlayStatus aIn, uint8_t& aOut);
 
 #ifdef MOZ_B2G_BT_API_V2
 nsresult
 Convert(nsresult aIn, BluetoothStatus& aOut);
 #else
 // Missing in bluetooth1
 #endif
--- a/dom/bluetooth/bluedroid/BluetoothDaemonInterface.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothDaemonInterface.cpp
@@ -503,16 +503,17 @@ public:
     rv = Send(pdu, aRes);
     if (NS_FAILED(rv)) {
       return rv;
     }
     unused << pdu.forget();
     return rv;
   }
 
+#ifdef MOZ_B2G_BT_API_V2
   nsresult SspReplyCmd(const nsAString& aBdAddr, BluetoothSspVariant aVariant,
                        bool aAccept, uint32_t aPasskey,
                        BluetoothResultHandler* aRes)
   {
     MOZ_ASSERT(NS_IsMainThread());
 
     nsAutoPtr<BluetoothDaemonPDU> pdu(new BluetoothDaemonPDU(0x01, 0x11, 0));
 
@@ -524,16 +525,40 @@ public:
     }
     rv = Send(pdu, aRes);
     if (NS_FAILED(rv)) {
       return rv;
     }
     unused << pdu.forget();
     return rv;
   }
+#else
+  nsresult SspReplyCmd(const nsAString& aBdAddr, const nsAString& aVariant,
+                       bool aAccept, uint32_t aPasskey,
+                       BluetoothResultHandler* aRes)
+  {
+    MOZ_ASSERT(NS_IsMainThread());
+
+    nsAutoPtr<BluetoothDaemonPDU> pdu(new BluetoothDaemonPDU(0x01, 0x11, 0));
+
+    nsresult rv = PackPDU(
+      PackConversion<nsAString, BluetoothAddress>(aBdAddr),
+      PackConversion<nsAString, BluetoothSspVariant>(aVariant),
+      aAccept, aPasskey, *pdu);
+    if (NS_FAILED(rv)) {
+      return rv;
+    }
+    rv = Send(pdu, aRes);
+    if (NS_FAILED(rv)) {
+      return rv;
+    }
+    unused << pdu.forget();
+    return rv;
+  }
+#endif
 
   nsresult DutModeConfigureCmd(bool aEnable, BluetoothResultHandler* aRes)
   {
     MOZ_ASSERT(NS_IsMainThread());
 
     nsAutoPtr<BluetoothDaemonPDU> pdu(new BluetoothDaemonPDU(0x01, 0x12, 0));
 
     nsresult rv = PackPDU(aEnable, *pdu);
@@ -2399,28 +2424,43 @@ BluetoothDaemonInterface::PinReply(const
 {
   nsresult rv = static_cast<BluetoothDaemonCoreModule*>
     (mProtocol)->PinReplyCmd(aBdAddr, aAccept, aPinCode, aRes);
   if (NS_FAILED(rv)) {
     DispatchError(aRes, rv);
   }
 }
 
+#ifdef MOZ_B2G_BT_API_V2
 void
 BluetoothDaemonInterface::SspReply(const nsAString& aBdAddr,
                                    BluetoothSspVariant aVariant,
                                    bool aAccept, uint32_t aPasskey,
                                    BluetoothResultHandler* aRes)
 {
   nsresult rv = static_cast<BluetoothDaemonCoreModule*>
     (mProtocol)->SspReplyCmd(aBdAddr, aVariant, aAccept, aPasskey, aRes);
   if (NS_FAILED(rv)) {
     DispatchError(aRes, rv);
   }
 }
+#else
+void
+BluetoothDaemonInterface::SspReply(const nsAString& aBdAddr,
+                                   const nsAString& aVariant,
+                                   bool aAccept, uint32_t aPasskey,
+                                   BluetoothResultHandler* aRes)
+{
+  nsresult rv = static_cast<BluetoothDaemonCoreModule*>
+    (mProtocol)->SspReplyCmd(aBdAddr, aVariant, aAccept, aPasskey, aRes);
+  if (NS_FAILED(rv)) {
+    DispatchError(aRes, rv);
+  }
+}
+#endif
 
 /* DUT Mode */
 
 void
 BluetoothDaemonInterface::DutModeConfigure(bool aEnable,
                                            BluetoothResultHandler* aRes)
 {
   nsresult rv = static_cast<BluetoothDaemonCoreModule*>
--- a/dom/bluetooth/bluedroid/BluetoothDaemonInterface.h
+++ b/dom/bluetooth/bluedroid/BluetoothDaemonInterface.h
@@ -84,19 +84,25 @@ public:
                           BluetoothResultHandler* aRes);
 
   /* Authentication */
 
   void PinReply(const nsAString& aBdAddr, bool aAccept,
                 const nsAString& aPinCode,
                 BluetoothResultHandler* aRes);
 
+#ifdef MOZ_B2G_BT_API_V2
   void SspReply(const nsAString& aBdAddr, BluetoothSspVariant aVariant,
                 bool aAccept, uint32_t aPasskey,
                 BluetoothResultHandler* aRes);
+#else
+  void SspReply(const nsAString& aBdAddr, const nsAString& aVariant,
+                bool aAccept, uint32_t aPasskey,
+                BluetoothResultHandler* aRes);
+#endif
 
   /* DUT Mode */
 
   void DutModeConfigure(bool aEnable, BluetoothResultHandler* aRes);
   void DutModeSend(uint16_t aOpcode, uint8_t* aBuf, uint8_t aLen,
                    BluetoothResultHandler* aRes);
 
   /* LE Mode */
--- a/dom/bluetooth/bluedroid/BluetoothHALHelpers.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothHALHelpers.cpp
@@ -75,16 +75,17 @@ Convert(const nsAString& aIn, bt_bdaddr_
   for (size_t i = 0; i < MOZ_ARRAY_LENGTH(aOut.address); ++i, ++str) {
     aOut.address[i] =
       static_cast<uint8_t>(strtoul(str, const_cast<char**>(&str), 16));
   }
 
   return NS_OK;
 }
 
+#ifdef MOZ_B2G_BT_API_V2
 nsresult
 Convert(const BluetoothSspVariant aIn, bt_ssp_variant_t& aOut)
 {
   static const bt_ssp_variant_t sSspVariant[] = {
     CONVERT(SSP_VARIANT_PASSKEY_CONFIRMATION,
       BT_SSP_VARIANT_PASSKEY_CONFIRMATION),
     CONVERT(SSP_VARIANT_PASSKEY_ENTRY, BT_SSP_VARIANT_PASSKEY_ENTRY),
     CONVERT(SSP_VARIANT_CONSENT, BT_SSP_VARIANT_CONSENT),
@@ -92,16 +93,36 @@ Convert(const BluetoothSspVariant aIn, b
       BT_SSP_VARIANT_PASSKEY_NOTIFICATION)
   };
   if (aIn >= MOZ_ARRAY_LENGTH(sSspVariant)) {
     return NS_ERROR_ILLEGAL_VALUE;
   }
   aOut = sSspVariant[aIn];
   return NS_OK;
 }
+#else
+nsresult
+Convert(const nsAString& aIn, bt_ssp_variant_t& aOut)
+{
+  if (aIn.EqualsLiteral("PasskeyConfirmation")) {
+    aOut = BT_SSP_VARIANT_PASSKEY_CONFIRMATION;
+  } else if (aIn.EqualsLiteral("PasskeyEntry")) {
+    aOut = BT_SSP_VARIANT_PASSKEY_ENTRY;
+  } else if (aIn.EqualsLiteral("Consent")) {
+    aOut = BT_SSP_VARIANT_CONSENT;
+  } else if (aIn.EqualsLiteral("PasskeyNotification")) {
+    aOut = BT_SSP_VARIANT_PASSKEY_NOTIFICATION;
+  } else {
+    BT_LOGR("Invalid SSP variant name: %s", NS_ConvertUTF16toUTF8(aIn).get());
+    aOut = BT_SSP_VARIANT_PASSKEY_CONFIRMATION; // silences compiler warning
+    return NS_ERROR_ILLEGAL_VALUE;
+  }
+  return NS_OK;
+}
+#endif
 
 nsresult
 Convert(const uint8_t aIn[16], bt_uuid_t& aOut)
 {
   if (sizeof(aOut.uu) != 16) {
     return NS_ERROR_ILLEGAL_VALUE;
   }
 
--- a/dom/bluetooth/bluedroid/BluetoothHALHelpers.h
+++ b/dom/bluetooth/bluedroid/BluetoothHALHelpers.h
@@ -114,18 +114,23 @@ struct ConvertNamedValue
 };
 
 nsresult
 Convert(ConvertNamedValue& aIn, bt_property_t& aOut);
 
 nsresult
 Convert(const nsAString& aIn, bt_bdaddr_t& aOut);
 
+#ifdef MOZ_B2G_BT_API_V2
 nsresult
 Convert(BluetoothSspVariant aIn, bt_ssp_variant_t& aOut);
+#else
+nsresult
+Convert(const nsAString& aIn, bt_ssp_variant_t& aOut);
+#endif
 
 inline nsresult
 Convert(const bt_ssp_variant_t& aIn, BluetoothSspVariant& aOut)
 {
   static const BluetoothSspVariant sSspVariant[] = {
     CONVERT(BT_SSP_VARIANT_PASSKEY_CONFIRMATION,
       SSP_VARIANT_PASSKEY_CONFIRMATION),
     CONVERT(BT_SSP_VARIANT_PASSKEY_ENTRY, SSP_VARIANT_PASSKEY_ENTRY),
--- a/dom/bluetooth/bluedroid/BluetoothHALInterface.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothHALInterface.cpp
@@ -878,16 +878,17 @@ BluetoothHALInterface::PinReply(const ns
 
   if (aRes) {
     DispatchBluetoothHALResult(aRes,
                                &BluetoothResultHandler::PinReply,
                                ConvertDefault(status, STATUS_FAIL));
   }
 }
 
+#ifdef MOZ_B2G_BT_API_V2
 void
 BluetoothHALInterface::SspReply(const nsAString& aBdAddr,
                                 BluetoothSspVariant aVariant,
                                 bool aAccept, uint32_t aPasskey,
                                 BluetoothResultHandler* aRes)
 {
   int status;
   bt_bdaddr_t bdAddr;
@@ -903,16 +904,43 @@ BluetoothHALInterface::SspReply(const ns
   }
 
   if (aRes) {
     DispatchBluetoothHALResult(aRes,
                                &BluetoothResultHandler::SspReply,
                                ConvertDefault(status, STATUS_FAIL));
   }
 }
+#else
+void
+BluetoothHALInterface::SspReply(const nsAString& aBdAddr,
+                                const nsAString& aVariant,
+                                bool aAccept, uint32_t aPasskey,
+                                BluetoothResultHandler* aRes)
+{
+  int status;
+  bt_bdaddr_t bdAddr;
+  bt_ssp_variant_t variant;
+  uint8_t accept;
+
+  if (NS_SUCCEEDED(Convert(aBdAddr, bdAddr)) &&
+      NS_SUCCEEDED(Convert(aVariant, variant)) &&
+      NS_SUCCEEDED(Convert(aAccept, accept))) {
+    status = mInterface->ssp_reply(&bdAddr, variant, accept, aPasskey);
+  } else {
+    status = BT_STATUS_PARM_INVALID;
+  }
+
+  if (aRes) {
+    DispatchBluetoothHALResult(aRes,
+                               &BluetoothResultHandler::SspReply,
+                               ConvertDefault(status, STATUS_FAIL));
+  }
+}
+#endif
 
 /* DUT Mode */
 
 void
 BluetoothHALInterface::DutModeConfigure(bool aEnable,
                                         BluetoothResultHandler* aRes)
 {
   int status;
--- a/dom/bluetooth/bluedroid/BluetoothHALInterface.h
+++ b/dom/bluetooth/bluedroid/BluetoothHALInterface.h
@@ -70,19 +70,25 @@ public:
                           BluetoothResultHandler* aRes);
 
   /* Authentication */
 
   void PinReply(const nsAString& aBdAddr, bool aAccept,
                 const nsAString& aPinCode,
                 BluetoothResultHandler* aRes);
 
+#ifdef MOZ_B2G_BT_API_V2
   void SspReply(const nsAString& aBdAddr, BluetoothSspVariant aVariant,
                 bool aAccept, uint32_t aPasskey,
                 BluetoothResultHandler* aRes);
+#else
+  void SspReply(const nsAString& aBdAddr, const nsAString& aVariant,
+                bool aAccept, uint32_t aPasskey,
+                BluetoothResultHandler* aRes);
+#endif
 
   /* DUT Mode */
 
   void DutModeConfigure(bool aEnable, BluetoothResultHandler* aRes);
   void DutModeSend(uint16_t aOpcode, uint8_t* aBuf, uint8_t aLen,
                    BluetoothResultHandler* aRes);
 
   /* LE Mode */
--- a/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp
@@ -1561,17 +1561,17 @@ BluetoothServiceBluedroid::SetPairingCon
   const nsAString& aDeviceAddress, bool aConfirm,
   BluetoothReplyRunnable* aRunnable)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   ENSURE_BLUETOOTH_IS_READY(aRunnable, false);
 
   sBtInterface->SspReply(aDeviceAddress,
-                         SSP_VARIANT_PASSKEY_CONFIRMATION,
+                         NS_ConvertUTF8toUTF16("PasskeyConfirmation"),
                          aConfirm, 0, new SspReplyResultHandler(aRunnable));
   return true;
 }
 #endif
 
 #ifdef MOZ_B2G_BT_API_V2
 // Missing in bluetooth2
 #else
--- a/dom/bluetooth/bluetooth1/BluetoothInterface.h
+++ b/dom/bluetooth/bluetooth1/BluetoothInterface.h
@@ -648,18 +648,17 @@ public:
                                   BluetoothResultHandler* aRes) = 0;
 
   /* Authentication */
 
   virtual void PinReply(const nsAString& aBdAddr, bool aAccept,
                         const nsAString& aPinCode,
                         BluetoothResultHandler* aRes) = 0;
 
-  virtual void SspReply(const nsAString& aBdAddr,
-                        BluetoothSspVariant aVariant,
+  virtual void SspReply(const nsAString& aBdAddr, const nsAString& aVariant,
                         bool aAccept, uint32_t aPasskey,
                         BluetoothResultHandler* aRes) = 0;
 
   /* DUT Mode */
 
   virtual void DutModeConfigure(bool aEnable,
                                 BluetoothResultHandler* aRes) = 0;
   virtual void DutModeSend(uint16_t aOpcode, uint8_t* aBuf, uint8_t aLen,